How to parse JSON array from inside an object with rapidjson
Solution 1:
doc['layers']
is an array.
const rapidjson::Value& layers = doc["layers"];
assert(layers.IsArray());
for (size_t i=0; i < layers.Size(); i++) {
const rapidjson::Value& data = doc["layers"][i]["data"];
assert(data.IsArray());
}
UPDATE:
Direct access to first data
item in layers
:
const rapidjson::Value& data = doc["layers"][0]["data"];
This only gives you the data
for the first item in layers
array. If layers
have at least one item and you only need the first one, then this will always work.