how do I add a member to a rapidjson object and then print it?
for example add
itemtwo => "world" ;
to this object:
{"itemone":"hello"}
I tried
char buff[] = "{\"itemone\":\"hello\"}"; rapidjson::Document json_obj; if(json_obj.Parse<0>(buff.c_str()).HasParseError() == false){ json_obj["itemtwo"].SetString("world"); rapidjson::StringBuffer strbuf; rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf); json_obj.Accept(writer); cout<<strbuf.GetString()<<endl; }
I get the following output:
{"itemone":"hello"}
meaning no change. What am I doing wrong?