rabbit is a very handy rapidjson wrapper library.
dependencies
how to use
load
std::string json = "{\"value\": 123}";
rabbit::document doc;
doc.parse(json);
int value = doc["value"].as_int();
std::cout << value << std::endl; // 123
dump
rabbit::object root;
rabbit::object user = root["user"];
user["name"] = "yui";
user["age"] = 18;
std::cout << root.str() << std::endl; // {"user":{"name":"yui","age":18}}
test
- require : boost.test
mkdir build
cd build
cmake ..
make
make test
benchmark
- require: picojson
wget "http://api.reddit.com/hot" -O hot.json
g++ -I. -O2 -o bench bench.cpp
./bench 1000 2> /dev/null
score
rapidjson score: 360644
rabbit score: 363334
picojson score: 2495122