JSON中数组数据解码

JSON中数组数据模板:

{
    "event": "notification.markAsRead",
    "data": {
        "nIds": [
            1,
            2,
            3,
            4
        ]
    }
}

 

decode代码:

DictionaryValue* data_dictionaryValue = NULL;
						if (!body->GetDictionary("data", &data_dictionaryValue))
						{
							continue;
						}

						if (data_dictionaryValue)
						{
							ListValue* read_notices_id = NULL;
							data_dictionaryValue->GetList("nIds", &read_notices_id);
							vector<int>* read_notices_id_vec = new vector<int>;

							//get read notices' ids
							ListValue::iterator it = read_notices_id->begin();
							for (; it != read_notices_id->end(); it++)
							{
								int id;
								(*it)->GetAsInteger(&id);

								read_notices_id_vec->push_back(id);
							}

							events_[event_str] = (int64)read_notices_id_vec;
						}

你可能感兴趣的:(JSON中数组数据解码)