ofxJSON icon indicating copy to clipboard operation
ofxJSON copied to clipboard

updating json data

Open raditv opened this issue 9 years ago • 3 comments

do you have any sample for updating json value?

raditv avatar Mar 03 '16 13:03 raditv

Can you give a more specific example?

Do you mean like:


Json::Value v;

v["x"] = 3;

// update 

v["x"] = 4;

bakercp avatar Mar 03 '16 13:03 bakercp

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

raditv avatar Mar 05 '16 14:03 raditv

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");

hamoid avatar Mar 20 '17 15:03 hamoid