Lines Matching refs:value

177         SECTION("access specified element with default value")
181 SECTION("access existing value")
183 CHECK(j.value("integer", 2) == 1);
184 CHECK(j.value("integer", 1.0) == Approx(1));
185 CHECK(j.value("unsigned", 2) == 1u);
186 CHECK(j.value("unsigned", 1.0) == Approx(1u));
187 CHECK(j.value("null", Json(1)) == Json());
188 CHECK(j.value("boolean", false) == true);
189 CHECK(j.value("string", "bar") == "hello world");
190 CHECK(j.value("string", std::string("bar")) == "hello world");
191 CHECK(j.value("floating", 12.34) == Approx(42.23));
192 CHECK(j.value("floating", 12) == 42);
193 CHECK(j.value("object", Json({{"foo", "bar"}})) == Json::object());
194 CHECK(j.value("array", Json({10, 100})) == Json({1, 2, 3}));
196 CHECK(j_const.value("integer", 2) == 1);
197 CHECK(j_const.value("integer", 1.0) == Approx(1));
198 CHECK(j_const.value("unsigned", 2) == 1u);
199 CHECK(j_const.value("unsigned", 1.0) == Approx(1u));
200 CHECK(j_const.value("boolean", false) == true);
201 CHECK(j_const.value("string", "bar") == "hello world");
202 CHECK(j_const.value("string", std::string("bar")) == "hello world");
203 CHECK(j_const.value("floating", 12.34) == Approx(42.23));
204 CHECK(j_const.value("floating", 12) == 42);
205 CHECK(j_const.value("object", Json({{"foo", "bar"}})) == Json::object());
206 CHECK(j_const.value("array", Json({10, 100})) == Json({1, 2, 3}));
209 CHECK(j.value(std::string_view("integer"), 2) == 1);
210 CHECK(j.value(std::string_view("integer"), 1.0) == Approx(1));
211 CHECK(j.value(std::string_view("unsigned"), 2) == 1u);
212 CHECK(j.value(std::string_view("unsigned"), 1.0) == Approx(1u));
213 CHECK(j.value(std::string_view("null"), Json(1)) == Json());
214 CHECK(j.value(std::string_view("boolean"), false) == true);
215 CHECK(j.value(std::string_view("string"), "bar") == "hello world");
216 CHECK(j.value(std::string_view("string"), std::string("bar")) == "hello world");
217 CHECK(j.value(std::string_view("floating"), 12.34) == Approx(42.23));
218 CHECK(j.value(std::string_view("floating"), 12) == 42);
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}));
222 CHECK(j_const.value(std::string_view("integer"), 2) == 1);
223 CHECK(j_const.value(std::string_view("integer"), 1.0) == Approx(1));
224 CHECK(j_const.value(std::string_view("unsigned"), 2) == 1u);
225 CHECK(j_const.value(std::string_view("unsigned"), 1.0) == Approx(1u));
226 CHECK(j_const.value(std::string_view("boolean"), false) == true);
227 CHECK(j_const.value(std::string_view("string"), "bar") == "hello world");
228 CHECK(j_const.value(std::string_view("string"), std::string("bar")) == "hello world");
229 CHECK(j_const.value(std::string_view("floating"), 12.34) == Approx(42.23));
230 CHECK(j_const.value(std::string_view("floating"), 12) == 42);
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}));
236 SECTION("access non-existing value")
238 CHECK(j.value("_", 2) == 2);
239 CHECK(j.value("_", 2u) == 2u);
240 CHECK(j.value("_", false) == false);
241 CHECK(j.value("_", "bar") == "bar");
242 CHECK(j.value("_", 12.34) == Approx(12.34));
243 CHECK(j.value("_", Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
244 CHECK(j.value("_", Json({10, 100})) == Json({10, 100}));
246 CHECK(j_const.value("_", 2) == 2);
247 CHECK(j_const.value("_", 2u) == 2u);
248 CHECK(j_const.value("_", false) == false);
249 CHECK(j_const.value("_", "bar") == "bar");
250 CHECK(j_const.value("_", 12.34) == Approx(12.34));
251 CHECK(j_const.value("_", Json({{"foo", "bar"}})) == Json({{"foo", "bar"}}));
252 CHECK(j_const.value("_", Json({10, 100})) == Json({10, 100}));
255 CHECK(j.value(std::string_view("_"), 2) == 2);
256 CHECK(j.value(std::string_view("_"), 2u) == 2u);
257 CHECK(j.value(std::string_view("_"), false) == false);
258 CHECK(j.value(std::string_view("_"), "bar") == "bar");
259 CHECK(j.value(std::string_view("_"), 12.34) == Approx(12.34));
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}));
263 CHECK(j_const.value(std::string_view("_"), 2) == 2);
264 CHECK(j_const.value(std::string_view("_"), 2u) == 2u);
265 CHECK(j_const.value(std::string_view("_"), false) == false);
266 CHECK(j_const.value(std::string_view("_"), "bar") == "bar");
267 CHECK(j_const.value(std::string_view("_"), 12.34) == Approx(12.34));
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}));
279 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
280 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
283 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
284 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
292 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&);
293 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&);
296 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&);
297 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&);
305 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&);
306 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&);
309 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&);
310 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&);
318 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&);
319 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&);
322 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&);
323 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&);
331 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
332 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
335 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
336 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
344 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
345 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
348 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
349 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
357 CHECK_THROWS_WITH_AS(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
358 CHECK_THROWS_WITH_AS(j_nonobject_const.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
361 CHECK_THROWS_WITH_AS(j_nonobject.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
362 CHECK_THROWS_WITH_AS(j_nonobject_const.value(std::string_view("foo"), 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
370 SECTION("access existing value")
372 CHECK(j.value("/integer"_json_pointer, 2) == 1);
373 CHECK(j.value("/integer"_json_pointer, 1.0) == Approx(1));
374 CHECK(j.value("/unsigned"_json_pointer, 2) == 1u);
375 CHECK(j.value("/unsigned"_json_pointer, 1.0) == Approx(1u));
376 CHECK(j.value("/null"_json_pointer, Json(1)) == Json());
377 CHECK(j.value("/boolean"_json_pointer, false) == true);
378 CHECK(j.value("/string"_json_pointer, "bar") == "hello world");
379 CHECK(j.value("/string"_json_pointer, std::string("bar")) == "hello world");
380 CHECK(j.value("/floating"_json_pointer, 12.34) == Approx(42.23));
381 CHECK(j.value("/floating"_json_pointer, 12) == 42);
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}));
385 CHECK(j_const.value("/integer"_json_pointer, 2) == 1);
386 CHECK(j_const.value("/integer"_json_pointer, 1.0) == Approx(1));
387 CHECK(j_const.value("/unsigned"_json_pointer, 2) == 1u);
388 CHECK(j_const.value("/unsigned"_json_pointer, 1.0) == Approx(1u));
389 CHECK(j_const.value("/boolean"_json_pointer, false) == true);
390 CHECK(j_const.value("/string"_json_pointer, "bar") == "hello world");
391 CHECK(j_const.value("/string"_json_pointer, std::string("bar")) == "hello world");
392 CHECK(j_const.value("/floating"_json_pointer, 12.34) == Approx(42.23));
393 CHECK(j_const.value("/floating"_json_pointer, 12) == 42);
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}));
404 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
405 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
412 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&);
413 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolean", typename Json::type_error&);
420 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&);
421 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with string", typename Json::type_error&);
428 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&);
429 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array", typename Json::type_error&);
436 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
437 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
444 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
445 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
452 CHECK_THROWS_WITH_AS(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
453 CHECK_THROWS_WITH_AS(j_nonobject_const.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number", typename Json::type_error&);
486 if (std::is_same<Json, nlohmann::ordered_json>::value)
920 "[json.exception.invalid_iterator.202] iterator does not fit current value", typename Json::invalid_iterator&);
922 "[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid_iterator&);
924 "[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid_iterator&);
926 "[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid_iterator&);
932 "[json.exception.invalid_iterator.202] iterator does not fit current value", typename Json::invalid_iterator&);
934 "[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid_iterator&);
936 "[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid_iterator&);
938 "[json.exception.invalid_iterator.203] iterators do not fit current value", typename Json::invalid_iterator&);
1467 SECTION("access specified element with default value")
1471 SECTION("access non-existing value")
1473 CHECK(j.value("/not/existing"_json_pointer, 2) == 2);
1474 CHECK(j.value("/not/existing"_json_pointer, 2u) == 2u);
1475 CHECK(j.value("/not/existing"_json_pointer, false) == false);
1476 CHECK(j.value("/not/existing"_json_pointer, "bar") == "bar");
1477 CHECK(j.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
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}));
1481 CHECK(j_const.value("/not/existing"_json_pointer, 2) == 2);
1482 CHECK(j_const.value("/not/existing"_json_pointer, 2u) == 2u);
1483 CHECK(j_const.value("/not/existing"_json_pointer, false) == false);
1484 CHECK(j_const.value("/not/existing"_json_pointer, "bar") == "bar");
1485 CHECK(j_const.value("/not/existing"_json_pointer, 12.34) == Approx(12.34));
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::ordered_json)
1502 REQUIRE(std::is_same<string_t, typename Json::object_t::key_type>::value);
1521 CHECK(j.value("foo", "default") == "bar");
1522 CHECK(j.value("foo", cpstr) == "bar");
1523 CHECK(j.value("foo", castr) == "bar");
1524 CHECK(j.value("foo", str) == "bar");
1528 CHECK(j.value("baz", 0) == 42);
1529 CHECK(j.value("baz", 47) == 42);
1530 CHECK(j.value("baz", integer) == 42);
1531 CHECK(j.value("baz", size) == 42);
1533 CHECK(j.value("bar", "default") == "default");
1534 CHECK(j.value("bar", 0) == 0);
1535 CHECK(j.value("bar", 47) == 47);
1536 CHECK(j.value("bar", integer) == integer);
1537 CHECK(j.value("bar", size) == size);
1539 CHECK_THROWS_WITH_AS(Json().value("foo", "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1540 CHECK_THROWS_WITH_AS(Json().value("foo", str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1549 CHECK(j.value(key, "default") == "bar");
1550 CHECK(j.value(key, cpstr) == "bar");
1551 CHECK(j.value(key, castr) == "bar");
1552 CHECK(j.value(key, str) == "bar");
1553 CHECK(j.value(key2, 0) == 42);
1554 CHECK(j.value(key2, 47) == 42);
1555 CHECK(j.value(key2, integer) == 42);
1556 CHECK(j.value(key2, size) == 42);
1558 CHECK(j.value(key_notfound, "default") == "default");
1559 CHECK(j.value(key_notfound, 0) == 0);
1560 CHECK(j.value(key_notfound, 47) == 47);
1561 CHECK(j.value(key_notfound, integer) == integer);
1562 CHECK(j.value(key_notfound, size) == size);
1564 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1565 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1574 CHECK(j.value(key, "default") == "bar");
1575 CHECK(j.value(key, cpstr) == "bar");
1576 CHECK(j.value(key, castr) == "bar");
1577 CHECK(j.value(key, str) == "bar");
1578 CHECK(j.value(key2, 0) == 42);
1579 CHECK(j.value(key2, 47) == 42);
1580 CHECK(j.value(key2, integer) == 42);
1581 CHECK(j.value(key2, size) == 42);
1583 CHECK(j.value(key_notfound, "default") == "default");
1584 CHECK(j.value(key_notfound, 0) == 0);
1585 CHECK(j.value(key_notfound, 47) == 47);
1586 CHECK(j.value(key_notfound, integer) == integer);
1587 CHECK(j.value(key_notfound, size) == size);
1589 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1590 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1599 CHECK(j.value(key, "default") == "bar");
1600 CHECK(j.value(key, cpstr) == "bar");
1601 CHECK(j.value(key, castr) == "bar");
1602 CHECK(j.value(key, str) == "bar");
1603 CHECK(j.value(key2, 0) == 42);
1604 CHECK(j.value(key2, 47) == 42);
1605 CHECK(j.value(key2, integer) == 42);
1606 CHECK(j.value(key2, size) == 42);
1608 CHECK(j.value(key_notfound, "default") == "default");
1609 CHECK(j.value(key_notfound, 0) == 0);
1610 CHECK(j.value(key_notfound, 47) == 47);
1611 CHECK(j.value(key_notfound, integer) == integer);
1612 CHECK(j.value(key_notfound, size) == size);
1614 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1615 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1625 CHECK(j.value(key, "default") == "bar");
1626 CHECK(j.value(key, cpstr) == "bar");
1627 CHECK(j.value(key, castr) == "bar");
1628 CHECK(j.value(key, str) == "bar");
1629 CHECK(j.value(key2, 0) == 42);
1630 CHECK(j.value(key2, 47) == 42);
1631 CHECK(j.value(key2, integer) == 42);
1632 CHECK(j.value(key2, size) == 42);
1634 CHECK(j.value(key_notfound, "default") == "default");
1635 CHECK(j.value(key_notfound, 0) == 0);
1636 CHECK(j.value(key_notfound, 47) == 47);
1637 CHECK(j.value(key_notfound, integer) == integer);
1638 CHECK(j.value(key_notfound, size) == size);
1640 CHECK_THROWS_WITH_AS(Json().value(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1641 CHECK_THROWS_WITH_AS(Json().value(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1650 CHECK(j.template value<string_t>("foo", "default") == "bar");
1651 CHECK(j.template value<string_t>("foo", cpstr) == "bar");
1652 CHECK(j.template value<string_t>("foo", castr) == "bar");
1653 CHECK(j.template value<string_t>("foo", str) == "bar");
1654 CHECK(j.template value<number_integer_t>("baz", 0) == 42);
1655 CHECK(j.template value<number_integer_t>("baz", 47) == 42);
1656 CHECK(j.template value<number_integer_t>("baz", integer) == 42);
1657 CHECK(j.template value<std::size_t>("baz", 0) == 42);
1658 CHECK(j.template value<std::size_t>("baz", 47) == 42);
1659 CHECK(j.template value<std::size_t>("baz", size) == 42);
1661 CHECK(j.template value<string_t>("bar", "default") == "default");
1662 CHECK(j.template value<number_integer_t>("bar", 0) == 0);
1663 CHECK(j.template value<number_integer_t>("bar", 47) == 47);
1664 CHECK(j.template value<number_integer_t>("bar", integer) == integer);
1665 CHECK(j.template value<std::size_t>("bar", 0) == 0);
1666 CHECK(j.template value<std::size_t>("bar", 47) == 47);
1667 CHECK(j.template value<std::size_t>("bar", size) == size);
1669 CHECK_THROWS_WITH_AS(Json().template value<string_t>("foo", "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1670 CHECK_THROWS_WITH_AS(Json().template value<string_t>("foo", str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1679 CHECK(j.template value<string_t>(key, "default") == "bar");
1680 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1681 CHECK(j.template value<string_t>(key, castr) == "bar");
1682 CHECK(j.template value<string_t>(key, str) == "bar");
1683 CHECK(j.template value<number_integer_t>(key2, 0) == 42);
1684 CHECK(j.template value<number_integer_t>(key2, 47) == 42);
1685 CHECK(j.template value<number_integer_t>(key2, integer) == 42);
1686 CHECK(j.template value<std::size_t>(key2, 0) == 42);
1687 CHECK(j.template value<std::size_t>(key2, 47) == 42);
1688 CHECK(j.template value<std::size_t>(key2, size) == 42);
1690 CHECK(j.template value<string_t>(key_notfound, "default") == "default");
1691 CHECK(j.template value<number_integer_t>(key_notfound, 0) == 0);
1692 CHECK(j.template value<number_integer_t>(key_notfound, 47) == 47);
1693 CHECK(j.template value<number_integer_t>(key_notfound, integer) == integer);
1694 CHECK(j.template value<std::size_t>(key_notfound, 0) == 0);
1695 CHECK(j.template value<std::size_t>(key_notfound, 47) == 47);
1696 CHECK(j.template value<std::size_t>(key_notfound, size) == size);
1698 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1699 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1708 CHECK(j.template value<string_t>(key, "default") == "bar");
1709 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1710 CHECK(j.template value<string_t>(key, castr) == "bar");
1711 CHECK(j.template value<string_t>(key, str) == "bar");
1712 CHECK(j.template value<number_integer_t>(key2, 0) == 42);
1713 CHECK(j.template value<number_integer_t>(key2, 47) == 42);
1714 CHECK(j.template value<number_integer_t>(key2, integer) == 42);
1715 CHECK(j.template value<std::size_t>(key2, 0) == 42);
1716 CHECK(j.template value<std::size_t>(key2, 47) == 42);
1717 CHECK(j.template value<std::size_t>(key2, size) == 42);
1719 CHECK(j.template value<string_t>(key_notfound, "default") == "default");
1720 CHECK(j.template value<number_integer_t>(key_notfound, 0) == 0);
1721 CHECK(j.template value<number_integer_t>(key_notfound, 47) == 47);
1722 CHECK(j.template value<number_integer_t>(key_notfound, integer) == integer);
1723 CHECK(j.template value<std::size_t>(key_notfound, 0) == 0);
1724 CHECK(j.template value<std::size_t>(key_notfound, 47) == 47);
1725 CHECK(j.template value<std::size_t>(key_notfound, size) == size);
1727 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1728 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1737 CHECK(j.template value<string_t>(key, "default") == "bar");
1738 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1739 CHECK(j.template value<string_t>(key, castr) == "bar");
1740 CHECK(j.template value<string_t>(key, str) == "bar");
1741 CHECK(j.template value<number_integer_t>(key2, 0) == 42);
1742 CHECK(j.template value<number_integer_t>(key2, 47) == 42);
1743 CHECK(j.template value<std::size_t>(key2, 0) == 42);
1744 CHECK(j.template value<std::size_t>(key2, 47) == 42);
1746 CHECK(j.template value<string_t>(key_notfound, "default") == "default");
1747 CHECK(j.template value<number_integer_t>(key_notfound, 0) == 0);
1748 CHECK(j.template value<number_integer_t>(key_notfound, 47) == 47);
1749 CHECK(j.template value<std::size_t>(key_notfound, 0) == 0);
1750 CHECK(j.template value<std::size_t>(key_notfound, 47) == 47);
1752 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1753 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1763 CHECK(j.template value<string_t>(key, "default") == "bar");
1764 CHECK(j.template value<string_t>(key, cpstr) == "bar");
1765 CHECK(j.template value<string_t>(key, castr) == "bar");
1766 CHECK(j.template value<string_t>(key, str) == "bar");
1767 CHECK(j.template value<number_integer_t>(key2, 0) == 42);
1768 CHECK(j.template value<number_integer_t>(key2, 47) == 42);
1769 CHECK(j.template value<number_integer_t>(key2, integer) == 42);
1770 CHECK(j.template value<std::size_t>(key2, 0) == 42);
1771 CHECK(j.template value<std::size_t>(key2, 47) == 42);
1772 CHECK(j.template value<std::size_t>(key2, size) == 42);
1774 CHECK(j.template value<string_t>(key_notfound, "default") == "default");
1775 CHECK(j.template value<number_integer_t>(key_notfound, 0) == 0);
1776 CHECK(j.template value<number_integer_t>(key_notfound, 47) == 47);
1777 CHECK(j.template value<number_integer_t>(key_notfound, integer) == integer);
1778 CHECK(j.template value<std::size_t>(key_notfound, 0) == 0);
1779 CHECK(j.template value<std::size_t>(key_notfound, 47) == 47);
1780 CHECK(j.template value<std::size_t>(key_notfound, size) == size);
1782 CHECK(j.template value<std::string_view>(key, "default") == "bar");
1783 CHECK(j.template value<std::string_view>(key, cpstr) == "bar");
1784 CHECK(j.template value<std::string_view>(key, castr) == "bar");
1785 CHECK(j.template value<std::string_view>(key, str) == "bar");
1787 CHECK(j.template value<std::string_view>(key_notfound, "default") == "default");
1789 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, "default"), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);
1790 CHECK_THROWS_WITH_AS(Json().template value<string_t>(key, str), "[json.exception.type_error.306] cannot use value() with null", typename Json::type_error&);