void *upload (void *pparam) {Cupsender *s = (cupsender*) pparam;map<string, string> mx;char tmp[20] = {0};char Filenam E[50] = {0};string data = ""; while (1) {mx.clear (); FileLog (filename, "in thread m_urlcount = [%d]", s->m_urlcount) and while (S->m_urlcount = = 0) {filelog (filename, " There is no count files....wait ten seconds!!!! "); Sleep (10);} Here is the portion of the ID that is taken out into the map for the for (int i = 1; I! = S->m_urlcount + 1; i++) {memset (tmp, 0, sizeof (TMP)); memset (filename, 0, Sizeo f (filename)); snprintf (TMP, sizeof (TMP), "%d", I); snprintf (filename, sizeof (filename), "/apps/hotel/run_env/bin/id/% D ", i); ifstream IIS (filename); Getline (IIS, mx[tmp]); FileLog (filename, "read UrlCount from%d =%s", filename, mx[tmp].c_str ());} Here to start combining json::value root; Json::value Roott; Json::value arrayobj; Json::value item;for (map<string, string>::iterator it = Mx.begin (); It! = Mx.end (); it++) {item["id"] = It->first ; Arrayobj.append (item);} Roott["Mac"] = s->m_strdevmac;roott["uploadfrequency"] = s->m_uploadfrequency;roott["URLs"] = arrayobj;root["uwdupload"] = Roott;data = Root.tostyledstring (); FileLog (FILENAME, "the thread would send to Peng WebService data: [%s], url = [%s]", Data.c_str (), (S->m_threadurl). c_s TR ()); s->sendcmd1 (data, s->m_threadurl); FileLog (FILENAME, "The Thread sleeptime is: [%d]", s->m_threadtime); sleep (S->m_threadtime);}}
The top is the process of synthesis.
{"Uwdupload": { "Mac": "F0:d1:a9:c9:56:e8", "uploadfrequency": "+", "URLs": [ {"id": "1", "total": "100" , }, {"id": "2", "Total": "*", }, { "id": "3", "Total": "," } ] }}
This is the result of the synthesis. Thinking is similar to parsing.
Jsoncpp usage easy to understand the synthesis of data in JSON format