17RAPIDJSON_DIAG_OFF(effc++)
22RAPIDJSON_DIAG_OFF(
switch-
enum)
26 :
public BaseReaderHandler<UTF8<>, MessageHandler> {
42 name_ = string(str, length);
46 messages_.insert(MessageMap::value_type(
name_,
string(str, length)));
75static void ParseMessages(
const char* json,
MessageMap& messages) {
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;
94 ParseMessages(json1, messages);
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;
102 ParseMessages(json2, messages);
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
ParseErrorCode GetParseErrorCode() const
Get the ParseErrorCode of last 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.
ParseErrorCode
Error code of parsing.
map< string, string > MessageMap
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
enum MessageHandler::State state_
bool String(const char *str, SizeType length, bool)