0

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

Community
  • 1
  • 1
Eric J
  • 1
  • Your code seems correct. May you post more complete code? – Milo Yip Nov 24 '15 at 02:35
  • I think my Eclipse installation is flaky. I installed Visual Studio 2015 with C++, and it works in that environment. I may have to reinstall Eclipse/MinGW. Eclipse/MinGW has other problems with RapidJSON, such as flagging line 168 of rapidjson.h: #define RAPIDJSON_LITTLEENDIAN 0 //!< Little endian machine with the error "missing binary operator before token "0"" which has everyone here scratching their heads. This happened after some time of it not having a problem, and then suddenly this error cropping up at the same time it found the error I described in this post. – Eric J Nov 24 '15 at 15:06
  • I may post that as a separate question if I don't resolve the Eclispe issue soon. At some point this has to work in an environment other than Microsoft Visual Studio. Eclipse is my preferred IDE. – Eric J Nov 24 '15 at 15:14

0 Answers0