ofxJSON
ofxJSON copied to clipboard
updating json data
do you have any sample for updating json value?
Can you give a more specific example?
Do you mean like:
Json::Value v;
v["x"] = 3;
// update
v["x"] = 4;
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
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");