0
FindMember를 사용하여 유효성을 검사 한 다음 JSON을 받기 원합니다. 하지만 문제는 그것이 "제목"문자열 을 찾을 수 있습니까하지만 그것은 rapidjson :: 값RapidJSON FindMember를 사용할 때 멤버 개체를받는 방법
[{
"title" : "one",
"type" : "gg",
"center" : {
},
}]
rapidjson::Document document;
if(!document.Parse(jsonContent.c_str()).HasParseError())
{
if (document.IsArray())
{
for (rapidjson::SizeType i = 0; i < document.Size(); i++)
{
rapidjson::Value& findMemberInJsonNode = FindMemberInJsonNode(&document[i], "title");
}
}
}
rapidjson::Value& HelloWorld::FindMemberInJsonNode(rapidjson::Value* jsonValue,std::string str)
{
rapidjson::Value::MemberIterator localMemberItr = jsonValue->FindMember(str.c_str());
//create null
rapidjson::Value &val = rapidjson::Value::GenericValue();
if (localMemberItr != jsonValue->MemberEnd())
{
//IT IS ENTER HERE SO it DOES FIND THE "title" STRING
val = localMemberItr->value;
if (val.IsNull())
{
int s = 1;
}
else if (val.IsObject())
{
int s = 0;
}
}
//IT IS NULL
return val;
}
왜 그들이 rapidjson 웹 사이트 튜토리얼 HasMember을 보여, 그러나 사람들은 회원이 존재하는지 확인하기 위해 다음과 같이 반복됩니다
는 또한, JSON pointer를 사용하여 이미 당신이 한 짓을 다했다? 나는 HasMember를 일하려고 애쓰는 중입니다. – Michele
FindMember()를 사용하면 동시에 값을 가져올 수 있지만 HasMember()는 bool 만 반환 할 수 있습니다. FindMember()를 사용하면 끝에 값이 필요한 경우 데이터 구조를 두 번 검색하지 못하게됩니다. –