Skip to content
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

updating json data #19

Open
raditv opened this issue Mar 3, 2016 · 3 comments
Open

updating json data #19

raditv opened this issue Mar 3, 2016 · 3 comments

Comments

@raditv
Copy link

raditv commented Mar 3, 2016

do you have any sample for updating json value?

@bakercp
Copy link
Collaborator

bakercp commented Mar 3, 2016

Can you give a more specific example?

Do you mean like:

Json::Value v;

v["x"] = 3;

// update 

v["x"] = 4;

@raditv
Copy link
Author

raditv commented Mar 5, 2016

for example I have this json file
{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML"] }, "GlossSee": "markup" } } } } }

how to update the value SortAs from SGML to LMG for example, then rewrite the file

@hamoid
Copy link

hamoid commented Mar 20, 2017

I go to this issue because I got confused between ofxJSON and ofxJsonSettings...

If I get it right, this is how you do it?

ofxJSONElement data;
data.load("file.json");
data["glossary"]["GlossDiv"]["GlossList"]["GlossEntry"]["SortAs"] = "LMG";
data.save("file.json");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants