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.")); } }