Closed wwdok closed 3 years ago
Error is :
I want to parse following json:
{ "code":200, "message":"Success", "data":[ { "masterComputer":{ "id":8, "cuid":"4efbc2ec-efe4-4f59-a7a4-1abc735e485b", "name":"Pactera", "mac":"C0-3E-BA-7D-E6-01", "ip":"192.168.53.101", "osType":"Windows 10", "status":0, "registerTime":"2021-04-26T03:11:03.000+00:00", "disconnectTime":null, "nickName":null }, "deviceInfos":[ { "id":10, "duid":"8fed50d3-ed2e-4575-acd5-ebf4797fa5ec", "sn":"AFFBB20B20900472", "name":null, "model":"KRJ-W09", "brand":"HONOR", "platform":0, "cpuAbi":"arm64-v8a", "sdkVersion":29, "status":0, "height":2000, "width":1200, "registerTime":"2021-04-26 13:12:53", "disconnectTime":"2021-04-26 15:03:23", "iconIndex":null, "masterComputerId":8, "userId":null, "masterUid":46, "userName":null, "taskId":null, "taskUserId":null, "taskUserName":null, "nickName":null, "dbcFileCid":null, "dbcFileName":null, "canCode":"0_0", "cuid":"4efbc2ec-efe4-4f59-a7a4-1abc735e485b", "canState":2 }, { "id":3, "duid":"55555555-c016-4edf-8191-711a4672567a", "sn":"192.168.53.55:5555", "name":null, "model":"jacinto6evm", "brand":"Android", "platform":0, ...
The code is :
I find if i only parse the first level, it works, but if i parse the secondary level, it will not work. I am not familiar with rapidjson, i just write such code with my intuitive
Note that data is a JSON array. To access to first element in the array, use document["data"][0]["deviceInfos"].
data
document["data"][0]["deviceInfos"]
Oh, I was so negligent at that time, you are right, thank you !
Error is :
I want to parse following json:
The code is :
I find if i only parse the first level, it works, but if i parse the secondary level, it will not work. I am not familiar with rapidjson, i just write such code with my intuitive