/xjson

c++11 json. small and simple

Primary LanguageC++GNU Lesser General Public License v3.0LGPL-3.0

xjson

c++11 json. small and simple

	xjson::obj_t obj;
	obj["int"] = 1;

	obj["bool"] = false;
	obj["float"] = 0.1;
	obj["str"] = "xjson";
	obj["vec"].add(true);
	obj["vec"].add(true);
	obj["vec"].add("xjson vec");
	obj["obj"]["child"]["int"] = 1;
	try {
		obj["obj"]["child"]["int"].get<bool>();
	}
	catch (xjson::type_error &e)
	{
		std::cout << e.str() << std::endl;
	}
	std::cout << obj.str().c_str() << std::endl;

	xjson::obj_t *json2 = xjson::build(obj.str());

	assert(json2->str() == obj.str());
	xjson::destory(json2);