-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
multi-level JSON support. #775
Comments
How are you printing them? Can you also give the exact code you're using to parse? The code above is invalid. |
//create string Thanks for taking the time to look at this! |
You are iterating over the top-level object. If you want to iterate the "sub-objects", you need to iterate over Maybe related: https://stackoverflow.com/questions/45934851/c-nlohmann-json-how-to-iterate-find-a-nested-object |
Your first line of code still won't compile, due to unquoted quotes within the string. Assuming that you're actually properly quoting these, or reading this from a file or something, then the parse looks to be fine, and you just need to handle objects within your loop, as @nlohmann described. |
When posting code, you should indent all the lines by at least 4 characters, and leave a blank line before and after. This will make github display your code as code, with the proper spacing.
|
Thank you for the tip for posting code. I'm not sure this library is going to work for me as it doesn't readily support nested json. (it->value().begin(), it->value().end() method) does not compile. I'm simply trying to parse out a multi-level json data like the example shown into an array that I can use for analysis and graphing. |
It supports nested json just fine. Did you read the stackoverflow post above? |
I did.
|
It's parsing the entire thing. It may look like it's not because when you write it to |
That worked! Totally appreciate your help on this! |
Hi,
I'm using json.hpp in an attempt to create a jason object from a json string. It appears that it only supports single hierarchy json. for example, I'm trying to parse the following:
std::string myString = "{ "Meta Data": { "1. Information": "Intraday (1min) prices and volumes", "2. Symbol" : "MSFT"}, "Time Series (1min)":{"2017-10-09 16:00:00": {"1. open": "76.3300","2. high" : "76.3400","3. low" : "76.2900"},"2017-10-09 15:59:00": {"1. open": "76.3200","2. high" : "76.3350"} }}";
json j = json::parse(myString);
when I print the json, I only get the top keys parsed:
Meta Data : {"1. Information":"Intraday (1min) prices and volumes","2. Symbol":"MSFT"}
Time Series (1min) : {"2017-10-09 15:59:00":{"1. open":"76.3200","2. high":"76.3
350"},"2017-10-09 16:00:00":{"1. open":"76.3300","2. high":"76.3400","3. low":"7
6.2900"}}
Any advise?
thanks!
Mike
The text was updated successfully, but these errors were encountered: