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();
        }
  • 相关阅读:
    uTenux-OS-Task再探
    uTenux——LED驱动讲解
    uTenux——HelloWord
    uTenux——重新整理底层驱动库
    template的超级bug
    [LeetCode] Integer to Roman
    [LeetCode] Roman to Integer
    [LeetCode]Flatten Binary Tree to Linked List
    [LeetCode] LRU Cache [Forward]
    [LeetCode] Reorder List
  • 原文地址:https://www.cnblogs.com/132818Creator/p/14349095.html
Copyright © 2011-2022 走看看