json - Writing in order to jsoncpp (c++) -


example source

    json::value root;     root["id"]=0;             json::value text;             text["first"]="i";             text["second"]="love";             text["third"]="you";     root["text"]=text;     root["type"]="test";     root["begin"]=1;     root["end"]=1;     json::styledwriter writer;     string strjson=writer.write(root);     cout<<"json writetest" << endl << strjson <<endl; 

i thought i'd write order. result

json writetest { "begin" : 1, "end" : 1, "id" : 0, "text" : { "first" : "i", "second" : "love", "third" : "you" }, "type" : "test" }

i want json format

json writetest { "id" : 0, "text" : { "first" : "i", "second" : "love", "third" : "you" }, "type" : "test" "begin" : 1, "end" : 1, }

how can write jason order?

no, don't think can. jsoncpp keeps values in std::map<czstring, value>, sorted czstring comparison. doesn't know original order added items.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -