17 RAPIDJSON_DIAG_OFF(effc++)
22 RAPIDJSON_DIAG_OFF(
switch-
enum)
31 case kExpectObjectStart:
32 state_ = kExpectNameOrObjectEnd;
41 case kExpectNameOrObjectEnd:
42 name_ = string(str, length);
43 state_ = kExpectValue;
46 messages_.insert(MessageMap::value_type(name_,
string(str, length)));
47 state_ = kExpectNameOrObjectEnd;
79 if (reader.
Parse(ss, handler))
85 cout <<
" at offset " << o <<
" near '" << string(json).substr(o, 10) <<
"...'" << endl;
92 const char* json1 =
"{ \"greeting\" : \"Hello!\", \"farewell\" : \"bye-bye!\" }";
93 cout << json1 << endl;
96 for (MessageMap::const_iterator itr = messages.begin(); itr != messages.end(); ++itr)
97 cout << itr->first <<
": " << itr->second << endl;
99 cout << endl <<
"Parse a JSON with invalid schema." << endl;
100 const char* json2 =
"{ \"greeting\" : \"Hello!\", \"farewell\" : \"bye-bye!\", \"foo\" : {} }";
101 cout << json2 << endl;
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
bool String(const char *str, SizeType length, bool)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Default implementation of Handler.
ParseErrorCode GetParseErrorCode() const
Get the ParseErrorCode of last parsing.
static void ParseMessages(const char *json, MessageMap &messages)
map< string, string > MessageMap
ParseErrorCode
Error code of parsing.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.