Sha256: 097ff1c98545a7b59aca45562f748e5b272a8e738f59bf8765932305b87a8f9b

Contents?: true

Size: 1.01 KB

Versions: 22

Compression:

Stored size: 1.01 KB

Contents

#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>

using namespace rapidjson;
using namespace std;

int main() {
    StringBuffer s;
    Writer<StringBuffer> writer(s);
    
    writer.StartObject();               // Between StartObject()/EndObject(), 
    writer.Key("hello");                // output a key,
    writer.String("world");             // follow by a value.
    writer.Key("t");
    writer.Bool(true);
    writer.Key("f");
    writer.Bool(false);
    writer.Key("n");
    writer.Null();
    writer.Key("i");
    writer.Uint(123);
    writer.Key("pi");
    writer.Double(3.1416);
    writer.Key("a");
    writer.StartArray();                // Between StartArray()/EndArray(),
    for (unsigned i = 0; i < 4; i++)
        writer.Uint(i);                 // all values are elements of the array.
    writer.EndArray();
    writer.EndObject();

    // {"hello":"world","t":true,"f":false,"n":null,"i":123,"pi":3.1416,"a":[0,1,2,3]}
    cout << s.GetString() << endl;

    return 0;
}

Version data entries

22 entries across 22 versions & 3 rubygems

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