-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading JSON which contains certain extraneous values breaks parsing #24
Comments
After further investigation, I reckon something is up with the implementation of |
I've got an implementation locally that seems to fix the issue, I'll make a PR for it. |
Hi, thank you for your time and effort. I really appreciate it! |
I took the liberty of pushing c2b4906 under your name. Its the testcase you attached, reworked in to a unit test. |
Ok, I was reviewing the code once more, and I compare it with what is done when creating the skiplists for the map object. I have pushed a1874db, its removes the recursion and just loops until done. I don't think its a performance issue, but I like the implementation better. I hope you don't mind that I have overwritten your fix. |
That's fine by me! I'll make sure it works on my end as well. |
I discovered this issue when I was trying to parse a small subset of data from a large JSON message. If I created a set of nested structs with members corresponding to only the data I needed, the parse would fail with an
ExpectedObjectStart
error at an arbitrary location. However, if I added in all of the values present in the message, it would parse correctly.I spent some time investigating this and have managed to come up with a minimal reproducible example. In the example the parsing doesn't explicitly fail, but rather the parser seems to get out of sync and places incorrect values into structs. I believe that the parser getting out of sync was the cause of my original issue.
The fundamental issue seems to be surrounding nested objects. Take the following JSON:
If this message is parsed using structs, where every key-value pair is catered for, then parsing succeeds as expected. However, if
nested_object
is omitted from the struct definition, this triggers the parsing issue. Note that the issue does not occur unless thenested_object
has at least two other nested JSON objects within it.The attached C++ project encapsulates the minimal reproducible example. In the case where the nested object fails to parse correctly. the struct representing
object2
contains a value of0
when it should contain a value of2
.json_struct MRE.zip
The text was updated successfully, but these errors were encountered: