Background: PHP generates announcements that are sent to CGI, where CGI writes JSON strings of the announcement to the file (the escaped string)
Operation via Jsoncpp
intWrite_notice_to_json (stringStr_path,Const string&str_content) {Json::reader Reader; Json::fastwriter writer; Json::value Root; if(false= = Reader.parse (str_content, Root))//Reader parses the JSON string into root,root will contain all the child elements in the JSON { returnResult_error; } std::stringJson_file =Writer.write (root); Ofstream OFS; Ofs.open (Str_path.c_str (), Ofstream:: out); if(Ofs.is_open ()) {OFS<<Json_file; Ofs.close (); returnRESULT_OK; } returnResult_error; }
Came to the company today and finally got the mark.
The string content received:
{\ "notice\": {\ "noticeversion\": \ "1414\", \ "noticecontent\": [{\ "image\": \ "notice\\/notice01\", \ "imagewidth\": \ " 350\ ", \" imageheight\ ": \" 5\ "},{\" image\ ": \" notice\\/notice02\ ", \" imagewidth\ ": \" 350\ ", \" imageheight\ ": \" 5\ "},\" Jghjfghjfghj\ "]}}
After saving to file
Trampled pit: Initially wanted to replace the reversed string with C + + but it didn't work
Cstringutils::replace (m_str_content, "\\\" "," \ "");
String written to JSON file