Looks like Types is an array, but arrays are a subclass of Object so that is why IsObject() returns true. You should call IsArray() on it to see if it is an array.
The correct syntax would be document["Types"][0]["Mtype"].GetString(), or you can iterate over it with the following:
for (SizeType i = 0; i < document["Types"].Size(); i++){
std::string strval;
if(document["Types"][i].hasMember("Mtype")){
strval = document["Types"][i]["Mtype"].GetString();
} else if(document["Types"][i].hasMember("mtypeSec")){
strval = document["Types"][i]["mtypeSec"].GetString();
} else if(document["Types"][i].hasMember("time")){
strval = document["Types"][i]["time"].GetString();
} else if(/*other member test*/){
//do something with other member
} else {
//base case, member not in the list of useful members
}
//do something useful with strval
....
}
Looks like
Types
is an array, but arrays are a subclass ofObject
so that is whyIsObject()
returns true. You should callIsArray()
on it to see if it is an array.The correct syntax would be
document["Types"][0]["Mtype"].GetString()
, or you can iterate over it with the following: