<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ### 環境 ***** 源碼下載 [GITHUB](https://github.com/open-source-parsers/jsoncpp) ### jsoncpp的使用 使用jsoncpp創建json對象 ```c++ //將字段里面的數據轉化為string 類型 string rc = root["msg"].toStyledString(); #pragma comment(lib, "lib_json.lib") int main() { std::string strValue = "{\"key\":\"value1\",\"array\":[{\"arraykey\":1},{\"arraykey\":2}]}"; Json::Reader reader; Json::Value root; // reader將Json字符串解析到root,root將包含Json里所有子元素 if (reader.parse(strValue, root)) { if (!root["key"].isNull()) { std::string strValue= root["key"].asString(); std::cout << strValue<< std::endl; } Json::Value arrayObj = root["array"]; for (int i=0; i<arrayObj.size(); i++) { int iarrayValue = arrayObj[i]["arraykey"].asInt(); std::cout << iarrayValue << std::endl; } } system("pause"); return 0; } ``` 構建Json對象序列化為字符串 ```c++ int main() { Json::Value root; Json::Value arrayObj; Json::Value item; root["key"] = "value1"; for (int i=0; i<10; i++) { item["arraykey"] = i; arrayObj.append(item); //添加新的數組成員 } root["array"] = arrayObj; std::string out = root.toStyledString(); //將Json對象序列化為字符串 std::cout << out << std::endl; system("pause"); return 0; } ``` 清空Json對象中的數組 ***** ```c++ root["array"].resize(0); ``` 刪除Json對象 ```c++ root.removeMember("key"); ``` ### 解決中文轉碼的問題 ***** ```c++ name = value[i]["name"].asString(); //解決中文轉碼問題 int len = strlen(name.c_str())+1; char outch[MAX_PATH]; WCHAR * wChar = new WCHAR[len]; wChar[0] = 0; MultiByteToWideChar(CP_UTF8, 0, name.c_str(), len, wChar, len); WideCharToMultiByte(CP_ACP, 0, wChar, len, outch , len, 0, 0); delete [] wChar; char* pchar = (char*)outch; len=strlen(pchar)+1; WCHAR outName[MAX_PATH]; MultiByteToWideChar(CP_ACP, 0, pchar, len, outName, len); AfxMessageBox(outName); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看