I have a similar issue as an earlier question (see Parsing object inside array in rapidjson ) where I am writing a recursive function to walk an arbitrary JSON tree, and I tried the suggested answer, but my C++ compiler does not like it.
I have declared the function
void traverseObject(const Value& v) {
if (v.IsObject()) {
// . . .
}
else if (v.IsArray()) {
// . . .
}
}
As you suggested (for the sake of clarity, I have left out some namespace syntax that my implementation must use). However, when calling it recursively with a Value::ConstMemberIterator itr as
traverseObject(itr->value);
or with a Value::ConstValueIterator itr as
traverseObject(*itr);
my C++ compiler generates the error
Invalid arguments ' Candidates are: void traverseObject(rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> &) '
I admit to being new to C++ (most of my OOP experience is with Java), so I am simultaneously climbing more than one learning curve here. Why does this function require that I call it with an allocator if I am just calling it with an object by reference? I also looked though the RapidJSON docs and none of the examples mention the use of an allocator with method calls, so I am probably missing something basic here due to my C++ newbie-ness, but any suggestions would be helpful.
If it helps, I am using the Eclipse C++ Development Toolkit and the MinGW compiler on Windows 7. This combination has been painful in other ways which I will not go into here, but I really like Eclipse's code analysis and refactoring tools. I am open to using other IDEs which offer comparable features.
Thanks very much for your help.
Eric