-
-
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
Accessing array inside array syntax? #2151
Comments
[
{ "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] },
{ "name":"BMW", "models":[ "320", "X3", "X5" ] },
{ "name":"Fiat", "models":[ "500", "Panda" ] }
]
{ "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] }
[ "Fiesta", "Focus", "Mustang"]
you just need to declare a |
Thank you!! This is exactly what I needed!!!! Thanks for clearing up the syntax |
json input
Accessing the trades gives me as expected:
However iterating over
and null together with an error:
What am I doing wrong? |
@Lightningblade Can you provide a full example that reproduces the issue? |
main
stocktradehistory.cpp
stocktradehistory.h
Trade is just a simple class with the 7 values. And trades is a simple vector defined in the .h file. |
Your JSON has |
Thank you very much. I literally sat at this problem for two days. |
Casual reminder that you can define JSON_DIAGNOSTICS before including the library to get extended diagnostic messages which can help to better locate the error. |
1 similar comment
Casual reminder that you can define JSON_DIAGNOSTICS before including the library to get extended diagnostic messages which can help to better locate the error. |
Hello,
I have a json file containing the following:
How would I go about accessing an array inside an array in my main.cpp file? For example if I wanted to create a sting variable and set "Fiesta" to it. Would I read into the file, declare a json object (j), and then... from here I can only guess as what the syntax would be. j[0].models[0] ??
One more question is what if the json object is an array containing multiple types (string, int, bool). Would I declare a vector of type j for the json object in my cpp file?
My apologies if this is covered in the documentation. I can't seem to figure it out.
The text was updated successfully, but these errors were encountered: