<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ### boost庫解析json ***** #### 待解析待json數據 ``` {"status":?"0", "data":?{"login_name":"1"} } ``` #### 解析示例 `ptree.get<int>("data") = ptree.get_child("data").get_value<int>()` ``` #include <iostream> #include <string> #include <sstream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> int test() { std::string s = "{\"status\":?\"0\", \"data\":?{\"login_name\":\"1\"} }" std::stringstream ss(s); boost::property_tree::ptree ptree; boost::property_tree::read_json(ss, ptree); std::cout << "input text:" << std::endl; boost::property_tree::write_json(std::cout, ptree); std::cout << "-------------------------" << std::endl; std::cout << "data.login_name:" << ptree.get<std::string>("data.login_name") << std::endl; } ``` ### 解析json數組 ***** #### 待解析一維數組 ``` {"status":["1","2"]} ``` #### 示例 ``` #include <iostream> #include <string> #include <sstream> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> int test() { std::string s = "{\"status\":?[\"1\",\"2\"]}" std::stringstream ss(s); boost::property_tree::ptree ptree; boost::property_tree::read_json(ss, ptree); std::cout << "input text:" << std::endl; for (auto &item: ptree.get_child("status")) { std::cout <<item.second.get_value<int>()<< std::endl; } } ``` #### 待解析多維數組 ``` "{\n" " \"status\": \"0\",\n" " \"data\": {\n" " \"login_name\": \"12123\",\n" " \"user_name\": \"\",\n" " \"ssid\": \"\",\n" " \"time\": \"\",\n" " \"onlineinfos\": [\n" " {\n" " \"platform\": \"1\",\n" " \"status\": \"0\",\n" " \"status_desc\": \"\",\n" " \"server_name\": \"LoginYet\",\n" " \"client_ver\": \"5.6\",\n" " \"mac\": \"\",\n" " \"ip\": \"192.168.0.1\",\n" " \"login_time\": \"\",\n" " \"is_back_online\": \"\",\n" " \"back_online_flag\": \"\"\n" " }\n" " ]\n" " }\n" "}" ``` #### 示例 ``` std::string s = "{\n" " \"status\": \"0\",\n" " \"data\": {\n" " \"login_name\": \"12123\",\n" " \"user_name\": \"\",\n" " \"ssid\": \"\",\n" " \"time\": \"\",\n" " \"onlineinfos\": [\n" " {\n" " \"platform\": \"1\",\n" " \"status\": \"0\",\n" " \"status_desc\": \"\",\n" " \"server_name\": \"LoginYet\",\n" " \"client_ver\": \"5.6\",\n" " \"mac\": \"\",\n" " \"ip\": \"192.168.0.1\",\n" " \"login_time\": \"\",\n" " \"is_back_online\": \"\",\n" " \"back_online_flag\": \"\"\n" " }\n" " ]\n" " }\n" "}"; std::stringstream ss(s); boost::property_tree::ptree ptree; boost::property_tree::read_json(ss, ptree); std::cout << "input text:" << std::endl; boost::property_tree::write_json(std::cout, ptree); std::cout << "-------------------------" << std::endl; std::cout << "data.login_name:" << ptree.get<std::string>("data.login_name") << std::endl; for (auto &item: ptree.get_child("data.onlineinfos")) { std::cout <<item.second.get<std::string>("platform")<< std::endl; } } ```
                  <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>

                              哎呀哎呀视频在线观看