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."));
        }
    }
  • 相关阅读:
    10.1~10.15学习情况
    ACM-ICPC 2018 沈阳赛区网络预赛
    打卡4
    打卡3
    tab 简单的tab
    css 圆形动画
    pdf和图片之间的转换
    对list进行分组
    C# 打开所在文件夹
    读取xml文件
  • 原文地址:https://www.cnblogs.com/lhwblog/p/7683879.html
Copyright © 2011-2022 走看看