-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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 and writing array elements #1607
Comments
The library already provides STL-like access APIs for reading/writing JSON values. Do they cover your requirements? |
Thanks, that's what I've been trying to figure out. I'm not able to "fit" any STL container to the JSON format I listed above. Finding an STL container (even if its a nested, complicated one) that would allow reading/writing of "meals" element is what this question is about. |
It appears that the STL structure would be: I was able to make it work like that, though the c++ code of adding/searching elements is quite ugly (nothing to do with the library, just a weird JSON doc format). I'll close this. |
The underlying data type is
Correct. JSON schema has a great impact on ease of implementation . I've written a sample demo based on your schema: https://wandbox.org/permlink/iVUmUQV1GDtXzr6Q You can find more info at README page and indeed the documentations. |
Thanks! |
Say I am given a JSON:
{
"name": "John Doe",
"meals":
[
{
"breakfast": "omlet at 8AM"
},
{
"lunch": "salad at 12"
}
]
}
And its loaded into below object(does not matter how):
nlohmann::json someJson;
Now I'd like to load the "meals" structure into some STL container.
std::? = someJson["meals"];
I also need to be able to make some changes to the values and write it back.
someJson["meals"] = ?;
How would that look like? Struggling to figure out the type(s) to use here.
The text was updated successfully, but these errors were encountered: