#include #include "../Jsonxx/json.hpp" using namespace jsonxx; class jsontest { public: int maintest(int argc, const char **argv) { { jsonxx::json j; j["number"] = 1; j["float"] = 1.5; j["string"] = "this is a string"; j["boolean"] = true; j["user"]["id"] = 10; j["user"]["name"] = "Nomango"; for (auto &j1 : j) { std::cout << j1 << std::endl; } // 使用初始化列表构造数组 jsonxx::json arr = {1, 2, 3}; // 使用初始化列表构造对象 jsonxx::json obj = { { "user", { {"id", 10}, {"name", "Nomango"} } } }; // 第二个对象 jsonxx::json obj2 = { {"nul", nullptr}, {"number", 1}, {"float", 1.3}, {"boolean", false}, {"string", "中文测试"}, {"array", {1, 2, true, 1.4}}, {"object", {"key", "value"}} }; } { json arr = json::array({1}); json obj = json::object({"user", {{"id", 1}, {"name", "Nomango"}}}); } } };