Sha256: 723f64435dc6260ca8fb3dd8cef0edc8e19de3a681f519eb86e6ec5f8ce9384d

Contents?: true

Size: 1.82 KB

Versions: 22

Compression:

Stored size: 1.82 KB

Contents

#include "rapidjson/reader.h"
#include <iostream>

using namespace rapidjson;
using namespace std;

struct MyHandler {
    bool Null() { cout << "Null()" << endl; return true; }
    bool Bool(bool b) { cout << "Bool(" << boolalpha << b << ")" << endl; return true; }
    bool Int(int i) { cout << "Int(" << i << ")" << endl; return true; }
    bool Uint(unsigned u) { cout << "Uint(" << u << ")" << endl; return true; }
    bool Int64(int64_t i) { cout << "Int64(" << i << ")" << endl; return true; }
    bool Uint64(uint64_t u) { cout << "Uint64(" << u << ")" << endl; return true; }
    bool Double(double d) { cout << "Double(" << d << ")" << endl; return true; }
    bool RawNumber(const char* str, SizeType length, bool copy) { 
        cout << "Number(" << str << ", " << length << ", " << boolalpha << copy << ")" << endl;
        return true;
    }
    bool String(const char* str, SizeType length, bool copy) { 
        cout << "String(" << str << ", " << length << ", " << boolalpha << copy << ")" << endl;
        return true;
    }
    bool StartObject() { cout << "StartObject()" << endl; return true; }
    bool Key(const char* str, SizeType length, bool copy) {
        cout << "Key(" << str << ", " << length << ", " << boolalpha << copy << ")" << endl;
        return true;
    }
    bool EndObject(SizeType memberCount) { cout << "EndObject(" << memberCount << ")" << endl; return true; }
    bool StartArray() { cout << "StartArray()" << endl; return true; }
    bool EndArray(SizeType elementCount) { cout << "EndArray(" << elementCount << ")" << endl; return true; }
};

int main() {
    const char json[] = " { \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3, 4] } ";

    MyHandler handler;
    Reader reader;
    StringStream ss(json);
    reader.Parse(ss, handler);

    return 0;
}

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
rj_schema-1.0.5 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-1.0.4 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-1.0.3 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-1.0.2 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-1.0.1 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-1.0.0 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
simdjson-0.3.0 vendor/simdjson/dependencies/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.2.6 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.2.5 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.2.3 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.2.2 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.2.1 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rroonga-9.0.7-x64-mingw32 vendor/local/share/doc/RapidJSON/examples/simplereader/simplereader.cpp
rroonga-9.0.7-x86-mingw32 vendor/local/share/doc/RapidJSON/examples/simplereader/simplereader.cpp
rj_schema-0.2.0 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.1.4 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.1.3 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.1.2 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.1.1 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp
rj_schema-0.1.0 ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp