-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Parsing string into json doesn't preserve the order correctly. #1817
Comments
This is known: https://github.com/nlohmann/json#order-of-object-keys |
Ok thanks, but does this solve how to access nested Json elements? or is that something unrelated? |
Does |
Yes, that works a charm! Thanks so much! This may seem like a silly question, but what does the [0] actually do there? Thanks again. |
It accesses the first element of an array, just like for a |
To be fixed with #2258. |
Describe what you want to achieve.
I want to parse a json file from the web, downloaded into a string using libcurl, back into a json object.
Describe what you tried.
Image of code
This is what I've tried - the former cout prints the string that curl downloaded, which is in the correct order of the original json on the webserver. The second cout simply posts the same json but as a json object, which has been parsed by nlohmann::json. As you can see, it is completely jumbled up. When trying to access a nested part of the json, for example ["teams"]["players"] it returns null and crashes with error 305, cannot use operator[] with a string argument. If you need any more information please don't hesitate to reply.
Describe which system (OS, compiler) you are using.
VS2015 (v140) on Windows 10
Describe which version of the library you are using (release version, develop branch).
release
The text was updated successfully, but these errors were encountered: