• 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>
20 TEST_CASE_TEMPLATE("element access 2", Json, nlohmann::json, nlohmann::ordered_json)
24Json j = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "he…
25 const Json j_const = j;
31 CHECK(j.at("integer") == Json(1));
32 CHECK(j.at("unsigned") == Json(1u));
33 CHECK(j.at("boolean") == Json(true));
34 CHECK(j.at("null") == Json(nullptr));
35 CHECK(j.at("string") == Json("hello world"));
36 CHECK(j.at("floating") == Json(42.23));
37 CHECK(j.at("object") == Json::object());
38 CHECK(j.at("array") == Json({1, 2, 3}));
40 CHECK(j_const.at("integer") == Json(1));
41 CHECK(j_const.at("unsigned") == Json(1u));
42 CHECK(j_const.at("boolean") == Json(true));
43 CHECK(j_const.at("null") == Json(nullptr));
44 CHECK(j_const.at("string") == Json("hello world"));
45 CHECK(j_const.at("floating") == Json(42.23));
46 CHECK(j_const.at("object") == Json::object());
47 CHECK(j_const.at("array") == Json({1, 2, 3}));
50 CHECK(j.at(std::string_view("integer")) == Json(1));
51 CHECK(j.at(std::string_view("unsigned")) == Json(1u));
52 CHECK(j.at(std::string_view("boolean")) == Json(true));
53 CHECK(j.at(std::string_view("null")) == Json(nullptr));
54 CHECK(j.at(std::string_view("string")) == Json("hello world"));
55 CHECK(j.at(std::string_view("floating")) == Json(42.23));
56 CHECK(j.at(std::string_view("object")) == Json::object());
57 CHECK(j.at(std::string_view("array")) == Json({1, 2, 3}));
59 CHECK(j_const.at(std::string_view("integer")) == Json(1));
60 CHECK(j_const.at(std::string_view("unsigned")) == Json(1u));
61 CHECK(j_const.at(std::string_view("boolean")) == Json(true));
62 CHECK(j_const.at(std::string_view("null")) == Json(nullptr));
63 CHECK(j_const.at(std::string_view("string")) == Json("hello world"));
64 CHECK(j_const.at(std::string_view("floating")) == Json(42.23));
65 CHECK(j_const.at(std::string_view("object")) == Json::object());
66 CHECK(j_const.at(std::string_view("array")) == Json({1, 2, 3}));
72 …CHECK_THROWS_WITH_AS(j.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", typenam…
73 …CHECK_THROWS_WITH_AS(j_const.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found", t…
77 …_WITH_AS(j.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", t…
78 …AS(j_const.at(std::string_view("foo")), "[json.exception.out_of_range.403] key 'foo' not found", t…
86 Json j_nonobject(Json::value_t::null);
87 const Json j_nonobject_const(j_nonobject);
88 …THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with null",…
89 …_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with null",…
92 …tring_view(std::string_view("foo"))), "[json.exception.type_error.304] cannot use at() with null",…
93 …tring_view(std::string_view("foo"))), "[json.exception.type_error.304] cannot use at() with null",…
99 Json j_nonobject(Json::value_t::boolean);
100 const Json j_nonobject_const(j_nonobject);
101 …HROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean…
102 …WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean…
105 …nobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with boolean…
106 …t_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with boolean…
112 Json j_nonobject(Json::value_t::string);
113 const Json j_nonobject_const(j_nonobject);
114 …HROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with string"…
115 …WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with string"…
118 …nobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with string"…
119 …t_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with string"…
125 Json j_nonobject(Json::value_t::array);
126 const Json j_nonobject_const(j_nonobject);
127 …THROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with array"…
128 …_WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with array"…
131 …onobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with array"…
132 …ct_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with array"…
138 Json j_nonobject(Json::value_t::number_integer);
139 const Json j_nonobject_const(j_nonobject);
140 …HROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number"…
141 …WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number"…
144 …nobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number"…
145 …t_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number"…
151 Json j_nonobject(Json::value_t::number_unsigned);
152 const Json j_nonobject_const(j_nonobject);
153 …HROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number"…
154 …WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number"…
157 …nobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number"…
158 …t_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number"…
164 Json j_nonobject(Json::value_t::number_float);
165 const Json j_nonobject_const(j_nonobject);
166 …HROWS_WITH_AS(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number"…
167 …WITH_AS(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number"…
170 …nobject.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number"…
171 …t_const.at(std::string_view("foo")), "[json.exception.type_error.304] cannot use at() with number"…
187 CHECK(j.value("null", Json(1)) == Json());
193 CHECK(j.value("object", Json({{"foo", "bar"}})) == Json::object());
194 CHECK(j.value("array", Json({10, 100})) == Json({1, 2, 3}));
205 CHECK(j_const.value("object", Json({{"foo", "bar"}})) == Json::object());
206 CHECK(j_const.value("array", Json({10, 100})) == Json({1, 2, 3}));
213 CHECK(j.value(std::string_view("null"), Json(1)) == Json());
219 … CHECK(j.value(std::string_view("object"), Json({{"foo", "bar"}})) == Json::object());
220 CHECK(j.value(std::string_view("array"), Json({10, 100})) == Json({1, 2, 3}));
231 … CHECK(j_const.value(std::string_view("object"), Json({{"foo", "bar"}})) == Json::object());
232 … CHECK(j_const.value(std::string_view("array"), Json({10, 100})) == Json({1, 2, 3}));
243 CHECK(j.value("_", Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
244 CHECK(j.value("_", Json({10, 100})) == Json({10, 100}));
251 CHECK(j_const.value("_", Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
252 CHECK(j_const.value("_", Json({10, 100})) == Json({10, 100}));
260 … CHECK(j.value(std::string_view("_"), Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
261 CHECK(j.value(std::string_view("_"), Json({10, 100})) == Json({10, 100}));
268 … CHECK(j_const.value(std::string_view("_"), Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
269 CHECK(j_const.value(std::string_view("_"), Json({10, 100})) == Json({10, 100}));
277 Json j_nonobject(Json::value_t::null);
278 const Json j_nonobject_const(Json::value_t::null);
279 …WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null…
280 …S(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null…
283 …t.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with null…
284 …t.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with null…
290 Json j_nonobject(Json::value_t::boolean);
291 const Json j_nonobject_const(Json::value_t::boolean);
292 …TH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolea…
293 …j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolea…
296 …value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with boolea…
297 …value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with boolea…
303 Json j_nonobject(Json::value_t::string);
304 const Json j_nonobject_const(Json::value_t::string);
305 …ITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with strin…
306 …(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with strin…
309 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with strin…
310 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with strin…
316 Json j_nonobject(Json::value_t::array);
317 const Json j_nonobject_const(Json::value_t::array);
318 …ITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array…
319 …(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array…
322 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with array…
323 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with array…
329 Json j_nonobject(Json::value_t::number_integer);
330 const Json j_nonobject_const(Json::value_t::number_integer);
331 …ITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with numbe…
332 …(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with numbe…
335 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with numbe…
336 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with numbe…
342 Json j_nonobject(Json::value_t::number_unsigned);
343 const Json j_nonobject_const(Json::value_t::number_unsigned);
344 …ITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with numbe…
345 …(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with numbe…
348 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with numbe…
349 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with numbe…
355 Json j_nonobject(Json::value_t::number_float);
356 const Json j_nonobject_const(Json::value_t::number_float);
357 …ITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with numbe…
358 …(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with numbe…
361 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with numbe…
362 ….value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with numbe…
368 SECTION("given a JSON pointer")
376 CHECK(j.value("/null"_json_pointer, Json(1)) == Json());
382 … CHECK(j.value("/object"_json_pointer, Json({{"foo", "bar"}})) == Json::object());
383 CHECK(j.value("/array"_json_pointer, Json({10, 100})) == Json({1, 2, 3}));
394 … CHECK(j_const.value("/object"_json_pointer, Json({{"foo", "bar"}})) == Json::object());
395 CHECK(j_const.value("/array"_json_pointer, Json({10, 100})) == Json({1, 2, 3}));
402 Json j_nonobject(Json::value_t::null);
403 const Json j_nonobject_const(Json::value_t::null);
404 …bject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null…
405 …const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null…
410 Json j_nonobject(Json::value_t::boolean);
411 const Json j_nonobject_const(Json::value_t::boolean);
412 …ect.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolea…
413 …nst.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolea…
418 Json j_nonobject(Json::value_t::string);
419 const Json j_nonobject_const(Json::value_t::string);
420 …ject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with strin…
421 …onst.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with strin…
426 Json j_nonobject(Json::value_t::array);
427 const Json j_nonobject_const(Json::value_t::array);
428 …ject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array…
429 …onst.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array…
434 Json j_nonobject(Json::value_t::number_integer);
435 const Json j_nonobject_const(Json::value_t::number_integer);
436 …ject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with numbe…
437 …onst.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with numbe…
442 Json j_nonobject(Json::value_t::number_unsigned);
443 const Json j_nonobject_const(Json::value_t::number_unsigned);
444 …ject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with numbe…
445 …onst.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with numbe…
450 Json j_nonobject(Json::value_t::number_float);
451 const Json j_nonobject_const(Json::value_t::number_float);
452 …ject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with numbe…
453 …onst.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with numbe…
462 Json j_null;
473 Json j_null;
486 if (std::is_same<Json, nlohmann::ordered_json>::value)
489 CHECK(j.front() == Json(1));
490 CHECK(j_const.front() == Json(1));
492 CHECK(j.back() == Json({1, 2, 3}));
493 CHECK(j_const.back() == Json({1, 2, 3}));
498 CHECK(j.front() == Json({1, 2, 3}));
499 CHECK(j_const.front() == Json({1, 2, 3}));
501 CHECK(j.back() == Json(1u));
502 CHECK(j_const.back() == Json(1u));
510 CHECK(j["integer"] == Json(1));
511 CHECK(j[typename Json::object_t::key_type("integer")] == j["integer"]);
513 CHECK(j["unsigned"] == Json(1u));
514 CHECK(j[typename Json::object_t::key_type("unsigned")] == j["unsigned"]);
516 CHECK(j["boolean"] == Json(true));
517 CHECK(j[typename Json::object_t::key_type("boolean")] == j["boolean"]);
519 CHECK(j["null"] == Json(nullptr));
520 CHECK(j[typename Json::object_t::key_type("null")] == j["null"]);
522 CHECK(j["string"] == Json("hello world"));
523 CHECK(j[typename Json::object_t::key_type("string")] == j["string"]);
525 CHECK(j["floating"] == Json(42.23));
526 CHECK(j[typename Json::object_t::key_type("floating")] == j["floating"]);
528 CHECK(j["object"] == Json::object());
529 CHECK(j[typename Json::object_t::key_type("object")] == j["object"]);
531 CHECK(j["array"] == Json({1, 2, 3}));
532 CHECK(j[typename Json::object_t::key_type("array")] == j["array"]);
534 CHECK(j_const["integer"] == Json(1));
535 CHECK(j_const[typename Json::object_t::key_type("integer")] == j["integer"]);
537 CHECK(j_const["boolean"] == Json(true));
538 CHECK(j_const[typename Json::object_t::key_type("boolean")] == j["boolean"]);
540 CHECK(j_const["null"] == Json(nullptr));
541 CHECK(j_const[typename Json::object_t::key_type("null")] == j["null"]);
543 CHECK(j_const["string"] == Json("hello world"));
544 CHECK(j_const[typename Json::object_t::key_type("string")] == j["string"]);
546 CHECK(j_const["floating"] == Json(42.23));
547 CHECK(j_const[typename Json::object_t::key_type("floating")] == j["floating"]);
549 CHECK(j_const["object"] == Json::object());
550 CHECK(j_const[typename Json::object_t::key_type("object")] == j["object"]);
552 CHECK(j_const["array"] == Json({1, 2, 3}));
553 CHECK(j_const[typename Json::object_t::key_type("array")] == j["array"]);
559 CHECK(j["integer"] == Json(1));
562 CHECK(j["unsigned"] == Json(1u));
565 CHECK(j["boolean"] == Json(true));
568 CHECK(j["null"] == Json(nullptr));
571 CHECK(j["string"] == Json("hello world"));
574 CHECK(j["floating"] == Json(42.23));
577 CHECK(j["object"] == Json::object());
580 CHECK(j["array"] == Json({1, 2, 3}));
583 CHECK(j_const["integer"] == Json(1));
586 CHECK(j_const["boolean"] == Json(true));
589 CHECK(j_const["null"] == Json(nullptr));
592 CHECK(j_const["string"] == Json("hello world"));
595 CHECK(j_const["floating"] == Json(42.23));
598 CHECK(j_const["object"] == Json::object());
601 CHECK(j_const["array"] == Json({1, 2, 3}));
610 Json j_nonobject(Json::value_t::null);
611 Json j_nonobject2(Json::value_t::null);
612 const Json j_const_nonobject(j_nonobject);
615 CHECK_NOTHROW(j_nonobject2[typename Json::object_t::key_type("foo")]);
616 …const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a string argum…
617 …ypename Json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] w…
621 …d::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argum…
627 Json j_nonobject(Json::value_t::boolean);
628 const Json j_const_nonobject(j_nonobject);
630 …"[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", typen…
631 CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")],
632 …"[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", typen…
634 …"[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", typen…
635 … CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")],
636 …"[json.exception.type_error.305] cannot use operator[] with a string argument with boolean", typen…
639 …:string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argumen…
640 …:string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argumen…
646 Json j_nonobject(Json::value_t::string);
647 const Json j_const_nonobject(j_nonobject);
649 …"[json.exception.type_error.305] cannot use operator[] with a string argument with string", typena…
650 CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")],
651 …"[json.exception.type_error.305] cannot use operator[] with a string argument with string", typena…
653 …"[json.exception.type_error.305] cannot use operator[] with a string argument with string", typena…
654 … CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")],
655 …"[json.exception.type_error.305] cannot use operator[] with a string argument with string", typena…
658 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
659 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
665 Json j_nonobject(Json::value_t::array);
666 const Json j_const_nonobject(j_nonobject);
668 …"[json.exception.type_error.305] cannot use operator[] with a string argument with array", typenam…
669 …pename Json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] wi…
671 …"[json.exception.type_error.305] cannot use operator[] with a string argument with array", typenam…
672 … CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")],
673 …"[json.exception.type_error.305] cannot use operator[] with a string argument with array", typenam…
676 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
677 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
683 Json j_nonobject(Json::value_t::number_integer);
684 const Json j_const_nonobject(j_nonobject);
686 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
687 CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")],
688 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
690 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
691 … CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")],
692 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
695 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
696 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
702 Json j_nonobject(Json::value_t::number_unsigned);
703 const Json j_const_nonobject(j_nonobject);
705 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
706 CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")],
707 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
709 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
710 … CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")],
711 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
714 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
715 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
721 Json j_nonobject(Json::value_t::number_float);
722 const Json j_const_nonobject(j_nonobject);
724 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
725 CHECK_THROWS_WITH_AS(j_nonobject[typename Json::object_t::key_type("foo")],
726 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
728 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
729 … CHECK_THROWS_WITH_AS(j_const_nonobject[typename Json::object_t::key_type("foo")],
730 …"[json.exception.type_error.305] cannot use operator[] with a string argument with number", typena…
733 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
734 …::string_view("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argume…
835 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
836 typename Json::iterator it2 = jobject.erase(jobject.begin());
837 CHECK(jobject == Json({{"b", 1}, {"c", 17u}}));
838 CHECK(*it2 == Json(1));
841 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
842 typename Json::const_iterator it2 = jobject.erase(jobject.cbegin());
843 CHECK(jobject == Json({{"b", 1}, {"c", 17u}}));
844 CHECK(*it2 == Json(1));
851 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
852 typename Json::iterator it2 = jobject.erase(jobject.begin(), jobject.end());
853 CHECK(jobject == Json::object());
857 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
858 … typename Json::const_iterator it2 = jobject.erase(jobject.cbegin(), jobject.cend());
859 CHECK(jobject == Json::object());
867 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
868 … typename Json::iterator it2 = jobject.erase(jobject.begin(), jobject.begin());
869 CHECK(jobject == Json({{"a", "a"}, {"b", 1}, {"c", 17u}}));
870 CHECK(*it2 == Json("a"));
873 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
874 … typename Json::const_iterator it2 = jobject.erase(jobject.cbegin(), jobject.cbegin());
875 CHECK(jobject == Json({{"a", "a"}, {"b", 1}, {"c", 17u}}));
876 CHECK(*it2 == Json("a"));
883 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
884 typename Json::iterator it = jobject.find("b");
885 typename Json::iterator it2 = jobject.erase(it);
886 CHECK(jobject == Json({{"a", "a"}, {"c", 17u}}));
887 CHECK(*it2 == Json(17));
890 Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}};
891 typename Json::const_iterator it = jobject.find("b");
892 typename Json::const_iterator it2 = jobject.erase(it);
893 CHECK(jobject == Json({{"a", "a"}, {"c", 17u}}));
894 CHECK(*it2 == Json(17));
901Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
902 … typename Json::iterator it2 = jobject.erase(jobject.find("b"), jobject.find("e"));
903 CHECK(jobject == Json({{"a", "a"}, {"e", true}}));
904 CHECK(*it2 == Json(true));
907Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
908 … typename Json::const_iterator it2 = jobject.erase(jobject.find("b"), jobject.find("e"));
909 CHECK(jobject == Json({{"a", "a"}, {"e", true}}));
910 CHECK(*it2 == Json(true));
917Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
918 Json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
920 …"[json.exception.invalid_iterator.202] iterator does not fit current value", typename Json::invali…
922 …"[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid…
924 …"[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid…
926 …"[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid…
929Json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}};
930 Json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}};
932 …"[json.exception.invalid_iterator.202] iterator does not fit current value", typename Json::invali…
934 …"[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid…
936 …"[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid…
938 …"[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid…
947 Json j_nonobject(Json::value_t::null);
948 …WS_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with null…
951 …ject.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with null…
957 Json j_nonobject(Json::value_t::boolean);
958 …_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with boolea…
961 …ct.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with boolea…
967 Json j_nonobject(Json::value_t::string);
968 …S_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with strin…
971 …ect.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with strin…
977 Json j_nonobject(Json::value_t::array);
978 …S_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with array…
981 …ect.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with array…
987 Json j_nonobject(Json::value_t::number_integer);
988 …S_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with numbe…
991 …ect.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with numbe…
997 Json j_nonobject(Json::value_t::number_float);
998 …S_WITH_AS(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with numbe…
1001 …ect.erase(std::string_view("foo")), "[json.exception.type_error.307] cannot use erase() with numbe…
1048 Json j_nonarray(Json::value_t::null);
1049 const Json j_nonarray_const(j_nonarray);
1062 Json j_nonarray(Json::value_t::string);
1063 const Json j_nonarray_const(j_nonarray);
1076 Json j_nonarray(Json::value_t::object);
1077 const Json j_nonarray_const(j_nonarray);
1090 Json j_nonarray(Json::value_t::array);
1091 const Json j_nonarray_const(j_nonarray);
1104 Json j_nonarray(Json::value_t::boolean);
1105 const Json j_nonarray_const(j_nonarray);
1118 Json j_nonarray(Json::value_t::number_integer);
1119 const Json j_nonarray_const(j_nonarray);
1132 Json j_nonarray(Json::value_t::number_unsigned);
1133 const Json j_nonarray_const(j_nonarray);
1146 Json j_nonarray(Json::value_t::number_float);
1147 const Json j_nonarray_const(j_nonarray);
1197 Json j_nonobject(Json::value_t::null);
1198 const Json j_nonobject_const(Json::value_t::null);
1211 Json j_nonobject(Json::value_t::string);
1212 const Json j_nonobject_const(Json::value_t::string);
1225 Json j_nonobject(Json::value_t::object);
1226 const Json j_nonobject_const(Json::value_t::object);
1239 Json j_nonobject(Json::value_t::array);
1240 const Json j_nonobject_const(Json::value_t::array);
1253 Json j_nonobject(Json::value_t::boolean);
1254 const Json j_nonobject_const(Json::value_t::boolean);
1267 Json j_nonobject(Json::value_t::number_integer);
1268 const Json j_nonobject_const(Json::value_t::number_integer);
1281 Json j_nonobject(Json::value_t::number_unsigned);
1282 const Json j_nonobject_const(Json::value_t::number_unsigned);
1295 Json j_nonobject(Json::value_t::number_float);
1296 const Json j_nonobject_const(Json::value_t::number_float);
1347 Json j_nonobject(Json::value_t::null);
1348 const Json j_nonobject_const(Json::value_t::null);
1361 Json j_nonobject(Json::value_t::string);
1362 const Json j_nonobject_const(Json::value_t::string);
1375 Json j_nonobject(Json::value_t::object);
1376 const Json j_nonobject_const(Json::value_t::object);
1389 Json j_nonobject(Json::value_t::array);
1390 const Json j_nonobject_const(Json::value_t::array);
1403 Json j_nonobject(Json::value_t::boolean);
1404 const Json j_nonobject_const(Json::value_t::boolean);
1417 Json j_nonobject(Json::value_t::number_integer);
1418 const Json j_nonobject_const(Json::value_t::number_integer);
1431 Json j_nonobject(Json::value_t::number_unsigned);
1432 const Json j_nonobject_const(Json::value_t::number_unsigned);
1445 Json j_nonobject(Json::value_t::number_float);
1446 const Json j_nonobject_const(Json::value_t::number_float);
1460 TEST_CASE_TEMPLATE("element access 2 (throwing tests)", Json, nlohmann::json, nlohmann::ordered_jso…
1464Json j = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"string", "he…
1465Json j_const = {{"integer", 1}, {"unsigned", 1u}, {"floating", 42.23}, {"null", nullptr}, {"strin…
1469 SECTION("given a JSON pointer")
1478 … CHECK(j.value("/not/existing"_json_pointer, Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
1479 … CHECK(j.value("/not/existing"_json_pointer, Json({10, 100})) == Json({10, 100}));
1486 …CHECK(j_const.value("/not/existing"_json_pointer, Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}…
1487 … CHECK(j_const.value("/not/existing"_json_pointer, Json({10, 100})) == Json({10, 100}));
1496 TEST_CASE_TEMPLATE("element access 2 (additional value() tests)", Json, nlohmann::json, nlohmann::o…
1498 using string_t = typename Json::string_t;
1499 using number_integer_t = typename Json::number_integer_t;
1502 REQUIRE(std::is_same<string_t, typename Json::object_t::key_type>::value);
1504 Json j
1539 …CHECK_THROWS_WITH_AS(Json().value("foo", "default"), "[json.exception.type_error.306] cannot use v…
1540 …CHECK_THROWS_WITH_AS(Json().value("foo", str), "[json.exception.type_error.306] cannot use value()…
1564 …CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use val…
1565 …CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() w…
1589 …CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use val…
1590 …CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() w…
1614 …CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use val…
1615 …CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() w…
1640 …CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use val…
1641 …CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() w…
1669 …OWS_WITH_AS(Json().template value<string_t>("foo", "default"), "[json.exception.type_error.306] ca…
1670 …THROWS_WITH_AS(Json().template value<string_t>("foo", str), "[json.exception.type_error.306] canno…
1698 …ROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] can…
1699 …_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot…
1727 …ROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] can…
1728 …_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot…
1752 …ROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] can…
1753 …_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot…
1789 …ROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] can…
1790 …_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot…