Recently in the completion of the establishment, the use of the JsonCpp0.5.0 version number of the source code!
According to the online installation configuration tutorial, set up a good environment can be used!
Here will not waste space to how to build the development environment! Let's go to Google for a moment!
When parsing a JSON file. The program always goes wrong somewhere!
Started to think that the TXT file format is not correct, but also deliberately found a JSON file to engage! This sends the JSON file and executes it!
Is it really a file problem! I'm simplifying my txt file, but it's still a problem, and it's not in my code. is the source of Jsoncpp has a problem! I can't believe it!!
I loaded the source into my project file, once again debug execution, debugging time to locate the problem!
In Json_reader.cpp
BOOL Reader::d ecodedouble (Token &token) { Double value = 0; const int buffersize = +; int count; int length = Int (Token.end_-token.start_); if (length <= buffersize) { Char buffer[buffersize]; memcpy (buffer, token.start_, length); Buffer[length] = 0; Count = sscanf (buffer, "%LF", &value); } else { std::string buffer (Token.start_, token.end_); Count = sscanf (Buffer.c_str (), "%lf", &value); if (count! = 1) return Adderror ("'" + std::string (Token.start_, Token.end_) + "is not a number.", token);
currentvalue () = value; return true;}
The problem is actually very easy, that is, array access to cross the border!
It would be nice to change the inferred statement in if to length < buffersize!
Test example passed! The correct resolution!
JSONCPP-SRC-0.5.0.TAR.GZ SOURCE Error!!!