1 Jsoncpp API Brief description
1, parsing (JSON string converted to object)
Std::string Strdatajson;
Json::reader Jreader;
Json::value Jobject;
if (! Jreader.parse (Strdatajson, Jobject))
{
Cerr << "Parse json error." << Endl;
return bsuccess;
}
2, read
std::string STRMSG = jrec["msg"].asstring ();
int nretcode = jrec["ret"]. Asint ();
Json::value JList = jrec["Data" ["List"];
int nSize = Jlist.size ();
Get error message: Jreader.getformatederrormessages ()
3, add or modify
jroot["StringData"] = Json::value ("msg");
jroot["Intdata"] = Json::value (10);
4, delete
Jvalue.removemember ("Toberemove");
5, the object is converted to a string
output unformatted JSON string
Json::fastwriter Fast_writer;
Strjreclist = Fast_writer.write (jroot);
JSON after formatting, with carriage return line break
std::string strout = jroot.tostyledstring ();
Jsoncpp's API brief description