zoukankan      html  css  js  c++  java
  • String 2 Json test

       Json::Value root;
        root["enabled"] = true;
        root["nodeName"] = "master";
        root["serverNo"] = 354;
        root["serverType"] = "QUOTATION_SERVER";
        root["serviceCategory"] = "STOCK";
        root["version"] = 1;
        std::string strSend = root.toStyledString();

        std::string strSend ="{ "enabled": true, "nodeName": "master", "serverNo": 354, "serverType": "QUOTATION_SERVER", "serviceCategory": "STOCK", "version": 1}";
     
     
     
        Json::Reader reader;
        Json::Value root;
        memset(buf,0,128);
        lseek(fd, 0L, SEEK_SET);
        int iRead = read(fd, buf, nSize);
        if (iRead != nSize)
        {
     
        }
       
        if (reader.parse(buf, root))
        {
            m_type = root["Type"].asInt();
            m_strIp = root["ServerIp"].asString();
            m_nPort = root["Port"].asInt();
            m_strMainConfig = root["Main_Config"].asString();
            m_strStandbyConfig = root["Standby_Config"].asString();
            m_strUseConfig = root["Use_Config"].asString();
            m_nId = root["Server_id"].asInt();
        }
  • 相关阅读:
    time模块
    Python进程模块
    Django面试题
    基本命令行语句
    scrapy中的配置与中间件
    JSON编码于解码对应dump于load
    python操作数据库
    Python里的方法
    正则表达式
    Python常用模块
  • 原文地址:https://www.cnblogs.com/132818Creator/p/14349095.html
Copyright © 2011-2022 走看看