7 RAPIDJSON_DIAG_OFF(effc++)
45 bool Null() { st_ = kHasNull; v_.SetNull();
return true; }
46 bool Bool(
bool b) { st_ = kHasBool; v_.SetBool(b);
return true; }
47 bool Int(
int i) { st_ = kHasNumber; v_.SetInt(i);
return true; }
48 bool Uint(
unsigned u) { st_ = kHasNumber; v_.SetUint(u);
return true; }
49 bool Int64(
int64_t i) { st_ = kHasNumber; v_.SetInt64(i);
return true; }
51 bool Double(
double d) { st_ = kHasNumber; v_.SetDouble(d);
return true; }
53 bool String(
const char* str,
SizeType length,
bool) { st_ = kHasString; v_.SetString(str, length);
return true; }
55 bool Key(
const char* str,
SizeType length,
bool) { st_ = kHasKey; v_.SetString(str, length);
return true; }
107 const char* NextObjectKey();
108 bool NextArrayValue();
111 const char* GetString();
124 void SkipOut(
int depth);
149 const char* result =
v_.GetString();
183 int result =
v_.GetInt();
194 double result =
v_.GetDouble();
205 bool result =
v_.GetBool();
225 const char* result =
v_.GetString();
288 char json[] =
" { \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null," 289 "\"i\":123, \"pi\": 3.1416, \"a\":[-1, 2, 3, 4, \"array\", []], \"skipArrays\":[1, 2, [[[3]]]], " 290 "\"skipObject\":{ \"i\":0, \"t\":true, \"n\":null, \"d\":123.45 }, " 291 "\"skipNested\":[[[[{\"\":0}, {\"\":[-9.87]}]]], [], []], " 292 "\"skipString\":\"zzz\", \"reachedEnd\":null, \"t\":true }";
300 if (0 == strcmp(key,
"hello")) {
302 cout << key <<
":" << r.
GetString() << endl;
304 else if (0 == strcmp(key,
"t") || 0 == strcmp(key,
"f")) {
306 cout << key <<
":" << r.
GetBool() << endl;
309 else if (0 == strcmp(key,
"n")) {
315 else if (0 == strcmp(key,
"pi")) {
317 cout << key <<
":" << r.
GetDouble() << endl;
320 else if (0 == strcmp(key,
"a")) {
325 cout << key <<
":[ ";
342 cout << key <<
":skipped" << endl;
bool RawNumber(const char *, SizeType, bool)
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
#define RAPIDJSON_ASSERT(x)
Assertion.
bool String(const char *str, SizeType length, bool)
LookaheadParsingState st_
Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS. ...
bool HasParseError() const
Whether a parse error has occured in the last parsing.
const char * NextObjectKey()
LookaheadParser(char *str)
unsigned __int64 uint64_t
bool IterativeParseNext(InputStream &is, Handler &handler)
Parse one token from JSON text.
LookaheadParserHandler(char *str)
void IterativeParseInit()
Initialize JSON text token-by-token parsing.
static const int parseFlags
bool Key(const char *str, SizeType length, bool)
In-situ(destructive) parsing.