我有一个这样的 JSON 字符串:
{"callCommand":{"command":"car","floor":"2","landing":"front"}}
现在,我想检查是否有名称command
并获取值。可能吗?我的代码如下,但它不起作用。
const char json[] = "{\"callCommand\":{\"command\":\"car\",\"floor\":\"2\",\"landing\":\"front\"}}";
rapidjson::Value::ConstMemberIterator itr = d.FindMember("command");
if (itr != d.MemberEnd())
printf("command = %s\n", d["callCommand"]["command"].GetString());