https://github.com/anhero/JsonBox
cd JsonBox && make
示例程序:
#include <iostream>
#include <string>
#include "JsonBox/Value.h"
#include "JsonBox/Object.h"
int main(int argc, const char *argv[])
{
JsonBox::Object o;
o["value"] = JsonBox::Value(123);
o["version"] = "v1.01";
o["myOtherMember"] = JsonBox::Value("asld\\kfn");
o["hahaha"] = JsonBox::Value(true);
o["adamo"] = JsonBox::Value(129.09);
std::cout << o << std::endl;
JsonBox::Value v(o);
std::cout << v["adamo"] << std::endl;
return 0;
}
编译:
$ g++ demo.cpp -o demo -I ./JsonBox/include/ -L./JsonBox/build/ -lJsonBox
运行结果:
{
"adamo" : 129.09,
"hahaha" : true,
"myOtherMember" : "asld\\kfn",
"value" : 123,
"version" : "v1.01"
}
129.09