{"id":8238,"date":"2023-01-07T15:42:53","date_gmt":"2023-01-07T07:42:53","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=8238"},"modified":"2023-10-07T14:04:36","modified_gmt":"2023-10-07T06:04:36","slug":"jsoncpp","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=8238","title":{"rendered":"jsoncpp"},"content":{"rendered":"<p><a href=\"https:\/\/blog.csdn.net\/u013456468\/article\/details\/124908853\">https:\/\/blog.csdn.net\/u013456468\/article\/details\/124908853<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/centnetHY\/article\/details\/83316090\">https:\/\/blog.csdn.net\/centnetHY\/article\/details\/83316090<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/zhanglehes\/article\/details\/128147992\">https:\/\/blog.csdn.net\/zhanglehes\/article\/details\/128147992<\/a><\/p>\n<p><a href=\"http:\/\/www.rosoo.net\/a\/202303\/17869.html\">http:\/\/www.rosoo.net\/a\/202303\/17869.html<\/a> \uff08demo\uff09<\/p>\n<ul>\n<li>\n<p>json\u89e3\u6790<\/p>\n<pre><code class=\"language-cpp\">list&lt;BoardInfo&gt; result;\nJson::Reader r;\nJson::Value root;\nif (r.parse(json, root)) {\n    int result_code = root[&quot;code&quot;].asInt();\n    if (result_code == 0) {\n        Json::Value result_data = root[&quot;data&quot;];\n        \/\/\u6570\u7ec4\u7684\u8bfb\u53d6\n        Json::Value boardList = result_data[&quot;list&quot;];\n        int size = boardList.size();\n        for (int i(0); i &lt; size; i++) {\n            BoardInfo boardInfo;\n            Json::Value boardListItem = boardList[i];\n            boardInfo.sn = boardListItem[&quot;sn&quot;].asString();\n            boardInfo.ip = boardListItem[&quot;ip&quot;].asString();\n            boardInfo.deviceStatus = boardListItem[&quot;deviceStatus&quot;].asInt();\n            result.push_back(boardInfo);\n        }\n    } else {\n        LOG(ERROR) &lt;&lt; &quot;code error :&quot; &lt;&lt; result_code;\n    }\n} else {\n    LOG(ERROR) &lt;&lt; &quot;parse json error&quot;;\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5b9e\u4f53\u7c7b\u8f6cjson<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"language-cpp\">Json::Value root;\n        Json::Value arrayObj;\n        Json::Value item;\n\n        root[&quot;memo&quot;] = pStructData-&gt;szMemo;\n        root[&quot;file_count&quot;] = pStructData-&gt;nCount;\n        \/\/ \u751f\u6210file_list\u6570\u7ec4\n        for(int i = 0; i &lt; pStructData-&gt;nCount; i ++)\n        {\n            item[&quot;num&quot;] = pStructData-&gt;szFileList[i].nNum;\n            item[&quot;file&quot;] = pStructData-&gt;szFileList[i].szFile;\n            arrayObj.append(item);\n        }\n        root[&quot;file_list&quot;] = arrayObj;\n        \/\/ JSON\u8f6c\u6362\u4e3aJSON\u5b57\u7b26\u4e32\uff08\u5df2\u683c\u5f0f\u5316\uff09\n        std::string strOut = root.toStyledString();\n        \/\/  JSON\u8f6c\u6362\u4e3aJSON\u5b57\u7b26\u4e32\uff08\u672a\u683c\u5f0f\u5316\uff09\n        \/\/Json::FastWriter writer;\n        \/\/std::string strOut = writer.write(root);\n<\/code><\/pre>\n<ul>\n<li>\u5224\u65ad\u67d0\u4e2a\u5b57\u6bb5\u662f\u5426\u5b58\u5728<br \/>\n<a href=\"https:\/\/blog.csdn.net\/weixin_34024034\/article\/details\/92340707\">https:\/\/blog.csdn.net\/weixin_34024034\/article\/details\/92340707<\/a><\/p>\n<pre><code class=\"language-cpp\">1\uff09if(root[&quot;url&quot;].type() != Json::nullValue)\n2\uff09if(value[&quot;sex&quot;].isNull())\u6216\u8005if(value.isMember(\u201csex\u201d))\n\u5982\u679c\u60f3\u8bfb\u53d6\u67d0\u4e00\u4e2a\u5b57\u6bb5\uff0c\u4f46\u662f\u53c8\u4e0d\u77e5\u9053\u5b57\u6bb5\u662f\u5426\u5b58\u5728\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd9\u6837\u5b50\u4f7f\u7528<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>Android\u5e73\u53f0\u7248\u672c\u7684jsoncpp\u4e0b\u8f7d\u53ca\u7f16\u8bd1<\/h3>\n<p><a href=\"https:\/\/www.jianshu.com\/p\/a882913c604d\">https:\/\/www.jianshu.com\/p\/a882913c604d<\/a><br \/>\ngithub\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/allanmax\/a_jsoncpp_android\">https:\/\/github.com\/allanmax\/a_jsoncpp_android<\/a><\/p>\n<ul>\n<li>android\u5e73\u53f0\u7684\u4e00\u4e9b\u95ee\u9898<br \/>\n1\uff09asstring\u65b9\u6cd5\u65e0\u6cd5\u4f7f\u7528\uff0c\u8981\u7528asCstring\u3002<\/li>\n<\/ul>\n<button class=\"simplefavorite-button\" data-postid=\"8238\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/blog.csdn.net\/u013456468\/article\/details\/1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[612],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/8238"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8238"}],"version-history":[{"count":9,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/8238\/revisions"}],"predecessor-version":[{"id":10473,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/8238\/revisions\/10473"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8238"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}