• Home
  • Raw
  • Download

Lines Matching full:json

2 //  __|  |   __|     |   | |  JSON for Modern C++ (supporting code)
4 // |_____|_____|_____|_|___| https://github.com/nlohmann/json
12 #include <nlohmann/json.hpp>
13 using nlohmann::json;
19 json j = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
20 const json j_const = j;
26 CHECK(j.at(0) == json(1));
27 CHECK(j.at(1) == json(1u));
28 CHECK(j.at(2) == json(true));
29 CHECK(j.at(3) == json(nullptr));
30 CHECK(j.at(4) == json("string"));
31 CHECK(j.at(5) == json(42.23));
32 CHECK(j.at(6) == json::object());
33 CHECK(j.at(7) == json({1, 2, 3}));
35 CHECK(j_const.at(0) == json(1));
36 CHECK(j_const.at(1) == json(1u));
37 CHECK(j_const.at(2) == json(true));
38 CHECK(j_const.at(3) == json(nullptr));
39 CHECK(j_const.at(4) == json("string"));
40 CHECK(j_const.at(5) == json(42.23));
41 CHECK(j_const.at(6) == json::object());
42 CHECK(j_const.at(7) == json({1, 2, 3}));
48 … "[json.exception.out_of_range.401] array index 8 is out of range", json::out_of_range&);
50 … "[json.exception.out_of_range.401] array index 8 is out of range", json::out_of_range&);
57 json j_nonarray(json::value_t::null);
58 const json j_nonarray_const(j_nonarray);
60 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with null"…
61 …ECK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with n…
66 json j_nonarray(json::value_t::boolean);
67 const json j_nonarray_const(j_nonarray);
69 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with boole…
70 …K_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with boo…
75 json j_nonarray(json::value_t::string);
76 const json j_nonarray_const(j_nonarray);
78 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with strin…
79 …CK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with st…
84 json j_nonarray(json::value_t::object);
85 const json j_nonarray_const(j_nonarray);
87 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with objec…
88 …CK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with ob…
93 json j_nonarray(json::value_t::number_integer);
94 const json j_nonarray_const(j_nonarray);
96 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with numbe…
97 …CK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with nu…
102 json j_nonarray(json::value_t::number_unsigned);
103 const json j_nonarray_const(j_nonarray);
105 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with numbe…
106 …CK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with nu…
111 json j_nonarray(json::value_t::number_float);
112 const json j_nonarray_const(j_nonarray);
114 …CHECK_THROWS_WITH_AS(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with numbe…
115 …CK_THROWS_WITH_AS(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with nu…
122 CHECK(j.front() == json(1));
123 CHECK(j_const.front() == json(1));
124 CHECK(j.back() == json({1, 2, 3}));
125 CHECK(j_const.back() == json({1, 2, 3}));
132 CHECK(j[0] == json(1));
133 CHECK(j[1] == json(1u));
134 CHECK(j[2] == json(true));
135 CHECK(j[3] == json(nullptr));
136 CHECK(j[4] == json("string"));
137 CHECK(j[5] == json(42.23));
138 CHECK(j[6] == json::object());
139 CHECK(j[7] == json({1, 2, 3}));
141 CHECK(j_const[0] == json(1));
142 CHECK(j_const[1] == json(1u));
143 CHECK(j_const[2] == json(true));
144 CHECK(j_const[3] == json(nullptr));
145 CHECK(j_const[4] == json("string"));
146 CHECK(j_const[5] == json(42.23));
147 CHECK(j_const[6] == json::object());
148 CHECK(j_const[7] == json({1, 2, 3}));
157 json j_nonarray(json::value_t::null);
158 const json j_nonarray_const(j_nonarray);
160 …ITH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric …
165 json j_nonarray;
167 CHECK(j_nonarray == json({nullptr, nullptr, nullptr, 42}));
173 json j_nonarray(json::value_t::boolean);
174 const json j_nonarray_const(j_nonarray);
175 …WS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric ar…
176 …H_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric ar…
181 json j_nonarray(json::value_t::string);
182 const json j_nonarray_const(j_nonarray);
183 …OWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
184 …TH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
189 json j_nonarray(json::value_t::object);
190 const json j_nonarray_const(j_nonarray);
191 …OWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
192 …TH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
197 json j_nonarray(json::value_t::number_integer);
198 const json j_nonarray_const(j_nonarray);
199 …OWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
200 …TH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
205 json j_nonarray(json::value_t::number_unsigned);
206 const json j_nonarray_const(j_nonarray);
207 …OWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
208 …TH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
213 json j_nonarray(json::value_t::number_float);
214 const json j_nonarray_const(j_nonarray);
215 …OWS_WITH_AS(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
216 …TH_AS(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric a…
226json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
228 … CHECK(jarray == json({1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
231json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
233 … CHECK(jarray == json({1, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
236json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
238 … CHECK(jarray == json({1, 1u, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
241json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
243 … CHECK(jarray == json({1, 1u, true, "string", 42.23, json::object(), {1, 2, 3}}));
246json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
248 CHECK(jarray == json({1, 1u, true, nullptr, 42.23, json::object(), {1, 2, 3}}));
251json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
253 … CHECK(jarray == json({1, 1u, true, nullptr, "string", json::object(), {1, 2, 3}}));
256json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
258 CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, {1, 2, 3}}));
261json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
263 CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, json::object()}));
266json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
267 …CHECK_THROWS_WITH_AS(jarray.erase(8), "[json.exception.out_of_range.401] array index 8 is out of r…
276json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
277 json::iterator const it2 = jarray.erase(jarray.begin());
278 … CHECK(jarray == json({1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
279 CHECK(*it2 == json(1u));
282json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
283 json::const_iterator const it2 = jarray.erase(jarray.cbegin());
284 … CHECK(jarray == json({1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
285 CHECK(*it2 == json(1u));
292json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
293 json::iterator it2 = jarray.erase(jarray.begin(), jarray.end());
294 CHECK(jarray == json::array());
298json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
299 json::const_iterator it2 = jarray.erase(jarray.cbegin(), jarray.cend());
300 CHECK(jarray == json::array());
308json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
309 json::iterator const it2 = jarray.erase(jarray.begin(), jarray.begin());
310 … CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
311 CHECK(*it2 == json(1));
314json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
315json::const_iterator const it2 = jarray.erase(jarray.cbegin(), jarray.cbegin());
316 … CHECK(jarray == json({1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}));
317 CHECK(*it2 == json(1));
324json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
325 json::iterator const it = jarray.begin() + 4;
326 json::iterator const it2 = jarray.erase(it);
327 … CHECK(jarray == json({1, 1u, true, nullptr, 42.23, json::object(), {1, 2, 3}}));
328 CHECK(*it2 == json(42.23));
331json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
332 json::const_iterator const it = jarray.cbegin() + 4;
333 json::const_iterator const it2 = jarray.erase(it);
334 … CHECK(jarray == json({1, 1u, true, nullptr, 42.23, json::object(), {1, 2, 3}}));
335 CHECK(*it2 == json(42.23));
342json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
343json::iterator const it2 = jarray.erase(jarray.begin() + 3, jarray.begin() + 6);
344 CHECK(jarray == json({1, 1u, true, json::object(), {1, 2, 3}}));
345 CHECK(*it2 == json::object());
348json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
349json::const_iterator const it2 = jarray.erase(jarray.cbegin() + 3, jarray.cbegin() + 6);
350 CHECK(jarray == json({1, 1u, true, json::object(), {1, 2, 3}}));
351 CHECK(*it2 == json::object());
358json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
359 json jarray2 = {"foo", "bar"};
362 …"[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterato…
364 …"[json.exception.invalid_iterator.203] iterators do not fit current value", json::invalid_iterator…
366 …"[json.exception.invalid_iterator.203] iterators do not fit current value", json::invalid_iterator…
368 …"[json.exception.invalid_iterator.203] iterators do not fit current value", json::invalid_iterator…
371json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}};
372 json const jarray2 = {"foo", "bar"};
375 …"[json.exception.invalid_iterator.202] iterator does not fit current value", json::invalid_iterato…
377 …"[json.exception.invalid_iterator.203] iterators do not fit current value", json::invalid_iterator…
379 …"[json.exception.invalid_iterator.203] iterators do not fit current value", json::invalid_iterator…
381 …"[json.exception.invalid_iterator.203] iterators do not fit current value", json::invalid_iterator…
390 json j_nonobject(json::value_t::null);
391 …ECK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with …
396 json j_nonobject(json::value_t::boolean);
397 …CK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with b…
402 json j_nonobject(json::value_t::string);
403 …CK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with s…
408 json j_nonobject(json::value_t::object);
409 …CK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with o…
414 json j_nonobject(json::value_t::number_integer);
415 …CK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with n…
420 json j_nonobject(json::value_t::number_unsigned);
421 …CK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with n…
426 json j_nonobject(json::value_t::number_float);
427 …CK_THROWS_WITH_AS(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with n…
440 json j;
441 …CHECK_THROWS_WITH_AS(j.front(), "[json.exception.invalid_iterator.214] cannot get value", json::in…
442 …CHECK_THROWS_WITH_AS(j.back(), "[json.exception.invalid_iterator.214] cannot get value", json::inv…
445 const json j{};
446 …CHECK_THROWS_WITH_AS(j.front(), "[json.exception.invalid_iterator.214] cannot get value", json::in…
447 …CHECK_THROWS_WITH_AS(j.back(), "[json.exception.invalid_iterator.214] cannot get value", json::inv…
454 json j = "foo";
459 const json j = "bar";
468 json j = false;
473 const json j = true;
482 json j = 17;
487 const json j = 17;
496 json j = 17u;
501 const json j = 17u;
510 json j = 23.42;
515 const json j = 23.42;
527 json j;
528 …CHECK_THROWS_WITH_AS(j.erase(j.begin()), "[json.exception.type_error.307] cannot use erase() with …
531 json j;
533 … "[json.exception.type_error.307] cannot use erase() with null", json::type_error&);
540 json j = "foo";
541 json::iterator it = j.erase(j.begin());
542 CHECK(j.type() == json::value_t::null);
546 json j = "bar";
547 json::const_iterator it = j.erase(j.cbegin());
548 CHECK(j.type() == json::value_t::null);
556 json j = false;
557 json::iterator it = j.erase(j.begin());
558 CHECK(j.type() == json::value_t::null);
562 json j = true;
563 json::const_iterator it = j.erase(j.cbegin());
564 CHECK(j.type() == json::value_t::null);
572 json j = 17;
573 json::iterator it = j.erase(j.begin());
574 CHECK(j.type() == json::value_t::null);
578 json j = 17;
579 json::const_iterator it = j.erase(j.cbegin());
580 CHECK(j.type() == json::value_t::null);
588 json j = 17u;
589 json::iterator it = j.erase(j.begin());
590 CHECK(j.type() == json::value_t::null);
594 json j = 17u;
595 json::const_iterator it = j.erase(j.cbegin());
596 CHECK(j.type() == json::value_t::null);
604 json j = 23.42;
605 json::iterator it = j.erase(j.begin());
606 CHECK(j.type() == json::value_t::null);
610 json j = 23.42;
611 json::const_iterator it = j.erase(j.cbegin());
612 CHECK(j.type() == json::value_t::null);
620 json j = json::binary({1, 2, 3});
621 json::iterator it = j.erase(j.begin());
622 CHECK(j.type() == json::value_t::null);
626 json j = json::binary({1, 2, 3});
627 json::const_iterator it = j.erase(j.cbegin());
628 CHECK(j.type() == json::value_t::null);
639 json j = "foo";
640 …CHECK_THROWS_WITH_AS(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of rang…
643 json j = "bar";
644 …CHECK_THROWS_WITH_AS(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of ran…
651 json j = false;
652 …CHECK_THROWS_WITH_AS(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of rang…
655 json j = true;
656 …CHECK_THROWS_WITH_AS(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of ran…
663 json j = 17;
664 …CHECK_THROWS_WITH_AS(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of rang…
667 json j = 17;
668 …CHECK_THROWS_WITH_AS(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of ran…
675 json j = 17u;
676 …CHECK_THROWS_WITH_AS(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of rang…
679 json j = 17u;
680 …CHECK_THROWS_WITH_AS(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of ran…
687 json j = 23.42;
688 …CHECK_THROWS_WITH_AS(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of rang…
691 json j = 23.42;
692 …CHECK_THROWS_WITH_AS(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of ran…
702 json j;
703 …OWS_WITH_AS(j.erase(j.begin(), j.end()), "[json.exception.type_error.307] cannot use erase() with …
706 json j;
707 …S_WITH_AS(j.erase(j.cbegin(), j.cend()), "[json.exception.type_error.307] cannot use erase() with …
714 json j = "foo";
715 json::iterator it = j.erase(j.begin(), j.end());
716 CHECK(j.type() == json::value_t::null);
720 json j = "bar";
721 json::const_iterator it = j.erase(j.cbegin(), j.cend());
722 CHECK(j.type() == json::value_t::null);
730 json j = false;
731 json::iterator it = j.erase(j.begin(), j.end());
732 CHECK(j.type() == json::value_t::null);
736 json j = true;
737 json::const_iterator it = j.erase(j.cbegin(), j.cend());
738 CHECK(j.type() == json::value_t::null);
746 json j = 17;
747 json::iterator it = j.erase(j.begin(), j.end());
748 CHECK(j.type() == json::value_t::null);
752 json j = 17;
753 json::const_iterator it = j.erase(j.cbegin(), j.cend());
754 CHECK(j.type() == json::value_t::null);
762 json j = 17u;
763 json::iterator it = j.erase(j.begin(), j.end());
764 CHECK(j.type() == json::value_t::null);
768 json j = 17u;
769 json::const_iterator it = j.erase(j.cbegin(), j.cend());
770 CHECK(j.type() == json::value_t::null);
778 json j = 23.42;
779 json::iterator it = j.erase(j.begin(), j.end());
780 CHECK(j.type() == json::value_t::null);
784 json j = 23.42;
785 json::const_iterator it = j.erase(j.cbegin(), j.cend());
786 CHECK(j.type() == json::value_t::null);
794 json j = json::binary({1, 2, 3});
795 json::iterator it = j.erase(j.begin(), j.end());
796 CHECK(j.type() == json::value_t::null);
800 json j = json::binary({1, 2, 3});
801 json::const_iterator it = j.erase(j.cbegin(), j.cend());
802 CHECK(j.type() == json::value_t::null);
813 json j = "foo";
814 …HROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of r…
815 …S_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of r…
818 json j = "bar";
819 …OWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of r…
820 …WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of r…
827 json j = false;
828 …HROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of r…
829 …S_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of r…
832 json j = true;
833 …OWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of r…
834 …WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of r…
841 json j = 17;
842 …HROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of r…
843 …S_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of r…
846 json j = 17;
847 …OWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of r…
848 …WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of r…
855 json j = 17u;
856 …HROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of r…
857 …S_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of r…
860 json j = 17u;
861 …OWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of r…
862 …WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of r…
869 json j = 23.42;
870 …HROWS_WITH_AS(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of r…
871 …S_WITH_AS(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of r…
874 json j = 23.42;
875 …OWS_WITH_AS(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of r…
876 …WITH_AS(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of r…