sheredom / json.h

🗄️ single header json parser for C and C++
The Unlicense
710 stars 79 forks source link

error parsing valid JSON with json_parse_flags_allow_simplified_json #28

Closed TimothyWrightSoftware closed 8 years ago

TimothyWrightSoftware commented 8 years ago

This give me a parser error when the json_parse_flags_allow_simplified_json flag is give, but work with the json_parse_flags_default flag. {"frames":[]}

The error type is error: json_parse_error_expected_colon

sheredom commented 8 years ago

Ok so this error is caused because with simplified JSON I require a global object. So what it does is it thinks the scope around the first {} is an object in its own right, and it first looks for a key for the first element of the object (and it succeeds where it probably shouldn't), and then looks for a : or = to separate the key from the value, and then bails out.

I could maybe see an argument that I should say 'you can have a global object or not' when you turn simplified JSON on, what do you think?

TimothyWrightSoftware commented 8 years ago

That was my assumption. That no matter what flags I pass in, valid JSON is always valid.

sheredom commented 8 years ago

Ok I'll rework the code with that in mind!

sheredom commented 8 years ago

I've got an MR in testing now for this fix https://github.com/sheredom/json.h/pull/29

TimothyWrightSoftware commented 8 years ago

Thank you so much for your quick attention. I wasn't sure how to tell the fix is through testing or ready to be pulled.

sheredom commented 8 years ago

So I just merged the MR into master, just pull and it should work! And don't thank me, thank YOU. It's super awesome for me that you want to use my library over others! Keep the requests coming in, always happy to add more :)