Lines Matching full:json

2 //  __|  |   __|     |   | |  JSON for Modern C++ (supporting code)
4 // |_____|_____|_____|_|___| https://github.com/nlohmann/json
11 #include <nlohmann/json.hpp>
12 using nlohmann::json;
24 json j {{"foo", 1}, {"bar", false}};
42 json j {"foo", 1, 1u, 42.23, false};
60 json j(nullptr);
78 json j(true);
96 json j("Hello world");
114 json j(42);
132 json j(42u);
150 json j(42.23);
168 json j(json::value_t::binary);
186 json j(json::value_t::discarded);
205 json j {{"object", json::object()}, {"array", {1, 2, 3, 4}}, {"number", 42}, {"boolean", false}, {"null", nullptr}, {"string", "Hello world"} };
244 const auto binary = json::binary({1, 2, 3}, 128);
250 auto s = json(42.23).dump();
256 auto s = json(1.23456e-78).dump();
262 CHECK(json("ä").dump() == "\"ä\"");
263 CHECK(json("Ö").dump() == "\"Ö\"");
264 CHECK(json("❤️").dump() == "\"❤️\"");
269 CHECK(json("ä").dump(-1, ' ', true) == "\"\\u00e4\"");
270 CHECK(json("Ö").dump(-1, ' ', true) == "\"\\u00d6\"");
271 CHECK(json("❤️").dump(-1, ' ', true) == "\"\\u2764\\ufe0f\"");
276 SECTION("parsing yields the same JSON value")
278 std::ifstream f_escaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode_ascii.json");
279 std::ifstream f_unescaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json");
281 json j1 = json::parse(f_escaped);
282 json j2 = json::parse(f_unescaped);
286 SECTION("dumping yields the same JSON text")
288 std::ifstream f_escaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode_ascii.json");
289 std::ifstream f_unescaped(TEST_DATA_DIRECTORY "/json_nlohmann_tests/all_unicode.json");
291 json value = json::parse(f_unescaped);
302 json j_discarded(json::value_t::discarded);
317 // use stringstream for JSON serialization
318 json j_number = 3.14159265358979;
335 json j1 = json::parse(s);
337 json j2 = json::parse(s1);
347 json j = nullptr;
348 CHECK(j.type() == json::value_t::null);
353 json j = {{"foo", "bar"}};
354 CHECK(j.type() == json::value_t::object);
359 json j = {1, 2, 3, 4};
360 CHECK(j.type() == json::value_t::array);
365 json j = true;
366 CHECK(j.type() == json::value_t::boolean);
371 json j = "Hello world";
372 CHECK(j.type() == json::value_t::string);
377 json j = 23;
378 CHECK(j.type() == json::value_t::number_integer);
383 json j = 23u;
384 CHECK(j.type() == json::value_t::number_unsigned);
389 json j = 42.23;
390 CHECK(j.type() == json::value_t::number_float);
398 json j = nullptr;
399 json::value_t t = j;
405 json j = {{"foo", "bar"}};
406 json::value_t t = j;
412 json j = {1, 2, 3, 4};
413 json::value_t t = j;
419 json j = true;
420 json::value_t t = j;
426 json j = "Hello world";
427 json::value_t t = j;
433 json j = 23;
434 json::value_t t = j;
440 json j = 23u;
441 json::value_t t = j;
447 json j = 42.23;
448 json::value_t t = j;
454 json j = json::binary({});
455 json::value_t t = j;