zoukankan      html  css  js  c++  java
  • 解析CommandMessage

    Json 解析:

    void CommandMessage::ParseCmdBody()
    {
        try
        {
            Json::Reader reader;
            Json::Value  root;
            if (!reader.parse(util::cStringToString(m_strRecvMsgString), root))
            {
                LOG__(ERR, _T("Json parse failed."));
                return;
            }
    
            std:string Code = root.get("code", "").asString();
            Json::Value bodyNode = root.get("body", "");     
            Json::Value mList = bodyNode.get("mlist", "");
            if (mList.isArray())
            {
                int nSize = mList.size();
                for (int i = 0; i < nSize; i++)
                {
                    Json::Value list = mList[i];
                    if (list.isObject())
                    {            
                        std::string muteType = list.get("mute_type", "").asString();
                        m_mType = atoi(muteType.c_str());
                        Json::Value frontUser = list.get("front_user", "");
                        if (frontUser.isArray())
                        {
                            int nSize = frontUser.size();
                            for (int i = 0; i < nSize; i++)
                            {
                                Json::Value List = frontUser[i];
                                Info userInfo;
                                if (List.isObject())
                                {
                                    userInfo.m_userCode = List.get("code", "").asString();
    
                                }
                                m_mapUserInfo[userInfo.m_userCode] = userInfo;
                            }
                        }
                    }
                }
            }
            
        }
        catch (...)
        {
            LOG__(ERR, _T("Json exception."));
        }
    }
  • 相关阅读:
    Codeforces
    Codeforces
    SCUT
    Codeforces
    Codeforces
    poj 2229 Sumsets(类似于n的m划分)
    poj 1742 Coins(多重背包)
    hdu 2159FATE(完全背包)
    NOIP 普及组 2014 比例简化
    2018.10.2浪在ACM 集训队第三次测试赛
  • 原文地址:https://www.cnblogs.com/lhwblog/p/7683879.html
Copyright © 2011-2022 走看看