diff --git a/annotated.html b/annotated.html index 69f7ad059..8006f12a2 100644 --- a/annotated.html +++ b/annotated.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classes.html b/classes.html index e4f786b5c..61ca37fb0 100644 --- a/classes.html +++ b/classes.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json-members.html b/classnlohmann_1_1basic__json-members.html index f46785f81..868c54d1a 100644 --- a/classnlohmann_1_1basic__json-members.html +++ b/classnlohmann_1_1basic__json-members.html @@ -244,7 +244,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json.html b/classnlohmann_1_1basic__json.html index de3cab988..dc98ed514 100644 --- a/classnlohmann_1_1basic__json.html +++ b/classnlohmann_1_1basic__json.html @@ -688,14 +688,14 @@ class nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, N -
See also
RFC 7159 http://rfc7159.net/rfc7159
+
See also
RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format
Since
version 1.0.0
-

Definition at line 194 of file json.hpp.

+

Definition at line 168 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1const__iterator-members.html b/classnlohmann_1_1basic__json_1_1const__iterator-members.html index 389503336..7c49ffa7e 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator-members.html @@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1const__iterator.html b/classnlohmann_1_1basic__json_1_1const__iterator.html index b24aa9486..a606255b4 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator.html @@ -215,11 +215,11 @@ class nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, N
Since
version 1.0.0
-

Definition at line 6127 of file json.hpp.

+

Definition at line 6101 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a0d5820d1dda9dea3bbeb029cacf68522.html b/classnlohmann_1_1basic__json_1_1const__iterator_a0d5820d1dda9dea3bbeb029cacf68522.html index 8bb3fcf09..083f21b7d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a0d5820d1dda9dea3bbeb029cacf68522.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a0d5820d1dda9dea3bbeb029cacf68522.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6520 of file json.hpp.

+

Definition at line 6494 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a18c35a6735d3da96b4fc026421c05dd8.html b/classnlohmann_1_1basic__json_1_1const__iterator_a18c35a6735d3da96b4fc026421c05dd8.html index 5f7f6e3b8..3a1bf1516 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a18c35a6735d3da96b4fc026421c05dd8.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a18c35a6735d3da96b4fc026421c05dd8.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6202 of file json.hpp.

+

Definition at line 6176 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html b/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html index e3c711287..5a6d570b8 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6138 of file json.hpp.

+

Definition at line 6112 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html b/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html index a0ab33e74..2a7550c3d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6136 of file json.hpp.

+

Definition at line 6110 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a5521515067b6597cb0b55a9c547a7a2b.html b/classnlohmann_1_1basic__json_1_1const__iterator_a5521515067b6597cb0b55a9c547a7a2b.html index 7b42a39a1..343b8d175 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5521515067b6597cb0b55a9c547a7a2b.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5521515067b6597cb0b55a9c547a7a2b.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6207 of file json.hpp.

+

Definition at line 6181 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a5d4320e24fcb7df041ff2c95d976dba0.html b/classnlohmann_1_1basic__json_1_1const__iterator_a5d4320e24fcb7df041ff2c95d976dba0.html index 14e5c54a7..5c9e5d2f1 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5d4320e24fcb7df041ff2c95d976dba0.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5d4320e24fcb7df041ff2c95d976dba0.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6630 of file json.hpp.

+

Definition at line 6604 of file json.hpp.

@@ -152,7 +152,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a5e4d98a8f95e2eccde8cd48c19efa196.html b/classnlohmann_1_1basic__json_1_1const__iterator_a5e4d98a8f95e2eccde8cd48c19efa196.html index c4c763abd..8fe773ce1 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5e4d98a8f95e2eccde8cd48c19efa196.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5e4d98a8f95e2eccde8cd48c19efa196.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6570 of file json.hpp.

+

Definition at line 6544 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a65f491b515e5967e9c0b40289e3c0ff3.html b/classnlohmann_1_1basic__json_1_1const__iterator_a65f491b515e5967e9c0b40289e3c0ff3.html index fbb8d8507..53e04958d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a65f491b515e5967e9c0b40289e3c0ff3.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a65f491b515e5967e9c0b40289e3c0ff3.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6472 of file json.hpp.

+

Definition at line 6446 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a6b682f09787eff62f03493d45aa05902.html b/classnlohmann_1_1basic__json_1_1const__iterator_a6b682f09787eff62f03493d45aa05902.html index 1f8a25c69..fc8e62509 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a6b682f09787eff62f03493d45aa05902.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a6b682f09787eff62f03493d45aa05902.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6502 of file json.hpp.

+

Definition at line 6476 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a6cab1c2ed7e2a014980e2a5717f43a64.html b/classnlohmann_1_1basic__json_1_1const__iterator_a6cab1c2ed7e2a014980e2a5717f43a64.html index f81b5ec2f..3f4231f8d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a6cab1c2ed7e2a014980e2a5717f43a64.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a6cab1c2ed7e2a014980e2a5717f43a64.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6399 of file json.hpp.

+

Definition at line 6373 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a72761de693f95edc195956197f4e5569.html b/classnlohmann_1_1basic__json_1_1const__iterator_a72761de693f95edc195956197f4e5569.html index e87c268c4..4df6beac8 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a72761de693f95edc195956197f4e5569.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a72761de693f95edc195956197f4e5569.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6148 of file json.hpp.

+

Definition at line 6122 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a7a80257f2303210b0a5d056fc0b30b40.html b/classnlohmann_1_1basic__json_1_1const__iterator_a7a80257f2303210b0a5d056fc0b30b40.html index 5d5f5965f..bdd591bf3 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a7a80257f2303210b0a5d056fc0b30b40.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a7a80257f2303210b0a5d056fc0b30b40.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6554 of file json.hpp.

+

Definition at line 6528 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a7bd530bfbbc58ac77308c087120c21fa.html b/classnlohmann_1_1basic__json_1_1const__iterator_a7bd530bfbbc58ac77308c087120c21fa.html index fa982401a..c3b18be54 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a7bd530bfbbc58ac77308c087120c21fa.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a7bd530bfbbc58ac77308c087120c21fa.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6594 of file json.hpp.

+

Definition at line 6568 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a821560d64f50525162097f19b1392e7f.html b/classnlohmann_1_1basic__json_1_1const__iterator_a821560d64f50525162097f19b1392e7f.html index 52b9694c0..cdb6c3936 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a821560d64f50525162097f19b1392e7f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a821560d64f50525162097f19b1392e7f.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6142 of file json.hpp.

+

Definition at line 6116 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a8be837e4d902887676dd837abe9098d3.html b/classnlohmann_1_1basic__json_1_1const__iterator_a8be837e4d902887676dd837abe9098d3.html index b5c320704..238eeb441 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8be837e4d902887676dd837abe9098d3.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8be837e4d902887676dd837abe9098d3.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6327 of file json.hpp.

+

Definition at line 6301 of file json.hpp.

@@ -152,7 +152,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a8dbaec5bf8ccba3225520356629061cb.html b/classnlohmann_1_1basic__json_1_1const__iterator_a8dbaec5bf8ccba3225520356629061cb.html index 77f353dc5..1f2b4076d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8dbaec5bf8ccba3225520356629061cb.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8dbaec5bf8ccba3225520356629061cb.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6362 of file json.hpp.

+

Definition at line 6336 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a8fbb15efd97599209a7def77af8e748e.html b/classnlohmann_1_1basic__json_1_1const__iterator_a8fbb15efd97599209a7def77af8e748e.html index 951de9b70..57436bf1a 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8fbb15efd97599209a7def77af8e748e.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8fbb15efd97599209a7def77af8e748e.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6370 of file json.hpp.

+

Definition at line 6344 of file json.hpp.

@@ -152,7 +152,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html b/classnlohmann_1_1basic__json_1_1const__iterator_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html index 7b861034f..4a34bd0f8 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6466 of file json.hpp.

+

Definition at line 6440 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a9ea0497199b1e96ce9cadd1f202ec343.html b/classnlohmann_1_1basic__json_1_1const__iterator_a9ea0497199b1e96ce9cadd1f202ec343.html index 6faeb9eae..4485301e2 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a9ea0497199b1e96ce9cadd1f202ec343.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a9ea0497199b1e96ce9cadd1f202ec343.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6134 of file json.hpp.

+

Definition at line 6108 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_ab3029a1a83cf46dc28ad443bbad0c74d.html b/classnlohmann_1_1basic__json_1_1const__iterator_ab3029a1a83cf46dc28ad443bbad0c74d.html index e70c8c597..f1666897d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab3029a1a83cf46dc28ad443bbad0c74d.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab3029a1a83cf46dc28ad443bbad0c74d.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6287 of file json.hpp.

+

Definition at line 6261 of file json.hpp.

@@ -152,7 +152,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_ab4c0b9baaec9ebc4837158e272f6c803.html b/classnlohmann_1_1basic__json_1_1const__iterator_ab4c0b9baaec9ebc4837158e272f6c803.html index 8f9dbb17b..2e6c6b74c 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab4c0b9baaec9ebc4837158e272f6c803.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab4c0b9baaec9ebc4837158e272f6c803.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6436 of file json.hpp.

+

Definition at line 6410 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html b/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html index 292a78275..280ae2737 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6562 of file json.hpp.

+

Definition at line 6536 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_ac6f4562e16e99b60820d100880b4c3c8.html b/classnlohmann_1_1basic__json_1_1const__iterator_ac6f4562e16e99b60820d100880b4c3c8.html index 34b236861..edc52d16c 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac6f4562e16e99b60820d100880b4c3c8.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac6f4562e16e99b60820d100880b4c3c8.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6175 of file json.hpp.

+

Definition at line 6149 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_ac6fdaff67857f82a623e5cc253917639.html b/classnlohmann_1_1basic__json_1_1const__iterator_ac6fdaff67857f82a623e5cc253917639.html index 9ae01f9bf..b180c2eed 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac6fdaff67857f82a623e5cc253917639.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac6fdaff67857f82a623e5cc253917639.html @@ -150,7 +150,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_ac75e80d30b6169ee2a29ec93fb4d2acd.html b/classnlohmann_1_1basic__json_1_1const__iterator_ac75e80d30b6169ee2a29ec93fb4d2acd.html index 25cfe88ae..b57de9514 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac75e80d30b6169ee2a29ec93fb4d2acd.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac75e80d30b6169ee2a29ec93fb4d2acd.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6645 of file json.hpp.

+

Definition at line 6619 of file json.hpp.

@@ -152,7 +152,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_acb6cd0ff760933afeb7f93e5207f3646.html b/classnlohmann_1_1basic__json_1_1const__iterator_acb6cd0ff760933afeb7f93e5207f3646.html index 2cdfa3008..ea4d7bad1 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_acb6cd0ff760933afeb7f93e5207f3646.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_acb6cd0ff760933afeb7f93e5207f3646.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6508 of file json.hpp.

+

Definition at line 6482 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html b/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html index d8b37c1fd..7b2a7a911 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html @@ -139,7 +139,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6130 of file json.hpp.

+

Definition at line 6104 of file json.hpp.

@@ -149,7 +149,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_adeb2ff3fdf3cc301b72db109934c9199.html b/classnlohmann_1_1basic__json_1_1const__iterator_adeb2ff3fdf3cc301b72db109934c9199.html index 2dc41f51b..ef417bab4 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_adeb2ff3fdf3cc301b72db109934c9199.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_adeb2ff3fdf3cc301b72db109934c9199.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6407 of file json.hpp.

+

Definition at line 6381 of file json.hpp.

@@ -152,7 +152,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_aefac8f3e390ac917f021761f4a8f8e71.html b/classnlohmann_1_1basic__json_1_1const__iterator_aefac8f3e390ac917f021761f4a8f8e71.html index fe2478a5b..13c9a0e4d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_aefac8f3e390ac917f021761f4a8f8e71.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_aefac8f3e390ac917f021761f4a8f8e71.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6548 of file json.hpp.

+

Definition at line 6522 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_aefd248cac6493eed1e6ff53ba6a63eb2.html b/classnlohmann_1_1basic__json_1_1const__iterator_aefd248cac6493eed1e6ff53ba6a63eb2.html index 33825cdfb..9450be5cb 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_aefd248cac6493eed1e6ff53ba6a63eb2.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_aefd248cac6493eed1e6ff53ba6a63eb2.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6140 of file json.hpp.

+

Definition at line 6114 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_af6941c3711dabb2e64960dd57e00d201.html b/classnlohmann_1_1basic__json_1_1const__iterator_af6941c3711dabb2e64960dd57e00d201.html index 0a45b10b9..9881f985f 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_af6941c3711dabb2e64960dd57e00d201.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_af6941c3711dabb2e64960dd57e00d201.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6514 of file json.hpp.

+

Definition at line 6488 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator-members.html b/classnlohmann_1_1basic__json_1_1iterator-members.html index adabf9c93..992cc0368 100644 --- a/classnlohmann_1_1basic__json_1_1iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1iterator-members.html @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1iterator.html b/classnlohmann_1_1basic__json_1_1iterator.html index d415d821f..3fbc483c1 100644 --- a/classnlohmann_1_1basic__json_1_1iterator.html +++ b/classnlohmann_1_1basic__json_1_1iterator.html @@ -266,11 +266,11 @@ class nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, N
Since
version 1.0.0
-

Definition at line 6669 of file json.hpp.

+

Definition at line 6643 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1iterator_a050b7fa21051ea57e5b0cc03668b5d4a.html b/classnlohmann_1_1basic__json_1_1iterator_a050b7fa21051ea57e5b0cc03668b5d4a.html index af8177c5e..b347eb747 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a050b7fa21051ea57e5b0cc03668b5d4a.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a050b7fa21051ea57e5b0cc03668b5d4a.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6722 of file json.hpp.

+

Definition at line 6696 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a085fe0d8cf459b5b1ae7b518b933ae7d.html b/classnlohmann_1_1basic__json_1_1iterator_a085fe0d8cf459b5b1ae7b518b933ae7d.html index 564fac520..e01e7d58e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a085fe0d8cf459b5b1ae7b518b933ae7d.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a085fe0d8cf459b5b1ae7b518b933ae7d.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6680 of file json.hpp.

+

Definition at line 6654 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a1de0975e812c83e74d118b3e1063f335.html b/classnlohmann_1_1basic__json_1_1iterator_a1de0975e812c83e74d118b3e1063f335.html index 4ec89ed6e..77866ddcf 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a1de0975e812c83e74d118b3e1063f335.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a1de0975e812c83e74d118b3e1063f335.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6685 of file json.hpp.

+

Definition at line 6659 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a2943e49b3d88e6ee5793c5923ab2ede9.html b/classnlohmann_1_1basic__json_1_1iterator_a2943e49b3d88e6ee5793c5923ab2ede9.html index 0fd4acb49..8811512da 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a2943e49b3d88e6ee5793c5923ab2ede9.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a2943e49b3d88e6ee5793c5923ab2ede9.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6714 of file json.hpp.

+

Definition at line 6688 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a3aae1df93a78b201d98e178c1c7d02a7.html b/classnlohmann_1_1basic__json_1_1iterator_a3aae1df93a78b201d98e178c1c7d02a7.html index f892744e7..9a23b279f 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a3aae1df93a78b201d98e178c1c7d02a7.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a3aae1df93a78b201d98e178c1c7d02a7.html @@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6673 of file json.hpp.

+

Definition at line 6647 of file json.hpp.

@@ -130,7 +130,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a3db892729714c4e7eaf60c00ee96e2e9.html b/classnlohmann_1_1basic__json_1_1iterator_a3db892729714c4e7eaf60c00ee96e2e9.html index 3f63449ff..4d08b811b 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a3db892729714c4e7eaf60c00ee96e2e9.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a3db892729714c4e7eaf60c00ee96e2e9.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6690 of file json.hpp.

+

Definition at line 6664 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html b/classnlohmann_1_1basic__json_1_1iterator_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html index 03332121a..c64c47708 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html @@ -139,7 +139,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a56952f8d5702541f0d88e6a764d2ae36.html b/classnlohmann_1_1basic__json_1_1iterator_a56952f8d5702541f0d88e6a764d2ae36.html index 210803eaa..44ae3143c 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a56952f8d5702541f0d88e6a764d2ae36.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a56952f8d5702541f0d88e6a764d2ae36.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6758 of file json.hpp.

+

Definition at line 6732 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a790f550ff168095c83c2e459c575916c.html b/classnlohmann_1_1basic__json_1_1iterator_a790f550ff168095c83c2e459c575916c.html index e933b7b38..7a9a33501 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a790f550ff168095c83c2e459c575916c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a790f550ff168095c83c2e459c575916c.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6766 of file json.hpp.

+

Definition at line 6740 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a7e01532727c10f87926dac4eb8e170f4.html b/classnlohmann_1_1basic__json_1_1iterator_a7e01532727c10f87926dac4eb8e170f4.html index b7b98620b..86507ac84 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a7e01532727c10f87926dac4eb8e170f4.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a7e01532727c10f87926dac4eb8e170f4.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6779 of file json.hpp.

+

Definition at line 6753 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html b/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html index f3eba9111..255578767 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6785 of file json.hpp.

+

Definition at line 6759 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a97aff5d71246774267a81066460dd1cf.html b/classnlohmann_1_1basic__json_1_1iterator_a97aff5d71246774267a81066460dd1cf.html index d3ebaa6f1..cac121e91 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a97aff5d71246774267a81066460dd1cf.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a97aff5d71246774267a81066460dd1cf.html @@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6674 of file json.hpp.

+

Definition at line 6648 of file json.hpp.

@@ -130,7 +130,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a9f3940ac5fb2c6ff8045ed59b8a0866f.html b/classnlohmann_1_1basic__json_1_1iterator_a9f3940ac5fb2c6ff8045ed59b8a0866f.html index 2f1c6398e..ea8ebf9f0 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a9f3940ac5fb2c6ff8045ed59b8a0866f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a9f3940ac5fb2c6ff8045ed59b8a0866f.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6773 of file json.hpp.

+

Definition at line 6747 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_ab07728b4da636eda0a24e0a51b8b46d7.html b/classnlohmann_1_1basic__json_1_1iterator_ab07728b4da636eda0a24e0a51b8b46d7.html index 11e873311..69af24600 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab07728b4da636eda0a24e0a51b8b46d7.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab07728b4da636eda0a24e0a51b8b46d7.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6702 of file json.hpp.

+

Definition at line 6676 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html b/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html index ed15b0770..27649ada4 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6737 of file json.hpp.

+

Definition at line 6711 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_ab4f238aa5fcf452b1884b748b0395b1f.html b/classnlohmann_1_1basic__json_1_1iterator_ab4f238aa5fcf452b1884b748b0395b1f.html index 8ac83d71e..8e1c69fbc 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab4f238aa5fcf452b1884b748b0395b1f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab4f238aa5fcf452b1884b748b0395b1f.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6729 of file json.hpp.

+

Definition at line 6703 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_ac48754e4dc48d65d95294bd170dcd857.html b/classnlohmann_1_1basic__json_1_1iterator_ac48754e4dc48d65d95294bd170dcd857.html index 5699d2c11..5555d3124 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ac48754e4dc48d65d95294bd170dcd857.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ac48754e4dc48d65d95294bd170dcd857.html @@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6672 of file json.hpp.

+

Definition at line 6646 of file json.hpp.

@@ -130,7 +130,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html b/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html index ffbdf6c27..7998c8dbf 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6744 of file json.hpp.

+

Definition at line 6718 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_ae58cd597336ad125d9615cff87fcd87e.html b/classnlohmann_1_1basic__json_1_1iterator_ae58cd597336ad125d9615cff87fcd87e.html index e91fddc02..6fe666899 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ae58cd597336ad125d9615cff87fcd87e.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ae58cd597336ad125d9615cff87fcd87e.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6708 of file json.hpp.

+

Definition at line 6682 of file json.hpp.

@@ -141,7 +141,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html b/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html index 99429cc28..8338342b9 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6751 of file json.hpp.

+

Definition at line 6725 of file json.hpp.

@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html index d751399db..43be3ca45 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html index 7f607f56f..13570ae6f 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html @@ -170,11 +170,11 @@ class nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, N
Since
version 1.0.0
-

Definition at line 238 of file json.hpp.

+

Definition at line 212 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a115fae3dd8ae02669fedae0545ce1cbc.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a115fae3dd8ae02669fedae0545ce1cbc.html index 761a5aa5d..c6e220959 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a115fae3dd8ae02669fedae0545ce1cbc.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a115fae3dd8ae02669fedae0545ce1cbc.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6877 of file json.hpp.

+

Definition at line 6851 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a4aede52d6ee253a510897518b59e09c0.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a4aede52d6ee253a510897518b59e09c0.html index aa43ea7a2..da1b0471f 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a4aede52d6ee253a510897518b59e09c0.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a4aede52d6ee253a510897518b59e09c0.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6834 of file json.hpp.

+

Definition at line 6808 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a53407187cceeb3ee5390318713dad827.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a53407187cceeb3ee5390318713dad827.html index fd8224662..bdba6604b 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a53407187cceeb3ee5390318713dad827.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a53407187cceeb3ee5390318713dad827.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6823 of file json.hpp.

+

Definition at line 6797 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a545a8204cfd6836eb85abc3113a0bb28.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a545a8204cfd6836eb85abc3113a0bb28.html index b7b360ae2..aa62b2a11 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a545a8204cfd6836eb85abc3113a0bb28.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a545a8204cfd6836eb85abc3113a0bb28.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6828 of file json.hpp.

+

Definition at line 6802 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a563a7bd281e9919798d18396107fb05c.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a563a7bd281e9919798d18396107fb05c.html index 20abb80ac..e856cbf19 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a563a7bd281e9919798d18396107fb05c.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a563a7bd281e9919798d18396107fb05c.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6847 of file json.hpp.

+

Definition at line 6821 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a693439bffe56a9a8cf53bc4a06b911ff.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a693439bffe56a9a8cf53bc4a06b911ff.html index 1579ce0df..c8fa4ef4e 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a693439bffe56a9a8cf53bc4a06b911ff.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a693439bffe56a9a8cf53bc4a06b911ff.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6841 of file json.hpp.

+

Definition at line 6815 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7265535f39299824f9712a2ca15013c3.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7265535f39299824f9712a2ca15013c3.html index 6d86473a6..e5d42c3b8 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7265535f39299824f9712a2ca15013c3.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7265535f39299824f9712a2ca15013c3.html @@ -117,7 +117,7 @@ template<typename Base >
-

Definition at line 6815 of file json.hpp.

+

Definition at line 6789 of file json.hpp.

@@ -127,7 +127,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7c5e0d3bd0e1a2ba9226b7eb539a53d6.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7c5e0d3bd0e1a2ba9226b7eb539a53d6.html index 1bb3ab519..f6fcfe741 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7c5e0d3bd0e1a2ba9226b7eb539a53d6.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7c5e0d3bd0e1a2ba9226b7eb539a53d6.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6818 of file json.hpp.

+

Definition at line 6792 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a99ee137dab7e5c948457f6a5321b54b1.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a99ee137dab7e5c948457f6a5321b54b1.html index 1f2beed50..eb518fb70 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a99ee137dab7e5c948457f6a5321b54b1.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a99ee137dab7e5c948457f6a5321b54b1.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6861 of file json.hpp.

+

Definition at line 6835 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9accc9dd9f9033f50c0ab6bcf337ffe0.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9accc9dd9f9033f50c0ab6bcf337ffe0.html index 4104e401e..dee373e44 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9accc9dd9f9033f50c0ab6bcf337ffe0.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9accc9dd9f9033f50c0ab6bcf337ffe0.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6854 of file json.hpp.

+

Definition at line 6828 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9ebc4c99e6fc90c965af0f39ad2ca70e.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9ebc4c99e6fc90c965af0f39ad2ca70e.html index 1a936a511..ceb1b4bd8 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9ebc4c99e6fc90c965af0f39ad2ca70e.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9ebc4c99e6fc90c965af0f39ad2ca70e.html @@ -117,7 +117,7 @@ template<typename Base >
-

Definition at line 6813 of file json.hpp.

+

Definition at line 6787 of file json.hpp.

@@ -127,7 +127,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac2634bee082633671125e909dffad40a.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac2634bee082633671125e909dffad40a.html index beb65d100..5d4d6028b 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac2634bee082633671125e909dffad40a.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac2634bee082633671125e909dffad40a.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6869 of file json.hpp.

+

Definition at line 6843 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aca5116682e206dac48f8a56716a3280b.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aca5116682e206dac48f8a56716a3280b.html index 04330d5a7..c74a22a4e 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aca5116682e206dac48f8a56716a3280b.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aca5116682e206dac48f8a56716a3280b.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6896 of file json.hpp.

+

Definition at line 6870 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_acecae6d237fcf14c909fb42b9d2e2955.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_acecae6d237fcf14c909fb42b9d2e2955.html index e28f73a55..e38eaddfb 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_acecae6d237fcf14c909fb42b9d2e2955.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_acecae6d237fcf14c909fb42b9d2e2955.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6889 of file json.hpp.

+

Definition at line 6863 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html index ce4d8a98f..3e69363b2 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6883 of file json.hpp.

+

Definition at line 6857 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html b/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html index a31fbc0f8..f42cae811 100644 --- a/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html +++ b/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html @@ -281,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
  • Has the semantics of std::distance(begin(), end()).
  • -
    Example
    The following code calls size on the different value types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call size()
    19  std::cout << j_null.size() << '\n';
    20  std::cout << j_boolean.size() << '\n';
    21  std::cout << j_number_integer.size() << '\n';
    22  std::cout << j_number_float.size() << '\n';
    23  std::cout << j_object.size() << '\n';
    24  std::cout << j_object_empty.size() << '\n';
    25  std::cout << j_array.size() << '\n';
    26  std::cout << j_array_empty.size() << '\n';
    27  std::cout << j_string.size() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code calls size on the different value types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call size()
    19  std::cout << j_null.size() << '\n';
    20  std::cout << j_boolean.size() << '\n';
    21  std::cout << j_number_integer.size() << '\n';
    22  std::cout << j_number_float.size() << '\n';
    23  std::cout << j_object.size() << '\n';
    24  std::cout << j_object_empty.size() << '\n';
    25  std::cout << j_array.size() << '\n';
    26  std::cout << j_array_empty.size() << '\n';
    27  std::cout << j_string.size() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    0
    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/size.cpp -o size 
    Since
    version 1.0.0
    -

    Definition at line 4330 of file json.hpp.

    +

    Definition at line 4304 of file json.hpp.

    @@ -306,7 +306,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html b/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html index 534b93b2b..a88ff03ee 100644 --- a/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html +++ b/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 235 of file json.hpp.

    +

    Definition at line 209 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a08ad7169ceb437efff7b2d4a8c0dafe2.html b/classnlohmann_1_1basic__json_a08ad7169ceb437efff7b2d4a8c0dafe2.html index 80dc15a76..59efb1124 100644 --- a/classnlohmann_1_1basic__json_a08ad7169ceb437efff7b2d4a8c0dafe2.html +++ b/classnlohmann_1_1basic__json_a08ad7169ceb437efff7b2d4a8c0dafe2.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is a boolean.

    Returns
    true if type is boolean, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_boolean for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_boolean()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_boolean() << '\n';
    20  std::cout << j_boolean.is_boolean() << '\n';
    21  std::cout << j_number_integer.is_boolean() << '\n';
    22  std::cout << j_number_unsigned_integer.is_boolean() << '\n';
    23  std::cout << j_number_float.is_boolean() << '\n';
    24  std::cout << j_object.is_boolean() << '\n';
    25  std::cout << j_array.is_boolean() << '\n';
    26  std::cout << j_string.is_boolean() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_boolean for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_boolean()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_boolean() << '\n';
    20  std::cout << j_boolean.is_boolean() << '\n';
    21  std::cout << j_number_integer.is_boolean() << '\n';
    22  std::cout << j_number_unsigned_integer.is_boolean() << '\n';
    23  std::cout << j_number_float.is_boolean() << '\n';
    24  std::cout << j_object.is_boolean() << '\n';
    25  std::cout << j_array.is_boolean() << '\n';
    26  std::cout << j_string.is_boolean() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     true
     false
    @@ -272,7 +272,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_boolean.cpp -o is_boolean 
    Since
    version 1.0.0
    -

    Definition at line 2167 of file json.hpp.

    +

    Definition at line 2141 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html b/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html index d9082290d..e7d7b6f43 100644 --- a/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html +++ b/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for back.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for back.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/back.cpp -o back 
    Since
    version 1.0.0
    -

    Definition at line 3593 of file json.hpp.

    +

    Definition at line 3567 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html b/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html index 9e26123d1..a357ee154 100644 --- a/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html +++ b/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html @@ -296,7 +296,7 @@ value() with null"
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be queried with a default value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object with different entry types
    8  json j =
    9  {
    10  {"integer", 1},
    11  {"floating", 42.23},
    12  {"string", "hello world"},
    13  {"boolean", true},
    14  {"object", {{"key1", 1}, {"key2", 2}}},
    15  {"array", {1, 2, 3}}
    16  };
    17 
    18  // access existing values
    19  int v_integer = j.value("integer", 0);
    20  double v_floating = j.value("floating", 47.11);
    21 
    22  // access nonexisting values and rely on default value
    23  std::string v_string = j.value("nonexisting", "oops");
    24  bool v_boolean = j.value("nonexisting", false);
    25 
    26  // output values
    27  std::cout << std::boolalpha << v_integer << " " << v_floating
    28  << " " << v_string << " " << v_boolean << "\n";
    29 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be queried with a default value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object with different entry types
    8  json j =
    9  {
    10  {"integer", 1},
    11  {"floating", 42.23},
    12  {"string", "hello world"},
    13  {"boolean", true},
    14  {"object", {{"key1", 1}, {"key2", 2}}},
    15  {"array", {1, 2, 3}}
    16  };
    17 
    18  // access existing values
    19  int v_integer = j.value("integer", 0);
    20  double v_floating = j.value("floating", 47.11);
    21 
    22  // access nonexisting values and rely on default value
    23  std::string v_string = j.value("nonexisting", "oops");
    24  bool v_boolean = j.value("nonexisting", false);
    25 
    26  // output values
    27  std::cout << std::boolalpha << v_integer << " " << v_floating
    28  << " " << v_string << " " << v_boolean << "\n";
    29 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1 42.23 oops false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__value.cpp -o basic_json__value 
    See also
    at(const typename object_t::key_type&) for access by reference with range checking
    @@ -304,7 +304,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3498 of file json.hpp.

    +

    Definition at line 3472 of file json.hpp.

    @@ -314,7 +314,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html b/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html index 7e413460d..174f36d7a 100644 --- a/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html +++ b/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html @@ -268,13 +268,13 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).rend().
  • -
    Example
    The following code shows an example for crend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-end
    11  json::const_reverse_iterator it = array.crend();
    12 
    13  // increment the iterator to point to the first element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:247
    +
    Example
    The following code shows an example for crend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-end
    11  json::const_reverse_iterator it = array.crend();
    12 
    13  // increment the iterator to point to the first element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:221
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crend.cpp -o crend 
    Since
    version 1.0.0
    -

    Definition at line 4153 of file json.hpp.

    +

    Definition at line 4127 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html b/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html index b4729ebf3..977dc4140 100644 --- a/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html +++ b/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    Note
    The order name/value pairs are added to the object is not preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as std::map with std::less is used by default. Please note this behavior conforms to RFC 7159, because any order implements the specified "unordered" nature of JSON objects.
    -

    Definition at line 354 of file json.hpp.

    +

    Definition at line 328 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html b/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html index 0f3849871..fcdc49c64 100644 --- a/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html +++ b/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html @@ -277,14 +277,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in cnt.
    -
    Example
    The following code shows examples for the basic_json(size_type, const basic_json&) constructor.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array by creating copies of a JSON value
    8  json value = "Hello";
    9  json array_0 = json(0, value);
    10  json array_1 = json(1, value);
    11  json array_5 = json(5, value);
    12 
    13  // serialize the JSON arrays
    14  std::cout << array_0 << '\n';
    15  std::cout << array_1 << '\n';
    16  std::cout << array_5 << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows examples for the basic_json(size_type, const basic_json&) constructor.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array by creating copies of a JSON value
    8  json value = "Hello";
    9  json array_0 = json(0, value);
    10  json array_1 = json(1, value);
    11  json array_5 = json(5, value);
    12 
    13  // serialize the JSON arrays
    14  std::cout << array_0 << '\n';
    15  std::cout << array_1 << '\n';
    16  std::cout << array_5 << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    []
     ["Hello"]
     ["Hello","Hello","Hello","Hello","Hello"]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__size_type_basic_json.cpp -o basic_json__size_type_basic_json 
    Since
    version 1.0.0
    -

    Definition at line 1700 of file json.hpp.

    +

    Definition at line 1674 of file json.hpp.

    @@ -294,7 +294,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html index d34cc7b9d..e1ae52ae3 100644 --- a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html +++ b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html @@ -282,7 +282,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether the values lhs and rhs are equal
    Complexity
    Linear.
    -
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.000000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.000000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 == array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 == object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 == number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 == string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3] == [1,2,4] false
     {"A":"a","B":"b"} == {"A":"a","B":"b"} true
     17 == 17.0 true
    @@ -290,7 +290,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__equal.cpp -o operator__equal 
    Since
    version 1.0.0
    -

    Definition at line 5050 of file json.hpp.

    +

    Definition at line 5024 of file json.hpp.

    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html b/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html index 45fbf2bb0..bdb20d270 100644 --- a/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html +++ b/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html @@ -278,11 +278,11 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    result of the deserialization
    Complexity
    Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser callback function cb has a super-linear complexity.
    Note
    A UTF-8 byte order mark is silently ignored.
    -
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // a JSON text
    8  auto text = R"(
    9  {
    10  "Image": {
    11  "Width": 800,
    12  "Height": 600,
    13  "Title": "View from 15th Floor",
    14  "Thumbnail": {
    15  "Url": "http://www.example.com/image/481989943",
    16  "Height": 125,
    17  "Width": 100
    18  },
    19  "Animated" : false,
    20  "IDs": [116, 943, 234, 38793]
    21  }
    22  }
    23  )";
    24 
    25  // fill a stream with JSON text
    26  std::stringstream ss;
    27  ss << text;
    28 
    29  // parse and serialize JSON
    30  json j_complete = json::parse(ss);
    31  std::cout << std::setw(4) << j_complete << "\n\n";
    32 
    33 
    34  // define parser callback
    35  json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    36  {
    37  // skip object elements with key "Thumbnail"
    38  if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
    39  {
    40  return false;
    41  }
    42  else
    43  {
    44  return true;
    45  }
    46  };
    47 
    48  // fill a stream with JSON text
    49  ss.clear();
    50  ss << text;
    51 
    52  // parse (with callback) and serialize JSON
    53  json j_filtered = json::parse(ss, cb);
    54  std::cout << std::setw(4) << j_filtered << '\n';
    55 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5479
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:922
    +
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // a JSON text
    8  auto text = R"(
    9  {
    10  "Image": {
    11  "Width": 800,
    12  "Height": 600,
    13  "Title": "View from 15th Floor",
    14  "Thumbnail": {
    15  "Url": "http://www.example.com/image/481989943",
    16  "Height": 125,
    17  "Width": 100
    18  },
    19  "Animated" : false,
    20  "IDs": [116, 943, 234, 38793]
    21  }
    22  }
    23  )";
    24 
    25  // fill a stream with JSON text
    26  std::stringstream ss;
    27  ss << text;
    28 
    29  // parse and serialize JSON
    30  json j_complete = json::parse(ss);
    31  std::cout << std::setw(4) << j_complete << "\n\n";
    32 
    33 
    34  // define parser callback
    35  json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    36  {
    37  // skip object elements with key "Thumbnail"
    38  if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
    39  {
    40  return false;
    41  }
    42  else
    43  {
    44  return true;
    45  }
    46  };
    47 
    48  // fill a stream with JSON text
    49  ss.clear();
    50  ss << text;
    51 
    52  // parse (with callback) and serialize JSON
    53  json j_filtered = json::parse(ss, cb);
    54  std::cout << std::setw(4) << j_filtered << '\n';
    55 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5453
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:896
    the parser read a key of a value in an object
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:857
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:831
    Output (play with this example online):
    {
         "Image": {
             "Animated": false,
    @@ -321,7 +321,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    parse(const string_t&, parser_callback_t) for a version that reads from a string
    Since
    version 1.0.0
    -

    Definition at line 5508 of file json.hpp.

    +

    Definition at line 5482 of file json.hpp.

    @@ -331,7 +331,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html b/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html index 5a99167e6..106904f83 100644 --- a/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html +++ b/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html @@ -276,7 +276,7 @@ template<typename T , std::size_t n>
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    2
     
     {
    @@ -302,7 +302,7 @@ template<typename T , std::size_t n> 
    value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3314 of file json.hpp.

    +

    Definition at line 3288 of file json.hpp.

    @@ -312,7 +312,7 @@ template<typename T , std::size_t n> diff --git a/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html b/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html index 0a61e7129..07b3d01ef 100644 --- a/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html +++ b/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 227 of file json.hpp.

    +

    Definition at line 201 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a1846cc6db1f38f5918c8200d9ce31896.html b/classnlohmann_1_1basic__json_a1846cc6db1f38f5918c8200d9ce31896.html index 891981295..38645c8ed 100644 --- a/classnlohmann_1_1basic__json_a1846cc6db1f38f5918c8200d9ce31896.html +++ b/classnlohmann_1_1basic__json_a1846cc6db1f38f5918c8200d9ce31896.html @@ -268,13 +268,13 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).rend().
  • -
    Example
    The following code shows an example for crend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-end
    11  json::const_reverse_iterator it = array.crend();
    12 
    13  // increment the iterator to point to the first element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:247
    +
    Example
    The following code shows an example for crend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-end
    11  json::const_reverse_iterator it = array.crend();
    12 
    13  // increment the iterator to point to the first element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:221
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crend.cpp -o crend 
    Since
    version 1.0.0
    -

    Definition at line 4199 of file json.hpp.

    +

    Definition at line 4173 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html b/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html index 4ef2097f3..a40e63fe8 100644 --- a/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html +++ b/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html @@ -275,8 +275,8 @@ template<typename T , typename std::enable_if<
    Note
    This constructor would have the same signature as basic_json(const int value), so we need to switch this one off in case number_integer_t is the same as int. This is done via the helper type T.
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of a JSON integer number value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number from number_integer_t
    8  json::number_integer_t value = 42;
    9 
    10  json j(value);
    11 
    12  // serialize the JSON numbers
    13  std::cout << j << '\n';
    14 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    +
    Example
    The example below shows the construction of a JSON integer number value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number from number_integer_t
    8  json::number_integer_t value = 42;
    9 
    10  json j(value);
    11 
    12  // serialize the JSON numbers
    13  std::cout << j << '\n';
    14 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    Output (play with this example online):
    42
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__number_integer_t.cpp -o basic_json__number_integer_t 
    See also
    basic_json(const int) – create a number value (integer)
    @@ -284,7 +284,7 @@ template<typename T , typename std::enable_if< basic_json(const CompatibleNumberIntegerType) – create a number value (integer) from a compatible number type
    Since
    version 1.0.0
    -

    Definition at line 1271 of file json.hpp.

    +

    Definition at line 1245 of file json.hpp.

    @@ -294,7 +294,7 @@ template<typename T , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html b/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html index 2ab68c4d1..7ffde1da0 100644 --- a/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html +++ b/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html @@ -258,7 +258,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 255 of file json.hpp.

    +

    Definition at line 229 of file json.hpp.

    @@ -268,7 +268,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html b/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html index 69611fc87..52cd4cc87 100644 --- a/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html +++ b/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Amortized constant.
    -
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -280,7 +280,7 @@ null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back.cpp -o push_back 
    Since
    version 1.0.0
    -

    Definition at line 4553 of file json.hpp.

    +

    Definition at line 4527 of file json.hpp.

    @@ -290,7 +290,7 @@ null diff --git a/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html b/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html index 9eb816565..7a1da2e40 100644 --- a/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html +++ b/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html @@ -268,12 +268,12 @@ Illustration from cppreference.com
  • The complexity is constant.
  • -
    Example
    The following code shows an example for end.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to one past the last element
    11  json::iterator it = array.end();
    12 
    13  // decrement the iterator to point to the last element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for end.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to one past the last element
    11  json::iterator it = array.end();
    12 
    13  // decrement the iterator to point to the last element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/end.cpp -o end 
    Since
    version 1.0.0
    -

    Definition at line 4056 of file json.hpp.

    +

    Definition at line 4030 of file json.hpp.

    @@ -283,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html b/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html index b22bf01da..1cc13e615 100644 --- a/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html +++ b/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html @@ -274,7 +274,7 @@ template<typename ValueType , typename std::enable_if<
    Complexity
    Linear in the size of the JSON value.
    -
    Example
    The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard std::vector<short>, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string, json>.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using json = nlohmann::json;
    5 
    6 int main()
    7 {
    8  // create a JSON value with different types
    9  json json_types =
    10  {
    11  {"boolean", true},
    12  {
    13  "number", {
    14  {"integer", 42},
    15  {"floating-point", 17.23}
    16  }
    17  },
    18  {"string", "Hello, world!"},
    19  {"array", {1, 2, 3, 4, 5}},
    20  {"null", nullptr}
    21  };
    22 
    23  // use explicit conversions
    24  auto v1 = json_types["boolean"].get<bool>();
    25  auto v2 = json_types["number"]["integer"].get<int>();
    26  auto v3 = json_types["number"]["integer"].get<short>();
    27  auto v4 = json_types["number"]["floating-point"].get<float>();
    28  auto v5 = json_types["number"]["floating-point"].get<int>();
    29  auto v6 = json_types["string"].get<std::string>();
    30  auto v7 = json_types["array"].get<std::vector<short>>();
    31  auto v8 = json_types.get<std::unordered_map<std::string, json>>();
    32 
    33  // print the conversion results
    34  std::cout << v1 << '\n';
    35  std::cout << v2 << ' ' << v3 << '\n';
    36  std::cout << v4 << ' ' << v5 << '\n';
    37  std::cout << v6 << '\n';
    38 
    39  for (auto i : v7)
    40  {
    41  std::cout << i << ' ';
    42  }
    43  std::cout << "\n\n";
    44 
    45  for (auto i : v8)
    46  {
    47  std::cout << i.first << ": " << i.second << '\n';
    48  }
    49 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard std::vector<short>, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string, json>.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using json = nlohmann::json;
    5 
    6 int main()
    7 {
    8  // create a JSON value with different types
    9  json json_types =
    10  {
    11  {"boolean", true},
    12  {
    13  "number", {
    14  {"integer", 42},
    15  {"floating-point", 17.23}
    16  }
    17  },
    18  {"string", "Hello, world!"},
    19  {"array", {1, 2, 3, 4, 5}},
    20  {"null", nullptr}
    21  };
    22 
    23  // use explicit conversions
    24  auto v1 = json_types["boolean"].get<bool>();
    25  auto v2 = json_types["number"]["integer"].get<int>();
    26  auto v3 = json_types["number"]["integer"].get<short>();
    27  auto v4 = json_types["number"]["floating-point"].get<float>();
    28  auto v5 = json_types["number"]["floating-point"].get<int>();
    29  auto v6 = json_types["string"].get<std::string>();
    30  auto v7 = json_types["array"].get<std::vector<short>>();
    31  auto v8 = json_types.get<std::unordered_map<std::string, json>>();
    32 
    33  // print the conversion results
    34  std::cout << v1 << '\n';
    35  std::cout << v2 << ' ' << v3 << '\n';
    36  std::cout << v4 << ' ' << v5 << '\n';
    37  std::cout << v6 << '\n';
    38 
    39  for (auto i : v7)
    40  {
    41  std::cout << i << ' ';
    42  }
    43  std::cout << "\n\n";
    44 
    45  for (auto i : v8)
    46  {
    47  std::cout << i.first << ": " << i.second << '\n';
    48  }
    49 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -292,7 +292,7 @@ array: [1,2,3,4,5]
     get() for pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2720 of file json.hpp.

    +

    Definition at line 2694 of file json.hpp.

    @@ -302,7 +302,7 @@ array: [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html b/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html index 8dcde0180..a6d987c8a 100644 --- a/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html +++ b/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html @@ -274,16 +274,16 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how array elements can be read and written using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON array
    8  json array = {"first", "2nd", "third", "fourth"};
    9 
    10  // output element at index 2 (third element)
    11  std::cout << array.at(2) << '\n';
    12 
    13  // change element at index 1 (second element) to "second"
    14  array.at(1) = "second";
    15 
    16  // output changed array
    17  std::cout << array << '\n';
    18 
    19  // try to write beyond the array limit
    20  try
    21  {
    22  array.at(5) = "sixth";
    23  }
    24  catch (std::out_of_range& e)
    25  {
    26  std::cout << "out of range: " << e.what() << '\n';
    27  }
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an array from an initializer list
    Definition: json.hpp:1636
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2950
    +
    Example
    The example below shows how array elements can be read and written using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON array
    8  json array = {"first", "2nd", "third", "fourth"};
    9 
    10  // output element at index 2 (third element)
    11  std::cout << array.at(2) << '\n';
    12 
    13  // change element at index 1 (second element) to "second"
    14  array.at(1) = "second";
    15 
    16  // output changed array
    17  std::cout << array << '\n';
    18 
    19  // try to write beyond the array limit
    20  try
    21  {
    22  array.at(5) = "sixth";
    23  }
    24  catch (std::out_of_range& e)
    25  {
    26  std::cout << "out of range: " << e.what() << '\n';
    27  }
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an array from an initializer list
    Definition: json.hpp:1610
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2924
    Output (play with this example online):
    "third"
     ["first","second","third","fourth"]
     out of range: array index 5 is out of range
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/at__size_type.cpp -o at__size_type 
    Since
    version 1.0.0
    -

    Definition at line 2950 of file json.hpp.

    +

    Definition at line 2924 of file json.hpp.

    @@ -293,7 +293,7 @@ out of range: array index 5 is out of range diff --git a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html index 07cfd3482..ca7584791 100644 --- a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html +++ b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje -

    Definition at line 703 of file json.hpp.

    +

    Definition at line 677 of file json.hpp.

    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a245b34ee6341bed2e3a611e223c53c48.html b/classnlohmann_1_1basic__json_a245b34ee6341bed2e3a611e223c53c48.html index a39f92015..15fd515bb 100644 --- a/classnlohmann_1_1basic__json_a245b34ee6341bed2e3a611e223c53c48.html +++ b/classnlohmann_1_1basic__json_a245b34ee6341bed2e3a611e223c53c48.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is an integer or unsigned integer number. This excludes floating-point values.

    Returns
    true if type is an integer or unsigned integer number, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number_integer for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number_integer()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number_integer() << '\n';
    20  std::cout << j_boolean.is_number_integer() << '\n';
    21  std::cout << j_number_integer.is_number_integer() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number_integer() << '\n';
    23  std::cout << j_number_float.is_number_integer() << '\n';
    24  std::cout << j_object.is_number_integer() << '\n';
    25  std::cout << j_array.is_number_integer() << '\n';
    26  std::cout << j_string.is_number_integer() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_number_integer for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number_integer()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number_integer() << '\n';
    20  std::cout << j_boolean.is_number_integer() << '\n';
    21  std::cout << j_number_integer.is_number_integer() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number_integer() << '\n';
    23  std::cout << j_number_float.is_number_integer() << '\n';
    24  std::cout << j_object.is_number_integer() << '\n';
    25  std::cout << j_array.is_number_integer() << '\n';
    26  std::cout << j_string.is_number_integer() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     true
    @@ -277,7 +277,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 1.0.0
    -

    Definition at line 2220 of file json.hpp.

    +

    Definition at line 2194 of file json.hpp.

    @@ -287,7 +287,7 @@ false diff --git a/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html b/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html index 00e5cad9a..07686d86d 100644 --- a/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html +++ b/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html @@ -302,7 +302,7 @@ erase() with null"
  • other types: constant
  • -
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_boolean = true;
    9  json j_number_integer = 17;
    10  json j_number_float = 23.42;
    11  json j_object = {{"one", 1}, {"two", 2}};
    12  json j_array = {1, 2, 4, 8, 16};
    13  json j_string = "Hello, world";
    14 
    15  // call erase
    16  j_boolean.erase(j_boolean.begin(), j_boolean.end());
    17  j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
    18  j_number_float.erase(j_number_float.begin(), j_number_float.end());
    19  j_object.erase(j_object.find("two"), j_object.end());
    20  j_array.erase(j_array.begin() + 1, j_array.begin() + 3);
    21  j_string.erase(j_string.begin(), j_string.end());
    22 
    23  // print values
    24  std::cout << j_boolean << '\n';
    25  std::cout << j_number_integer << '\n';
    26  std::cout << j_number_float << '\n';
    27  std::cout << j_object << '\n';
    28  std::cout << j_array << '\n';
    29  std::cout << j_string << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_boolean = true;
    9  json j_number_integer = 17;
    10  json j_number_float = 23.42;
    11  json j_object = {{"one", 1}, {"two", 2}};
    12  json j_array = {1, 2, 4, 8, 16};
    13  json j_string = "Hello, world";
    14 
    15  // call erase
    16  j_boolean.erase(j_boolean.begin(), j_boolean.end());
    17  j_number_integer.erase(j_number_integer.begin(), j_number_integer.end());
    18  j_number_float.erase(j_number_float.begin(), j_number_float.end());
    19  j_object.erase(j_object.find("two"), j_object.end());
    20  j_array.erase(j_array.begin() + 1, j_array.begin() + 3);
    21  j_string.erase(j_string.begin(), j_string.end());
    22 
    23  // print values
    24  std::cout << j_boolean << '\n';
    25  std::cout << j_number_integer << '\n';
    26  std::cout << j_number_float << '\n';
    27  std::cout << j_object << '\n';
    28  std::cout << j_array << '\n';
    29  std::cout << j_string << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    null
     null
     null
    @@ -317,7 +317,7 @@ null
     erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3756 of file json.hpp.

    +

    Definition at line 3730 of file json.hpp.

    @@ -327,7 +327,7 @@ null diff --git a/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html b/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html index a0af99e76..77cacbd63 100644 --- a/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html +++ b/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html @@ -275,7 +275,7 @@ operator[] with null"
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  const json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  const json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    2
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__key_type_const.cpp -o operatorarray__key_type_const 
    See also
    at(const typename object_t::key_type&) for access by reference with range checking
    @@ -283,7 +283,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3271 of file json.hpp.

    +

    Definition at line 3245 of file json.hpp.

    @@ -293,7 +293,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html b/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html index cd18c3d8f..d1b4eed40 100644 --- a/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html +++ b/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 245 of file json.hpp.

    +

    Definition at line 219 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html index 9160873a0..d2b98467e 100644 --- a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html +++ b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    the stream o
    Complexity
    Linear.
    -
    Example
    The example below shows the serialization with different parameters to width to adjust the indentation level.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_object = {{"one", 1}, {"two", 2}};
    9  json j_array = {1, 2, 4, 8, 16};
    10 
    11  // serialize without indentation
    12  std::cout << j_object << "\n\n";
    13  std::cout << j_array << "\n\n";
    14 
    15  // serialize with indentation
    16  std::cout << std::setw(4) << j_object << "\n\n";
    17  std::cout << std::setw(2) << j_array << "\n\n";
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows the serialization with different parameters to width to adjust the indentation level.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_object = {{"one", 1}, {"two", 2}};
    9  json j_array = {1, 2, 4, 8, 16};
    10 
    11  // serialize without indentation
    12  std::cout << j_object << "\n\n";
    13  std::cout << j_array << "\n\n";
    14 
    15  // serialize with indentation
    16  std::cout << std::setw(4) << j_object << "\n\n";
    17  std::cout << std::setw(2) << j_array << "\n\n";
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -299,7 +299,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator_serialize.cpp -o operator_serialize 
    Since
    version 1.0.0
    -

    Definition at line 5440 of file json.hpp.

    +

    Definition at line 5414 of file json.hpp.

    @@ -309,7 +309,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html b/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html index b7f8f7234..f9239ef01 100644 --- a/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html +++ b/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html @@ -278,11 +278,11 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    result of the deserialization
    Complexity
    Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser callback function cb has a super-linear complexity.
    Note
    A UTF-8 byte order mark is silently ignored.
    -
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // a JSON text
    8  std::string text = R"(
    9  {
    10  "Image": {
    11  "Width": 800,
    12  "Height": 600,
    13  "Title": "View from 15th Floor",
    14  "Thumbnail": {
    15  "Url": "http://www.example.com/image/481989943",
    16  "Height": 125,
    17  "Width": 100
    18  },
    19  "Animated" : false,
    20  "IDs": [116, 943, 234, 38793]
    21  }
    22  }
    23  )";
    24 
    25  // parse and serialize JSON
    26  json j_complete = json::parse(text);
    27  std::cout << std::setw(4) << j_complete << "\n\n";
    28 
    29 
    30  // define parser callback
    31  json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    32  {
    33  // skip object elements with key "Thumbnail"
    34  if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
    35  {
    36  return false;
    37  }
    38  else
    39  {
    40  return true;
    41  }
    42  };
    43 
    44  // parse (with callback) and serialize JSON
    45  json j_filtered = json::parse(text, cb);
    46  std::cout << std::setw(4) << j_filtered << '\n';
    47 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5479
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:922
    +
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // a JSON text
    8  std::string text = R"(
    9  {
    10  "Image": {
    11  "Width": 800,
    12  "Height": 600,
    13  "Title": "View from 15th Floor",
    14  "Thumbnail": {
    15  "Url": "http://www.example.com/image/481989943",
    16  "Height": 125,
    17  "Width": 100
    18  },
    19  "Animated" : false,
    20  "IDs": [116, 943, 234, 38793]
    21  }
    22  }
    23  )";
    24 
    25  // parse and serialize JSON
    26  json j_complete = json::parse(text);
    27  std::cout << std::setw(4) << j_complete << "\n\n";
    28 
    29 
    30  // define parser callback
    31  json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    32  {
    33  // skip object elements with key "Thumbnail"
    34  if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
    35  {
    36  return false;
    37  }
    38  else
    39  {
    40  return true;
    41  }
    42  };
    43 
    44  // parse (with callback) and serialize JSON
    45  json j_filtered = json::parse(text, cb);
    46  std::cout << std::setw(4) << j_filtered << '\n';
    47 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5453
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:896
    the parser read a key of a value in an object
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:857
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:831
    Output (play with this example online):
    {
         "Image": {
             "Animated": false,
    @@ -321,7 +321,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    parse(std::istream&, parser_callback_t) for a version that reads from an input stream
    Since
    version 1.0.0
    -

    Definition at line 5479 of file json.hpp.

    +

    Definition at line 5453 of file json.hpp.

    @@ -331,7 +331,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html b/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html index 03978c09b..2baf5e788 100644 --- a/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html +++ b/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows the constructor with string literal parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON string directly from a string literal
    8  json j("The quick brown fox jumps over the lazy doc");
    9 
    10  // serialize the JSON array
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the constructor with string literal parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON string directly from a string literal
    8  json j("The quick brown fox jumps over the lazy doc");
    9 
    10  // serialize the JSON array
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "The quick brown fox jumps over the lazy doc"
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__string_t_value_type.cpp -o basic_json__string_t_value_type 
    See also
    basic_json(const string_t&) – create a string value
    @@ -280,7 +280,7 @@ template<template< typename U, typename V, typename...Args > class Obje basic_json(const CompatibleStringType&) – create a string value from a compatible string container
    Since
    version 1.0.0
    -

    Definition at line 1187 of file json.hpp.

    +

    Definition at line 1161 of file json.hpp.

    @@ -290,7 +290,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html b/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html index 238b2c82d..b3a1ba4c3 100644 --- a/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html +++ b/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html @@ -272,14 +272,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
    9 
    10  // create an object_t
    11  json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
    12 
    13  // swap the object stored in the JSON value
    14  value["translation"].swap(object);
    15 
    16  // output the values
    17  std::cout << "value = " << value << '\n';
    18  std::cout << "object = " << object << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:354
    +
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} };
    9 
    10  // create an object_t
    11  json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}};
    12 
    13  // swap the object stored in the JSON value
    14  value["translation"].swap(object);
    15 
    16  // output the values
    17  std::cout << "value = " << value << '\n';
    18  std::cout << "object = " << object << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:328
    Output (play with this example online):
    value = {"translation":{"cow":"Kuh","dog":"Hund"}}
     object = {"one":"eins","two":"zwei"}
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/swap__object_t.cpp -o swap__object_t 
    Since
    version 1.0.0
    -

    Definition at line 4935 of file json.hpp.

    +

    Definition at line 4909 of file json.hpp.

    @@ -289,7 +289,7 @@ object = {"one":"eins","two":"zwei"} diff --git a/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html b/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html index 6dc67a98a..99f8b092f 100644 --- a/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html +++ b/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html @@ -272,14 +272,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows the constructor with an array_t parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array_t value
    8  json::array_t value = {"one", "two", 3, 4.5, false};
    9 
    10  // create a JSON array from the value
    11  json j(value);
    12 
    13  // serialize the JSON array
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:400
    +
    Example
    The following code shows the constructor with an array_t parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array_t value
    8  json::array_t value = {"one", "two", 3, 4.5, false};
    9 
    10  // create a JSON array from the value
    11  json j(value);
    12 
    13  // serialize the JSON array
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:374
    Output (play with this example online):
    ["one","two",3,4.5,false]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__array_t.cpp -o basic_json__array_t 
    See also
    basic_json(const CompatibleArrayType&) – create an array value from a compatible STL containers
    Since
    version 1.0.0
    -

    Definition at line 1097 of file json.hpp.

    +

    Definition at line 1071 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a3da0951c80c8f4b26497aba38cb3e463.html b/classnlohmann_1_1basic__json_a3da0951c80c8f4b26497aba38cb3e463.html index d433352b7..974bec059 100644 --- a/classnlohmann_1_1basic__json_a3da0951c80c8f4b26497aba38cb3e463.html +++ b/classnlohmann_1_1basic__json_a3da0951c80c8f4b26497aba38cb3e463.html @@ -268,13 +268,13 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).rbegin().
  • -
    Example
    The following code shows an example for crbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-beginning
    11  json::const_reverse_iterator it = array.crbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:247
    +
    Example
    The following code shows an example for crbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-beginning
    11  json::const_reverse_iterator it = array.crbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:221
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crbegin.cpp -o crbegin 
    Since
    version 1.0.0
    -

    Definition at line 4176 of file json.hpp.

    +

    Definition at line 4150 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html b/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html index bd1f5e0f8..5e934edb0 100644 --- a/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html +++ b/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html @@ -274,7 +274,7 @@ range"
    Complexity
    Linear in distance between idx and the end of the container.
    -
    Example
    The example shows the effect of erase.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json j_array = {0, 1, 2, 3, 4, 5};
    9 
    10  // call erase
    11  j_array.erase(2);
    12 
    13  // print values
    14  std::cout << j_array << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows the effect of erase.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json j_array = {0, 1, 2, 3, 4, 5};
    9 
    10  // call erase
    11  j_array.erase(2);
    12 
    13  // print values
    14  std::cout << j_array << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [0,1,3,4,5]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/erase__size_type.cpp -o erase__size_type 
    See also
    erase(InteratorType) – removes the element at a given position
    @@ -284,7 +284,7 @@ range" erase(const typename object_t::key_type&) – removes the element from an object at the given key
    Since
    version 1.0.0
    -

    Definition at line 3878 of file json.hpp.

    +

    Definition at line 3852 of file json.hpp.

    @@ -294,7 +294,7 @@ range" diff --git a/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html b/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html index deaf63a35..56c7b94ed 100644 --- a/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html +++ b/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 220 of file json.hpp.

    +

    Definition at line 194 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html b/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html index 8e98b3f97..d72db437e 100644 --- a/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html +++ b/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html @@ -292,7 +292,7 @@ of range"
  • other types: constant
  • -
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_boolean = true;
    9  json j_number_integer = 17;
    10  json j_number_float = 23.42;
    11  json j_object = {{"one", 1}, {"two", 2}};
    12  json j_array = {1, 2, 4, 8, 16};
    13  json j_string = "Hello, world";
    14 
    15  // call erase
    16  j_boolean.erase(j_boolean.begin());
    17  j_number_integer.erase(j_number_integer.begin());
    18  j_number_float.erase(j_number_float.begin());
    19  j_object.erase(j_object.find("two"));
    20  j_array.erase(j_array.begin() + 2);
    21  j_string.erase(j_string.begin());
    22 
    23  // print values
    24  std::cout << j_boolean << '\n';
    25  std::cout << j_number_integer << '\n';
    26  std::cout << j_number_float << '\n';
    27  std::cout << j_object << '\n';
    28  std::cout << j_array << '\n';
    29  std::cout << j_string << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_boolean = true;
    9  json j_number_integer = 17;
    10  json j_number_float = 23.42;
    11  json j_object = {{"one", 1}, {"two", 2}};
    12  json j_array = {1, 2, 4, 8, 16};
    13  json j_string = "Hello, world";
    14 
    15  // call erase
    16  j_boolean.erase(j_boolean.begin());
    17  j_number_integer.erase(j_number_integer.begin());
    18  j_number_float.erase(j_number_float.begin());
    19  j_object.erase(j_object.find("two"));
    20  j_array.erase(j_array.begin() + 2);
    21  j_string.erase(j_string.begin());
    22 
    23  // print values
    24  std::cout << j_boolean << '\n';
    25  std::cout << j_number_integer << '\n';
    26  std::cout << j_number_float << '\n';
    27  std::cout << j_object << '\n';
    28  std::cout << j_array << '\n';
    29  std::cout << j_string << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    null
     null
     null
    @@ -307,7 +307,7 @@ null
     erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3650 of file json.hpp.

    +

    Definition at line 3624 of file json.hpp.

    @@ -317,7 +317,7 @@ null diff --git a/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html b/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html index 221adb907..fc0879de3 100644 --- a/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html +++ b/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Amortized constant.
    -
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -280,7 +280,7 @@ null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back.cpp -o push_back 
    Since
    version 1.0.0
    -

    Definition at line 4527 of file json.hpp.

    +

    Definition at line 4501 of file json.hpp.

    @@ -290,7 +290,7 @@ null diff --git a/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html b/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html index 5afda769b..8b2f53d23 100644 --- a/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html +++ b/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html @@ -277,13 +277,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for the copy constructor.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json j1 = {"one", "two", 3, 4.5, false};
    9 
    10  // create a copy
    11  json j2(j1);
    12 
    13  // serialize the JSON array
    14  std::cout << j1 << " = " << j2 << '\n';
    15  std::cout << std::boolalpha << (j1 == j2) << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for the copy constructor.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json j1 = {"one", "two", 3, 4.5, false};
    9 
    10  // create a copy
    11  json j2(j1);
    12 
    13  // serialize the JSON array
    14  std::cout << j1 << " = " << j2 << '\n';
    15  std::cout << std::boolalpha << (j1 == j2) << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    ["one","two",3,4.5,false] = ["one","two",3,4.5,false]
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__basic_json.cpp -o basic_json__basic_json 
    Since
    version 1.0.0
    -

    Definition at line 1857 of file json.hpp.

    +

    Definition at line 1831 of file json.hpp.

    @@ -293,7 +293,7 @@ true diff --git a/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html b/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html index d4176331d..77cee4468 100644 --- a/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html +++ b/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html @@ -273,12 +273,12 @@ template<typename CompatibleNumberFloatType , typename = typename std::enabl
    -
    Note
    RFC 7159 http://www.rfc-editor.org/rfc/rfc7159.txt, section 6 disallows NaN values:
    +
    Note
    RFC 7159, section 6 disallows NaN values:

    Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.

    In case the parameter val is not a number, a JSON null value is created instead.
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of several JSON floating-point number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create values of different floating-point types
    8  float f42 = 42.23;
    9  float f_nan = 1.0f / 0.0f;
    10  double f23 = 23.42;
    11 
    12  // create JSON numbers
    13  json j42(f42);
    14  json j_nan(f_nan);
    15  json j23(f23);
    16 
    17  // serialize the JSON numbers
    18  std::cout << j42 << '\n';
    19  std::cout << j_nan << '\n';
    20  std::cout << j23 << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows the construction of several JSON floating-point number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create values of different floating-point types
    8  float f42 = 42.23;
    9  float f_nan = 1.0f / 0.0f;
    10  double f23 = 23.42;
    11 
    12  // create JSON numbers
    13  json j42(f42);
    14  json j_nan(f_nan);
    15  json j23(f23);
    16 
    17  // serialize the JSON numbers
    18  std::cout << j42 << '\n';
    19  std::cout << j_nan << '\n';
    20  std::cout << j23 << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    42.2299995422363
     null
     23.42
    @@ -286,7 +286,7 @@ null
     
    See also
    basic_json(const number_float_t) – create a number value (floating-point)
    Since
    version 1.0.0
    -

    Definition at line 1471 of file json.hpp.

    +

    Definition at line 1445 of file json.hpp.

    @@ -296,7 +296,7 @@ null diff --git a/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html b/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html index b8e5cfe8d..4421a15f6 100644 --- a/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html +++ b/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html @@ -268,12 +268,12 @@ Illustration from cppreference.com
  • The complexity is constant.
  • -
    Example
    The following code shows an example for begin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to the first element
    11  json::iterator it = array.begin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for begin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to the first element
    11  json::iterator it = array.begin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/begin.cpp -o begin 
    Since
    version 1.0.0
    -

    Definition at line 3997 of file json.hpp.

    +

    Definition at line 3971 of file json.hpp.

    @@ -283,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html b/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html index 476e2f0cb..b6356d9d3 100644 --- a/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html +++ b/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html @@ -275,15 +275,15 @@ template<typename ReferenceType , typename std::enable_if<
    Complexity
    Constant.
    -
    Example
    The example shows several calls to get_ref().
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting references
    11  auto r1 = value.get_ref<const json::number_integer_t&>();
    12  auto r2 = value.get_ref<json::number_integer_t&>();
    13 
    14  // print the values
    15  std::cout << r1 << ' ' << r2 << '\n';
    16 
    17  // incompatible type throws exception
    18  try
    19  {
    20  auto r3 = value.get_ref<json::number_float_t&>();
    21  }
    22  catch (std::domain_error& ex)
    23  {
    24  std::cout << ex.what() << '\n';
    25  }
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The example shows several calls to get_ref().
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting references
    11  auto r1 = value.get_ref<const json::number_integer_t&>();
    12  auto r2 = value.get_ref<json::number_integer_t&>();
    13 
    14  // print the values
    15  std::cout << r1 << ' ' << r2 << '\n';
    16 
    17  // incompatible type throws exception
    18  try
    19  {
    20  auto r3 = value.get_ref<json::number_float_t&>();
    21  }
    22  catch (std::domain_error& ex)
    23  {
    24  std::cout << ex.what() << '\n';
    25  }
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    17 17
     incompatible ReferenceType for get_ref, actual type is number
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ref.cpp -o get_ref 
    Since
    version 1.1.0
    -

    Definition at line 2855 of file json.hpp.

    +

    Definition at line 2829 of file json.hpp.

    @@ -293,7 +293,7 @@ incompatible ReferenceType for get_ref, actual type is number diff --git a/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html b/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html index 8c03d4cf7..5531f04cb 100644 --- a/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html +++ b/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html @@ -267,13 +267,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    Number of elements with key key. If the JSON value is not an object, the return value will be 0.
    Complexity
    Logarithmic in the size of the JSON object.
    -
    Example
    The example shows how count is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call find
    11  auto count_two = j_object.count("two");
    12  auto count_three = j_object.count("three");
    13 
    14  // print values
    15  std::cout << std::boolalpha;
    16  std::cout << "number of elements with key \"two\": " << count_two << '\n';
    17  std::cout << "number of elements with key \"three\": " << count_three << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how count is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call find
    11  auto count_two = j_object.count("two");
    12  auto count_three = j_object.count("three");
    13 
    14  // print values
    15  std::cout << std::boolalpha;
    16  std::cout << "number of elements with key \"two\": " << count_two << '\n';
    17  std::cout << "number of elements with key \"three\": " << count_three << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    number of elements with key "two": 1
     number of elements with key "three": 0
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/count.cpp -o count 
    Since
    version 1.0.0
    -

    Definition at line 3962 of file json.hpp.

    +

    Definition at line 3936 of file json.hpp.

    @@ -283,7 +283,7 @@ number of elements with key "three": 0 diff --git a/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html b/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html index 8a9b0d7fc..d81168bcb 100644 --- a/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html +++ b/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Logarithmic in the size of the container, O(log(size())).
    -
    Example
    The example shows how push_back and += can be used to add elements to a JSON object. Note how the null value was silently converted to a JSON object.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json object = {{"one", 1}, {"two", 2}};
    9  json null;
    10 
    11  // print values
    12  std::cout << object << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  object.push_back(json::object_t::value_type("three", 3));
    17  object += json::object_t::value_type("four", 4);
    18  null += json::object_t::value_type("A", "a");
    19  null += json::object_t::value_type("B", "b");
    20 
    21  // print values
    22  std::cout << object << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how push_back and += can be used to add elements to a JSON object. Note how the null value was silently converted to a JSON object.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json object = {{"one", 1}, {"two", 2}};
    9  json null;
    10 
    11  // print values
    12  std::cout << object << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  object.push_back(json::object_t::value_type("three", 3));
    17  object += json::object_t::value_type("four", 4);
    18  null += json::object_t::value_type("A", "a");
    19  null += json::object_t::value_type("B", "b");
    20 
    21  // print values
    22  std::cout << object << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -280,7 +280,7 @@ null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back__object_t__value.cpp -o push_back__object_t__value 
    Since
    version 1.0.0
    -

    Definition at line 4613 of file json.hpp.

    +

    Definition at line 4587 of file json.hpp.

    @@ -290,7 +290,7 @@ null diff --git a/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html b/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html index 06437e40d..b913084f8 100644 --- a/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html +++ b/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Note
    This constructor allows to pass enums directly to a constructor. As C++ has no way of specifying the type of an anonymous enum explicitly, we can only rely on the fact that such values implicitly convert to int. As int may already be the same type of number_integer_t, we may need to switch off the constructor basic_json(const number_integer_t).
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of a JSON integer number value from an anonymous enum.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // an anonymous enum
    8  enum { t = 17 };
    9 
    10  // create a JSON number from the enum
    11  json j(t);
    12 
    13  // serialize the JSON numbers
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows the construction of a JSON integer number value from an anonymous enum.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // an anonymous enum
    8  enum { t = 17 };
    9 
    10  // create a JSON number from the enum
    11  json j(t);
    12 
    13  // serialize the JSON numbers
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    17
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__const_int.cpp -o basic_json__const_int 
    See also
    basic_json(const number_integer_t) – create a number value (integer)
    @@ -275,7 +275,7 @@ template<template< typename U, typename V, typename...Args > class Obje basic_json(const CompatibleNumberIntegerType) – create a number value (integer) from a compatible number type
    Since
    version 1.0.0
    -

    Definition at line 1300 of file json.hpp.

    +

    Definition at line 1274 of file json.hpp.

    @@ -285,7 +285,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html b/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html index ff966bba3..8f7a96f8f 100644 --- a/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html +++ b/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html @@ -272,8 +272,8 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    JSON array value
    Complexity
    Linear in the size of init.
    -
    Example
    The following code shows an example for the array function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON arrays
    8  json j_no_init_list = json::array();
    9  json j_empty_init_list = json::array({});
    10  json j_nonempty_init_list = json::array({1, 2, 3, 4});
    11  json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
    12 
    13  // serialize the JSON arrays
    14  std::cout << j_no_init_list << '\n';
    15  std::cout << j_empty_init_list << '\n';
    16  std::cout << j_nonempty_init_list << '\n';
    17  std::cout << j_list_of_pairs << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an array from an initializer list
    Definition: json.hpp:1636
    +
    Example
    The following code shows an example for the array function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON arrays
    8  json j_no_init_list = json::array();
    9  json j_empty_init_list = json::array({});
    10  json j_nonempty_init_list = json::array({1, 2, 3, 4});
    11  json j_list_of_pairs = json::array({ {"one", 1}, {"two", 2} });
    12 
    13  // serialize the JSON arrays
    14  std::cout << j_no_init_list << '\n';
    15  std::cout << j_empty_init_list << '\n';
    16  std::cout << j_nonempty_init_list << '\n';
    17  std::cout << j_list_of_pairs << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an array from an initializer list
    Definition: json.hpp:1610
    Output (play with this example online):
    []
     []
     [1,2,3,4]
    @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     object(std::initializer_list<basic_json>) – create a JSON object value from an initializer list
    Since
    version 1.0.0
    -

    Definition at line 1636 of file json.hpp.

    +

    Definition at line 1610 of file json.hpp.

    @@ -294,7 +294,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a579c170c06dc73a97f5e4c54d0942616.html b/classnlohmann_1_1basic__json_a579c170c06dc73a97f5e4c54d0942616.html index e09ba9b33..b7220e4f5 100644 --- a/classnlohmann_1_1basic__json_a579c170c06dc73a97f5e4c54d0942616.html +++ b/classnlohmann_1_1basic__json_a579c170c06dc73a97f5e4c54d0942616.html @@ -260,10 +260,10 @@ template<template< typename U, typename V, typename...Args > class Obje

    Implicitly return the type of the JSON value as a value from the value_t enumeration.

    Returns
    the type of the JSON value
    Complexity
    Constant.
    -
    Example
    The following code exemplifies the value_t operator for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call operator value_t()
    17  json::value_t t_null = j_null;
    18  json::value_t t_boolean = j_boolean;
    19  json::value_t t_number_integer = j_number_integer;
    20  json::value_t t_number_float = j_number_float;
    21  json::value_t t_object = j_object;
    22  json::value_t t_array = j_array;
    23  json::value_t t_string = j_string;
    24 
    25  // print types
    26  std::cout << std::boolalpha;
    27  std::cout << (t_null == json::value_t::null) << '\n';
    28  std::cout << (t_boolean == json::value_t::boolean) << '\n';
    29  std::cout << (t_number_integer == json::value_t::number_integer) << '\n';
    30  std::cout << (t_number_float == json::value_t::number_float) << '\n';
    31  std::cout << (t_object == json::value_t::object) << '\n';
    32  std::cout << (t_array == json::value_t::array) << '\n';
    33  std::cout << (t_string == json::value_t::string) << '\n';
    34 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies the value_t operator for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call operator value_t()
    17  json::value_t t_null = j_null;
    18  json::value_t t_boolean = j_boolean;
    19  json::value_t t_number_integer = j_number_integer;
    20  json::value_t t_number_float = j_number_float;
    21  json::value_t t_object = j_object;
    22  json::value_t t_array = j_array;
    23  json::value_t t_string = j_string;
    24 
    25  // print types
    26  std::cout << std::boolalpha;
    27  std::cout << (t_null == json::value_t::null) << '\n';
    28  std::cout << (t_boolean == json::value_t::boolean) << '\n';
    29  std::cout << (t_number_integer == json::value_t::number_integer) << '\n';
    30  std::cout << (t_number_float == json::value_t::number_float) << '\n';
    31  std::cout << (t_object == json::value_t::object) << '\n';
    32  std::cout << (t_array == json::value_t::array) << '\n';
    33  std::cout << (t_string == json::value_t::string) << '\n';
    34 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    -
    value_t
    the JSON type enumeration
    Definition: json.hpp:703
    +
    value_t
    the JSON type enumeration
    Definition: json.hpp:677
    array (ordered collection of values)
    number value (floating-point)
    @@ -279,7 +279,7 @@ true The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__value_t.cpp -o operator__value_t 
    Since
    version 1.0.0
    -

    Definition at line 2371 of file json.hpp.

    +

    Definition at line 2345 of file json.hpp.

    @@ -289,7 +289,7 @@ true diff --git a/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html b/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html index 507da751d..c15913f70 100644 --- a/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html +++ b/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html @@ -275,14 +275,14 @@ use operator[] with null"
    Complexity
    Constant if idx is in the range of the array. Otherwise linear in idx - size().
    -
    Example
    The example below shows how array elements can be read and written using [] operator. Note the addition of null values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // output element at index 3 (fourth element)
    11  std::cout << array[3] << '\n';
    12 
    13  // change last element to 6
    14  array[array.size() - 1] = 6;
    15 
    16  // output changed array
    17  std::cout << array << '\n';
    18 
    19  // write beyond array limit
    20  array[10] = 11;
    21 
    22  // output changed array
    23  std::cout << array << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how array elements can be read and written using [] operator. Note the addition of null values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // output element at index 3 (fourth element)
    11  std::cout << array[3] << '\n';
    12 
    13  // change last element to 6
    14  array[array.size() - 1] = 6;
    15 
    16  // output changed array
    17  std::cout << array << '\n';
    18 
    19  // write beyond array limit
    20  array[10] = 11;
    21 
    22  // output changed array
    23  std::cout << array << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    4
     [1,2,3,4,6]
     [1,2,3,4,6,null,null,null,null,null,11]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__size_type.cpp -o operatorarray__size_type 
    Since
    version 1.0.0
    -

    Definition at line 3137 of file json.hpp.

    +

    Definition at line 3111 of file json.hpp.

    @@ -292,7 +292,7 @@ use operator[] with null" diff --git a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html index 7e9117f1b..4678b8236 100644 --- a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html +++ b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether lhs is less than or equal to rhs
    Complexity
    Linear.
    -
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 > array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 > object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 > number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 > string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 > array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 > object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 > number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 > string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3] == [1,2,4] false
     {"A":"a","B":"b"} == {"A":"a","B":"b"} false
     17 == 17.0000000000001 false
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__greater.cpp -o operator__greater 
    Since
    version 1.0.0
    -

    Definition at line 5341 of file json.hpp.

    +

    Definition at line 5315 of file json.hpp.

    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a5d288e4e8828c2ef03a4f9958ce3d175.html b/classnlohmann_1_1basic__json_a5d288e4e8828c2ef03a4f9958ce3d175.html index 6a3c749ff..c789a066d 100644 --- a/classnlohmann_1_1basic__json_a5d288e4e8828c2ef03a4f9958ce3d175.html +++ b/classnlohmann_1_1basic__json_a5d288e4e8828c2ef03a4f9958ce3d175.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is a floating-point number. This excludes integer and unsigned integer values.

    Returns
    true if type is a floating-point number, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number_float for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number_float()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number_float() << '\n';
    20  std::cout << j_boolean.is_number_float() << '\n';
    21  std::cout << j_number_integer.is_number_float() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number_float() << '\n';
    23  std::cout << j_number_float.is_number_float() << '\n';
    24  std::cout << j_object.is_number_float() << '\n';
    25  std::cout << j_array.is_number_float() << '\n';
    26  std::cout << j_string.is_number_float() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_number_float for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number_float()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number_float() << '\n';
    20  std::cout << j_boolean.is_number_float() << '\n';
    21  std::cout << j_number_integer.is_number_float() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number_float() << '\n';
    23  std::cout << j_number_float.is_number_float() << '\n';
    24  std::cout << j_object.is_number_float() << '\n';
    25  std::cout << j_array.is_number_float() << '\n';
    26  std::cout << j_string.is_number_float() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -277,7 +277,7 @@ false
     is_number_unsigned() – check if value is an unsigned integer number
    Since
    version 1.0.0
    -

    Definition at line 2270 of file json.hpp.

    +

    Definition at line 2244 of file json.hpp.

    @@ -287,7 +287,7 @@ false diff --git a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html index b032feb95..ff9a1360b 100644 --- a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html +++ b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    the stream o
    Complexity
    Linear.
    -
    Example
    The example below shows the serialization with different parameters to width to adjust the indentation level.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_object = {{"one", 1}, {"two", 2}};
    9  json j_array = {1, 2, 4, 8, 16};
    10 
    11  // serialize without indentation
    12  std::cout << j_object << "\n\n";
    13  std::cout << j_array << "\n\n";
    14 
    15  // serialize with indentation
    16  std::cout << std::setw(4) << j_object << "\n\n";
    17  std::cout << std::setw(2) << j_array << "\n\n";
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows the serialization with different parameters to width to adjust the indentation level.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_object = {{"one", 1}, {"two", 2}};
    9  json j_array = {1, 2, 4, 8, 16};
    10 
    11  // serialize without indentation
    12  std::cout << j_object << "\n\n";
    13  std::cout << j_array << "\n\n";
    14 
    15  // serialize with indentation
    16  std::cout << std::setw(4) << j_object << "\n\n";
    17  std::cout << std::setw(2) << j_array << "\n\n";
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -299,7 +299,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator_serialize.cpp -o operator_serialize 
    Since
    version 1.0.0
    -

    Definition at line 5422 of file json.hpp.

    +

    Definition at line 5396 of file json.hpp.

    @@ -309,7 +309,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html b/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html index c1f98d164..9d8add511 100644 --- a/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html +++ b/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is null.

    Returns
    true if type is null, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_null for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_null()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_null() << '\n';
    20  std::cout << j_boolean.is_null() << '\n';
    21  std::cout << j_number_integer.is_null() << '\n';
    22  std::cout << j_number_unsigned_integer.is_null() << '\n';
    23  std::cout << j_number_float.is_null() << '\n';
    24  std::cout << j_object.is_null() << '\n';
    25  std::cout << j_array.is_null() << '\n';
    26  std::cout << j_string.is_null() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_null for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_null()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_null() << '\n';
    20  std::cout << j_boolean.is_null() << '\n';
    21  std::cout << j_number_integer.is_null() << '\n';
    22  std::cout << j_number_unsigned_integer.is_null() << '\n';
    23  std::cout << j_number_float.is_null() << '\n';
    24  std::cout << j_object.is_null() << '\n';
    25  std::cout << j_array.is_null() << '\n';
    26  std::cout << j_string.is_null() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    true
     false
     false
    @@ -272,7 +272,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_null.cpp -o is_null 
    Since
    version 1.0.0
    -

    Definition at line 2148 of file json.hpp.

    +

    Definition at line 2122 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html b/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html index 679a1aaf3..64390fb7d 100644 --- a/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html +++ b/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje number_integer_t – type for number values (integer)
    Since
    version 2.0.0
    -

    Definition at line 616 of file json.hpp.

    +

    Definition at line 590 of file json.hpp.

    @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html b/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html index ee8f0a8c2..275e79919 100644 --- a/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html +++ b/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in the length of the input. The parser is a predictive LL(1) parser.
    Note
    A UTF-8 byte order mark is silently ignored.
    -
    Example
    The example below shows how a JSON value is constructed by reading a serialization from a stream.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create stream with serialized JSON
    8  std::stringstream ss;
    9  ss << R"({
    10  "number": 23,
    11  "string": "Hello, world!",
    12  "array": [1, 2, 3, 4, 5],
    13  "boolean": false,
    14  "null": null
    15  })";
    16 
    17  // create JSON value and read the serialization from the stream
    18  json j;
    19  j << ss;
    20 
    21  // serialize JSON
    22  std::cout << std::setw(2) << j << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how a JSON value is constructed by reading a serialization from a stream.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create stream with serialized JSON
    8  std::stringstream ss;
    9  ss << R"({
    10  "number": 23,
    11  "string": "Hello, world!",
    12  "array": [1, 2, 3, 4, 5],
    13  "boolean": false,
    14  "null": null
    15  })";
    16 
    17  // create JSON value and read the serialization from the stream
    18  json j;
    19  j << ss;
    20 
    21  // serialize JSON
    22  std::cout << std::setw(2) << j << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -302,7 +302,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    parse(std::istream&, parser_callback_t) for a variant with a parser callback function to filter values while parsing
    Since
    version 1.0.0
    -

    Definition at line 5544 of file json.hpp.

    +

    Definition at line 5518 of file json.hpp.

    @@ -312,7 +312,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a620e4d98496f85bd7be080248c0f14e9.html b/classnlohmann_1_1basic__json_a620e4d98496f85bd7be080248c0f14e9.html index e4d88821c..3eeca5619 100644 --- a/classnlohmann_1_1basic__json_a620e4d98496f85bd7be080248c0f14e9.html +++ b/classnlohmann_1_1basic__json_a620e4d98496f85bd7be080248c0f14e9.html @@ -277,7 +277,7 @@ template<typename T , typename std::enable_if<
    See also
    basic_json(const CompatibleNumberUnsignedType) – create a number value (unsigned integer) from a compatible number type
    Since
    version 2.0.0
    -

    Definition at line 1365 of file json.hpp.

    +

    Definition at line 1339 of file json.hpp.

    @@ -287,7 +287,7 @@ template<typename T , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html b/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html index f4f9c330d..ea91c981c 100644 --- a/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html +++ b/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html @@ -292,13 +292,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in cnt plus linear in the distance between pos and end of the container.
    -
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert number 7 copies of number 7 before number 3
    11  auto new_pos = v.insert(v.begin() + 2, 7, 7);
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert number 7 copies of number 7 before number 3
    11  auto new_pos = v.insert(v.begin() + 2, 7, 7);
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    7
     [1,2,7,7,7,7,7,7,7,3,4]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/insert__count.cpp -o insert__count 
    Since
    version 1.0.0
    -

    Definition at line 4721 of file json.hpp.

    +

    Definition at line 4695 of file json.hpp.

    @@ -308,7 +308,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html b/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html index de72f80ff..b036101bc 100644 --- a/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html +++ b/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html @@ -261,7 +261,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Note
    This function will always be false for JSON values after parsing. That is, discarded values can only occur during parsing, but will be removed when inside a structured value or replaced by null in other cases.
    Returns
    true if type is discarded, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_discarded for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_discarded()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_discarded() << '\n';
    20  std::cout << j_boolean.is_discarded() << '\n';
    21  std::cout << j_number_integer.is_discarded() << '\n';
    22  std::cout << j_number_unsigned_integer.is_discarded() << '\n';
    23  std::cout << j_number_float.is_discarded() << '\n';
    24  std::cout << j_object.is_discarded() << '\n';
    25  std::cout << j_array.is_discarded() << '\n';
    26  std::cout << j_string.is_discarded() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_discarded for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_discarded()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_discarded() << '\n';
    20  std::cout << j_boolean.is_discarded() << '\n';
    21  std::cout << j_number_integer.is_discarded() << '\n';
    22  std::cout << j_number_unsigned_integer.is_discarded() << '\n';
    23  std::cout << j_number_float.is_discarded() << '\n';
    24  std::cout << j_object.is_discarded() << '\n';
    25  std::cout << j_array.is_discarded() << '\n';
    26  std::cout << j_string.is_discarded() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -273,7 +273,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_discarded.cpp -o is_discarded 
    Since
    version 1.0.0
    -

    Definition at line 2351 of file json.hpp.

    +

    Definition at line 2325 of file json.hpp.

    @@ -283,7 +283,7 @@ false diff --git a/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html b/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html index 86b2abf82..f1adfba7c 100644 --- a/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html +++ b/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON object
    8  json object =
    9  {
    10  {"the good", "il buono"},
    11  {"the bad", "il cativo"},
    12  {"the ugly", "il brutto"}
    13  };
    14 
    15  // output element with key "the ugly"
    16  std::cout << object.at("the ugly") << '\n';
    17 
    18  // try to read from a nonexisting key
    19  try
    20  {
    21  std::cout << object.at("the fast") << '\n';
    22  }
    23  catch (std::out_of_range)
    24  {
    25  std::cout << "out of range" << '\n';
    26  }
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON object
    8  json object =
    9  {
    10  {"the good", "il buono"},
    11  {"the bad", "il cativo"},
    12  {"the ugly", "il brutto"}
    13  };
    14 
    15  // output element with key "the ugly"
    16  std::cout << object.at("the ugly") << '\n';
    17 
    18  // try to read from a nonexisting key
    19  try
    20  {
    21  std::cout << object.at("the fast") << '\n';
    22  }
    23  catch (std::out_of_range)
    24  {
    25  std::cout << "out of range" << '\n';
    26  }
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "il brutto"
     out of range
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/at__object_t_key_type_const.cpp -o at__object_t_key_type_const 
    @@ -283,7 +283,7 @@ out of range value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3090 of file json.hpp.

    +

    Definition at line 3064 of file json.hpp.

    @@ -293,7 +293,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html b/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html index 40469aabf..3c5058037 100644 --- a/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html +++ b/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html @@ -277,7 +277,7 @@ template<typename CompatibleNumberUnsignedType , typename std::enable_if<
    See also
    basic_json(const number_unsigned_t) – create a number value (unsigned)
    Since
    version 2.0.0
    -

    Definition at line 1396 of file json.hpp.

    +

    Definition at line 1370 of file json.hpp.

    @@ -287,7 +287,7 @@ template<typename CompatibleNumberUnsignedType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a6adb089a5cacff9c7ad80d753b3fdf98.html b/classnlohmann_1_1basic__json_a6adb089a5cacff9c7ad80d753b3fdf98.html index 433c96f19..a727fb5f1 100644 --- a/classnlohmann_1_1basic__json_a6adb089a5cacff9c7ad80d753b3fdf98.html +++ b/classnlohmann_1_1basic__json_a6adb089a5cacff9c7ad80d753b3fdf98.html @@ -265,13 +265,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Note
    RFC 7159 http://www.rfc-editor.org/rfc/rfc7159.txt, section 6 disallows NaN values:
    +
    Note
    RFC 7159, section 6 disallows NaN values:

    Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.

    In case the parameter val is not a number, a JSON null value is created instead.
    Complexity
    Constant.
    -
    Example
    The following example creates several floating-point values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create values of different floating-point types
    8  json::number_float_t v_ok = 3.141592653589793;
    9  json::number_float_t v_nan = NAN;
    10  json::number_float_t v_infinity = INFINITY;
    11 
    12  // create JSON numbers
    13  json j_ok(v_ok);
    14  json j_nan(v_nan);
    15  json j_infinity(v_infinity);
    16 
    17  // serialize the JSON numbers
    18  std::cout << j_ok << '\n';
    19  std::cout << j_nan << '\n';
    20  std::cout << j_infinity << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The following example creates several floating-point values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create values of different floating-point types
    8  json::number_float_t v_ok = 3.141592653589793;
    9  json::number_float_t v_nan = NAN;
    10  json::number_float_t v_infinity = INFINITY;
    11 
    12  // create JSON numbers
    13  json j_ok(v_ok);
    14  json j_nan(v_nan);
    15  json j_infinity(v_infinity);
    16 
    17  // serialize the JSON numbers
    18  std::cout << j_ok << '\n';
    19  std::cout << j_nan << '\n';
    20  std::cout << j_infinity << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    3.14159265358979
     null
     null
    @@ -279,7 +279,7 @@ null
     
    See also
    basic_json(const CompatibleNumberFloatType) – create a number value (floating-point) from a compatible number type
    Since
    version 1.0.0
    -

    Definition at line 1425 of file json.hpp.

    +

    Definition at line 1399 of file json.hpp.

    @@ -289,7 +289,7 @@ null diff --git a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html index 605b5c2e5..a2b31999c 100644 --- a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html +++ b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether the values lhs and rhs are not equal
    Complexity
    Linear.
    -
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.000000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 != array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 != object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 != number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 != string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.000000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 != array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 != object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 != number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 != string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3] == [1,2,4] true
     {"A":"a","B":"b"} == {"A":"a","B":"b"} false
     17 == 17.0 false
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__notequal.cpp -o operator__notequal 
    Since
    version 1.0.0
    -

    Definition at line 5179 of file json.hpp.

    +

    Definition at line 5153 of file json.hpp.

    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html b/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html index 9e773fa6c..5f12a729b 100644 --- a/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html +++ b/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Amortized constant.
    -
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -280,7 +280,7 @@ null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back.cpp -o push_back 
    Since
    version 1.0.0
    -

    Definition at line 4563 of file json.hpp.

    +

    Definition at line 4537 of file json.hpp.

    @@ -290,7 +290,7 @@ null diff --git a/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html b/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html index ecb21ebb8..25354f105 100644 --- a/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html +++ b/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for back.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for back.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/back.cpp -o back 
    Since
    version 1.0.0
    -

    Definition at line 3583 of file json.hpp.

    +

    Definition at line 3557 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a73619da32d2a1388f5c7b37f2032138f.html b/classnlohmann_1_1basic__json_a73619da32d2a1388f5c7b37f2032138f.html index 2198e75ca..80b85c340 100644 --- a/classnlohmann_1_1basic__json_a73619da32d2a1388f5c7b37f2032138f.html +++ b/classnlohmann_1_1basic__json_a73619da32d2a1388f5c7b37f2032138f.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is an array.

    Returns
    true if type is array, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_array for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_array()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_array() << '\n';
    20  std::cout << j_boolean.is_array() << '\n';
    21  std::cout << j_number_integer.is_array() << '\n';
    22  std::cout << j_number_unsigned_integer.is_array() << '\n';
    23  std::cout << j_number_float.is_array() << '\n';
    24  std::cout << j_object.is_array() << '\n';
    25  std::cout << j_array.is_array() << '\n';
    26  std::cout << j_string.is_array() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_array for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_array()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_array() << '\n';
    20  std::cout << j_boolean.is_array() << '\n';
    21  std::cout << j_number_integer.is_array() << '\n';
    22  std::cout << j_number_unsigned_integer.is_array() << '\n';
    23  std::cout << j_number_float.is_array() << '\n';
    24  std::cout << j_object.is_array() << '\n';
    25  std::cout << j_array.is_array() << '\n';
    26  std::cout << j_string.is_array() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -272,7 +272,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_array.cpp -o is_array 
    Since
    version 1.0.0
    -

    Definition at line 2308 of file json.hpp.

    +

    Definition at line 2282 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html b/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html index b41f934de..560738b8c 100644 --- a/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html +++ b/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html @@ -267,13 +267,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Postcondition
    other is a JSON null value
    Complexity
    Constant.
    -
    Example
    The code below shows the move constructor explicitly called via std::move.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json a = 23;
    9 
    10  // move contents of a to b
    11  json b(std::move(a));
    12 
    13  // serialize the JSON arrays
    14  std::cout << a << '\n';
    15  std::cout << b << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The code below shows the move constructor explicitly called via std::move.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json a = 23;
    9 
    10  // move contents of a to b
    11  json b(std::move(a));
    12 
    13  // serialize the JSON arrays
    14  std::cout << a << '\n';
    15  std::cout << b << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    null
     23
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__moveconstructor.cpp -o basic_json__moveconstructor 
    Since
    version 1.0.0
    -

    Definition at line 1932 of file json.hpp.

    +

    Definition at line 1906 of file json.hpp.

    @@ -283,7 +283,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html b/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html index 50bc42237..ff0271601 100644 --- a/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html +++ b/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html @@ -270,7 +270,7 @@ template<template< typename U, typename V, typename...Args > class Obje number_unsigned_t – type for number values (unsigned integer)
    Since
    version 1.0.0
    -

    Definition at line 684 of file json.hpp.

    +

    Definition at line 658 of file json.hpp.

    @@ -280,7 +280,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html index 7e4db34f2..9e496d156 100644 --- a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html +++ b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether lhs is greater than or equal to rhs
    Complexity
    Linear.
    -
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " >= " << array_2 << " " << (array_1 >= array_2) << '\n';
    20  std::cout << object_1 << " >= " << object_2 << " " << (object_1 >= object_2) << '\n';
    21  std::cout << number_1 << " >= " << number_2 << " " << (number_1 >= number_2) << '\n';
    22  std::cout << string_1 << " >= " << string_2 << " " << (string_1 >= string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " >= " << array_2 << " " << (array_1 >= array_2) << '\n';
    20  std::cout << object_1 << " >= " << object_2 << " " << (object_1 >= object_2) << '\n';
    21  std::cout << number_1 << " >= " << number_2 << " " << (number_1 >= number_2) << '\n';
    22  std::cout << string_1 << " >= " << string_2 << " " << (string_1 >= string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3] >= [1,2,4] false
     {"A":"a","B":"b"} >= {"A":"a","B":"b"} true
     17 >= 17.0000000000001 false
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__greaterequal.cpp -o operator__greaterequal 
    Since
    version 1.0.0
    -

    Definition at line 5385 of file json.hpp.

    +

    Definition at line 5359 of file json.hpp.

    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a791afb7d6974c52b134d66aa1f249164.html b/classnlohmann_1_1basic__json_a791afb7d6974c52b134d66aa1f249164.html index 750acdc26..f20072e15 100644 --- a/classnlohmann_1_1basic__json_a791afb7d6974c52b134d66aa1f249164.html +++ b/classnlohmann_1_1basic__json_a791afb7d6974c52b134d66aa1f249164.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is a number. This includes both integer and floating-point values.

    Returns
    true if type is number (regardless whether integer, unsigned integer or floating-type), false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number() << '\n';
    20  std::cout << j_boolean.is_number() << '\n';
    21  std::cout << j_number_integer.is_number() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number() << '\n';
    23  std::cout << j_number_float.is_number() << '\n';
    24  std::cout << j_object.is_number() << '\n';
    25  std::cout << j_array.is_number() << '\n';
    26  std::cout << j_string.is_number() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_number for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number() << '\n';
    20  std::cout << j_boolean.is_number() << '\n';
    21  std::cout << j_number_integer.is_number() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number() << '\n';
    23  std::cout << j_number_float.is_number() << '\n';
    24  std::cout << j_object.is_number() << '\n';
    25  std::cout << j_array.is_number() << '\n';
    26  std::cout << j_string.is_number() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     true
    @@ -277,7 +277,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 1.0.0
    -

    Definition at line 2194 of file json.hpp.

    +

    Definition at line 2168 of file json.hpp.

    @@ -287,7 +287,7 @@ false diff --git a/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html b/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html index e6678a3fc..567840fb1 100644 --- a/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html +++ b/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html @@ -269,15 +269,15 @@ template<typename PointerType , typename std::enable_if<
    Returns
    pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise
    Complexity
    Constant.
    -
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get_ptr<const json::number_integer_t*>();
    12  auto p2 = value.get_ptr<json::number_integer_t*>();
    13  auto p3 = value.get_ptr<json::number_integer_t* const>();
    14  auto p4 = value.get_ptr<const json::number_integer_t* const>();
    15  auto p5 = value.get_ptr<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get_ptr<const json::number_integer_t*>();
    12  auto p2 = value.get_ptr<json::number_integer_t*>();
    13  auto p3 = value.get_ptr<json::number_integer_t* const>();
    14  auto p4 = value.get_ptr<const json::number_integer_t* const>();
    15  auto p5 = value.get_ptr<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr 
    Since
    version 1.0.0
    -

    Definition at line 2804 of file json.hpp.

    +

    Definition at line 2778 of file json.hpp.

    @@ -287,7 +287,7 @@ true diff --git a/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html b/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html index 03a574cf8..064b0e0ec 100644 --- a/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html +++ b/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html @@ -270,13 +270,13 @@ template<template< typename U, typename V, typename...Args > class Obje
  • The complexity is linear.
  • -
    Example
    The code below shows and example for the copy assignment. It creates a copy of value a which is then swapped with b. Finally, the copy of a (which is the null value after the swap) is destroyed.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json a = 23;
    9  json b = 42;
    10 
    11  // copy-assign a to b
    12  b = a;
    13 
    14  // serialize the JSON arrays
    15  std::cout << a << '\n';
    16  std::cout << b << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The code below shows and example for the copy assignment. It creates a copy of value a which is then swapped with b. Finally, the copy of a (which is the null value after the swap) is destroyed.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json a = 23;
    9  json b = 42;
    10 
    11  // copy-assign a to b
    12  b = a;
    13 
    14  // serialize the JSON arrays
    15  std::cout << a << '\n';
    16  std::cout << b << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    23
     23
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__copyassignment.cpp -o basic_json__copyassignment 
    Since
    version 1.0.0
    -

    Definition at line 1962 of file json.hpp.

    +

    Definition at line 1936 of file json.hpp.

    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html b/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html index c68adc96c..c495be007 100644 --- a/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html +++ b/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read and written using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON object
    8  json object =
    9  {
    10  {"the good", "il buono"},
    11  {"the bad", "il cativo"},
    12  {"the ugly", "il brutto"}
    13  };
    14 
    15  // output element with key "the ugly"
    16  std::cout << object.at("the ugly") << '\n';
    17 
    18  // change element with key "the bad"
    19  object.at("the bad") = "il cattivo";
    20 
    21  // output changed array
    22  std::cout << object << '\n';
    23 
    24  // try to write at a nonexisting key
    25  try
    26  {
    27  object.at("the fast") = "il rapido";
    28  }
    29  catch (std::out_of_range& e)
    30  {
    31  std::cout << "out of range: " << e.what() << '\n';
    32  }
    33 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read and written using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON object
    8  json object =
    9  {
    10  {"the good", "il buono"},
    11  {"the bad", "il cativo"},
    12  {"the ugly", "il brutto"}
    13  };
    14 
    15  // output element with key "the ugly"
    16  std::cout << object.at("the ugly") << '\n';
    17 
    18  // change element with key "the bad"
    19  object.at("the bad") = "il cattivo";
    20 
    21  // output changed array
    22  std::cout << object << '\n';
    23 
    24  // try to write at a nonexisting key
    25  try
    26  {
    27  object.at("the fast") = "il rapido";
    28  }
    29  catch (std::out_of_range& e)
    30  {
    31  std::cout << "out of range: " << e.what() << '\n';
    32  }
    33 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "il brutto"
     {"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
     out of range: key 'the fast' not found
    @@ -284,7 +284,7 @@ out of range: key 'the fast' not found
     value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3042 of file json.hpp.

    +

    Definition at line 3016 of file json.hpp.

    @@ -294,7 +294,7 @@ out of range: key 'the fast' not found diff --git a/classnlohmann_1_1basic__json_a7f53f3afd83a13c949c6c42e66e9c4b4.html b/classnlohmann_1_1basic__json_a7f53f3afd83a13c949c6c42e66e9c4b4.html index d10f7fbcc..ef70de914 100644 --- a/classnlohmann_1_1basic__json_a7f53f3afd83a13c949c6c42e66e9c4b4.html +++ b/classnlohmann_1_1basic__json_a7f53f3afd83a13c949c6c42e66e9c4b4.html @@ -268,13 +268,13 @@ Illustration from cppreference.com
  • Has the semantics of reverse_iterator(end()).
  • -
    Example
    The following code shows an example for rbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-beginning
    11  json::reverse_iterator it = array.rbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    json_reverse_iterator< typename basic_json::iterator > reverse_iterator
    a reverse iterator for a basic_json container
    Definition: json.hpp:245
    +
    Example
    The following code shows an example for rbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-beginning
    11  json::reverse_iterator it = array.rbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    json_reverse_iterator< typename basic_json::iterator > reverse_iterator
    a reverse iterator for a basic_json container
    Definition: json.hpp:219
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/rbegin.cpp -o rbegin 
    Since
    version 1.0.0
    -

    Definition at line 4114 of file json.hpp.

    +

    Definition at line 4088 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html b/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html index bfecf5431..b52eefd98 100644 --- a/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html +++ b/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html @@ -285,13 +285,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant plus linear in the distance between pos and end of the container.
    -
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert number 10 before number 3
    11  auto new_pos = v.insert(v.begin() + 2, 10);
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert number 10 before number 3
    11  auto new_pos = v.insert(v.begin() + 2, 10);
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    10
     [1,2,10,3,4]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/insert.cpp -o insert 
    Since
    version 1.0.0
    -

    Definition at line 4665 of file json.hpp.

    +

    Definition at line 4639 of file json.hpp.

    @@ -301,7 +301,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html index d553602da..666708fe7 100644 --- a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html +++ b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether v is not null
    Complexity
    Constant.
    Example
    The example compares several JSON types to the null pointer.
    -
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " != nullptr " << (array != nullptr) << '\n';
    17  std::cout << object << " != nullptr " << (object != nullptr) << '\n';
    18  std::cout << number << " != nullptr " << (number != nullptr) << '\n';
    19  std::cout << string << " != nullptr " << (string != nullptr) << '\n';
    20  std::cout << null << " != nullptr " << (null != nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " != nullptr " << (array != nullptr) << '\n';
    17  std::cout << object << " != nullptr " << (object != nullptr) << '\n';
    18  std::cout << number << " != nullptr " << (number != nullptr) << '\n';
    19  std::cout << string << " != nullptr " << (string != nullptr) << '\n';
    20  std::cout << null << " != nullptr " << (null != nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481

    Output (play with this example online):

    [1,2,3] != nullptr true
     {"A":"a","B":"b"} != nullptr true
     17 != nullptr true
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     null != nullptr false
     

    The example code above can be translated with

    g++ -std=c++11 -Isrc doc/examples/operator__notequal__nullptr_t.cpp -o operator__notequal__nullptr_t 
    Since
    version 1.0.0
    -

    Definition at line 5211 of file json.hpp.

    +

    Definition at line 5185 of file json.hpp.

    @@ -296,7 +296,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html b/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html index b2f4bf4c3..c77a81209 100644 --- a/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html +++ b/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for front.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for front.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/front.cpp -o front 
    Since
    version 1.0.0
    -

    Definition at line 3557 of file json.hpp.

    +

    Definition at line 3531 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html b/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html index fcdefacff..a9c976d30 100644 --- a/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html +++ b/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    string containing the serialization of the JSON value
    Complexity
    Linear.
    -
    Example
    The following example shows the effect of different indent parameters to the result of the serialization.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_object = {{"one", 1}, {"two", 2}};
    9  json j_array = {1, 2, 4, 8, 16};
    10 
    11  // call dump()
    12  std::cout << j_object.dump() << "\n\n";
    13  std::cout << j_object.dump(-1) << "\n\n";
    14  std::cout << j_object.dump(0) << "\n\n";
    15  std::cout << j_object.dump(4) << "\n\n";
    16  std::cout << j_array.dump() << "\n\n";
    17  std::cout << j_array.dump(-1) << "\n\n";
    18  std::cout << j_array.dump(0) << "\n\n";
    19  std::cout << j_array.dump(4) << "\n\n";
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following example shows the effect of different indent parameters to the result of the serialization.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_object = {{"one", 1}, {"two", 2}};
    9  json j_array = {1, 2, 4, 8, 16};
    10 
    11  // call dump()
    12  std::cout << j_object.dump() << "\n\n";
    13  std::cout << j_object.dump(-1) << "\n\n";
    14  std::cout << j_object.dump(0) << "\n\n";
    15  std::cout << j_object.dump(4) << "\n\n";
    16  std::cout << j_array.dump() << "\n\n";
    17  std::cout << j_array.dump(-1) << "\n\n";
    18  std::cout << j_array.dump(0) << "\n\n";
    19  std::cout << j_array.dump(4) << "\n\n";
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"one":1,"two":2}
     
     {"one":1,"two":2}
    @@ -306,7 +306,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    https://docs.python.org/2/library/json.html#json.dump
    Since
    version 1.0.0
    -

    Definition at line 2057 of file json.hpp.

    +

    Definition at line 2031 of file json.hpp.

    @@ -316,7 +316,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html b/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html index 4b74ca2fd..1a894faa8 100644 --- a/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html +++ b/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Amortized constant.
    -
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json array = {1, 2, 3, 4, 5};
    9  json null;
    10 
    11  // print values
    12  std::cout << array << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  array.push_back(6);
    17  array += 7;
    18  null += "first";
    19  null += "second";
    20 
    21  // print values
    22  std::cout << array << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -280,7 +280,7 @@ null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back.cpp -o push_back 
    Since
    version 1.0.0
    -

    Definition at line 4587 of file json.hpp.

    +

    Definition at line 4561 of file json.hpp.

    @@ -290,7 +290,7 @@ null diff --git a/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html b/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html index 9112a1135..59c0d987d 100644 --- a/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html +++ b/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html @@ -280,7 +280,7 @@ template<class CompatibleArrayType , typename std::enable_if<
    -
    Example
    The following code shows the constructor with several compatible array type parameters.
    1 #include <json.hpp>
    2 #include <deque>
    3 #include <list>
    4 #include <forward_list>
    5 #include <set>
    6 #include <unordered_set>
    7 
    8 using json = nlohmann::json;
    9 
    10 int main()
    11 {
    12  // create an array from std::vector
    13  std::vector<int> c_vector {1, 2, 3, 4};
    14  json j_vec(c_vector);
    15 
    16  // create an array from std::deque
    17  std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
    18  json j_deque(c_deque);
    19 
    20  // create an array from std::list
    21  std::list<bool> c_list {true, true, false, true};
    22  json j_list(c_list);
    23 
    24  // create an array from std::forward_list
    25  std::forward_list<int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
    26  json j_flist(c_flist);
    27 
    28  // create an array from std::array
    29  std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
    30  json j_array(c_array);
    31 
    32  // create an array from std::set
    33  std::set<std::string> c_set {"one", "two", "three", "four", "one"};
    34  json j_set(c_set); // only one entry for "one" is used
    35 
    36  // create an array from std::unordered_set
    37  std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
    38  json j_uset(c_uset); // only one entry for "one" is used
    39 
    40  // create an array from std::multiset
    41  std::multiset<std::string> c_mset {"one", "two", "one", "four"};
    42  json j_mset(c_mset); // only one entry for "one" is used
    43 
    44  // create an array from std::unordered_multiset
    45  std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
    46  json j_umset(c_umset); // both entries for "one" are used
    47 
    48  // serialize the JSON arrays
    49  std::cout << j_vec << '\n';
    50  std::cout << j_deque << '\n';
    51  std::cout << j_list << '\n';
    52  std::cout << j_flist << '\n';
    53  std::cout << j_array << '\n';
    54  std::cout << j_set << '\n';
    55  std::cout << j_uset << '\n';
    56  std::cout << j_mset << '\n';
    57  std::cout << j_umset << '\n';
    58 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the constructor with several compatible array type parameters.
    1 #include <json.hpp>
    2 #include <deque>
    3 #include <list>
    4 #include <forward_list>
    5 #include <set>
    6 #include <unordered_set>
    7 
    8 using json = nlohmann::json;
    9 
    10 int main()
    11 {
    12  // create an array from std::vector
    13  std::vector<int> c_vector {1, 2, 3, 4};
    14  json j_vec(c_vector);
    15 
    16  // create an array from std::deque
    17  std::deque<double> c_deque {1.2, 2.3, 3.4, 5.6};
    18  json j_deque(c_deque);
    19 
    20  // create an array from std::list
    21  std::list<bool> c_list {true, true, false, true};
    22  json j_list(c_list);
    23 
    24  // create an array from std::forward_list
    25  std::forward_list<int64_t> c_flist {12345678909876, 23456789098765, 34567890987654, 45678909876543};
    26  json j_flist(c_flist);
    27 
    28  // create an array from std::array
    29  std::array<unsigned long, 4> c_array {{1, 2, 3, 4}};
    30  json j_array(c_array);
    31 
    32  // create an array from std::set
    33  std::set<std::string> c_set {"one", "two", "three", "four", "one"};
    34  json j_set(c_set); // only one entry for "one" is used
    35 
    36  // create an array from std::unordered_set
    37  std::unordered_set<std::string> c_uset {"one", "two", "three", "four", "one"};
    38  json j_uset(c_uset); // only one entry for "one" is used
    39 
    40  // create an array from std::multiset
    41  std::multiset<std::string> c_mset {"one", "two", "one", "four"};
    42  json j_mset(c_mset); // only one entry for "one" is used
    43 
    44  // create an array from std::unordered_multiset
    45  std::unordered_multiset<std::string> c_umset {"one", "two", "one", "four"};
    46  json j_umset(c_umset); // both entries for "one" are used
    47 
    48  // serialize the JSON arrays
    49  std::cout << j_vec << '\n';
    50  std::cout << j_deque << '\n';
    51  std::cout << j_list << '\n';
    52  std::cout << j_flist << '\n';
    53  std::cout << j_array << '\n';
    54  std::cout << j_set << '\n';
    55  std::cout << j_uset << '\n';
    56  std::cout << j_mset << '\n';
    57  std::cout << j_umset << '\n';
    58 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3,4]
     [1.2,2.3,3.4,5.6]
     [true,true,false,true]
    @@ -294,7 +294,7 @@ template<class CompatibleArrayType , typename std::enable_if<
     
    See also
    basic_json(const array_t&) – create an array value
    Since
    version 1.0.0
    -

    Definition at line 1134 of file json.hpp.

    +

    Definition at line 1108 of file json.hpp.

    @@ -304,7 +304,7 @@ template<class CompatibleArrayType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html b/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html index 1928460ea..5e1fdb081 100644 --- a/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html +++ b/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html @@ -273,14 +273,14 @@ use swap() with string"
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json value = {{"array", {1, 2, 3, 4}}};
    9 
    10  // create an array_t
    11  json::array_t array = {"Snap", "Crackle", "Pop"};
    12 
    13  // swap the array stored in the JSON value
    14  value["array"].swap(array);
    15 
    16  // output the values
    17  std::cout << "value = " << value << '\n';
    18  std::cout << "array = " << array << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:400
    +
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json value = {{"array", {1, 2, 3, 4}}};
    9 
    10  // create an array_t
    11  json::array_t array = {"Snap", "Crackle", "Pop"};
    12 
    13  // swap the array stored in the JSON value
    14  value["array"].swap(array);
    15 
    16  // output the values
    17  std::cout << "value = " << value << '\n';
    18  std::cout << "array = " << array << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:374
    Output (play with this example online):
    value = {"array":["Snap","Crackle","Pop"]}
     array = [1,2,3,4]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/swap__array_t.cpp -o swap__array_t 
    Since
    version 1.0.0
    -

    Definition at line 4901 of file json.hpp.

    +

    Definition at line 4875 of file json.hpp.

    @@ -290,7 +290,7 @@ array = [1,2,3,4] diff --git a/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html b/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html index d64e3bdf2..40fe91454 100644 --- a/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html +++ b/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html @@ -285,13 +285,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant plus linear in the distance between pos and end of the container.
    -
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert number 10 before number 3
    11  auto new_pos = v.insert(v.begin() + 2, 10);
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert number 10 before number 3
    11  auto new_pos = v.insert(v.begin() + 2, 10);
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    10
     [1,2,10,3,4]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/insert.cpp -o insert 
    Since
    version 1.0.0
    -

    Definition at line 4692 of file json.hpp.

    +

    Definition at line 4666 of file json.hpp.

    @@ -301,7 +301,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html b/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html index e525079a8..af8d91c7a 100644 --- a/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html +++ b/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html @@ -273,14 +273,14 @@ use swap() with boolean"
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json value = { "the good", "the bad", "the ugly" };
    9 
    10  // create string_t
    11  json::string_t string = "the fast";
    12 
    13  // swap the object stored in the JSON value
    14  value[1].swap(string);
    15 
    16  // output the values
    17  std::cout << "value = " << value << '\n';
    18  std::cout << "string = " << string << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    StringType string_t
    a type for a string
    Definition: json.hpp:447
    +
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json value = { "the good", "the bad", "the ugly" };
    9 
    10  // create string_t
    11  json::string_t string = "the fast";
    12 
    13  // swap the object stored in the JSON value
    14  value[1].swap(string);
    15 
    16  // output the values
    17  std::cout << "value = " << value << '\n';
    18  std::cout << "string = " << string << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    StringType string_t
    a type for a string
    Definition: json.hpp:421
    Output (play with this example online):
    value = ["the good","the fast","the ugly"]
     string = the bad
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/swap__string_t.cpp -o swap__string_t 
    Since
    version 1.0.0
    -

    Definition at line 4969 of file json.hpp.

    +

    Definition at line 4943 of file json.hpp.

    @@ -290,7 +290,7 @@ string = the bad diff --git a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html index eaa27fdb1..0b1667dec 100644 --- a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html +++ b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether lhs is greater than to rhs
    Complexity
    Linear.
    -
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " <= " << array_2 << " " << (array_1 <= array_2) << '\n';
    20  std::cout << object_1 << " <= " << object_2 << " " << (object_1 <= object_2) << '\n';
    21  std::cout << number_1 << " <= " << number_2 << " " << (number_1 <= number_2) << '\n';
    22  std::cout << string_1 << " <= " << string_2 << " " << (string_1 <= string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " <= " << array_2 << " " << (array_1 <= array_2) << '\n';
    20  std::cout << object_1 << " <= " << object_2 << " " << (object_1 <= object_2) << '\n';
    21  std::cout << number_1 << " <= " << number_2 << " " << (number_1 <= number_2) << '\n';
    22  std::cout << string_1 << " <= " << string_2 << " " << (string_1 <= string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3] <= [1,2,4] true
     {"A":"a","B":"b"} <= {"A":"a","B":"b"} true
     17 <= 17.0000000000001 true
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__lessequal.cpp -o operator__lessequal 
    Since
    version 1.0.0
    -

    Definition at line 5363 of file json.hpp.

    +

    Definition at line 5337 of file json.hpp.

    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a8969119432218155193bb1dac30aa4ff.html b/classnlohmann_1_1basic__json_a8969119432218155193bb1dac30aa4ff.html index caf94aaa5..dcf1cbbe5 100644 --- a/classnlohmann_1_1basic__json_a8969119432218155193bb1dac30aa4ff.html +++ b/classnlohmann_1_1basic__json_a8969119432218155193bb1dac30aa4ff.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is an object.

    Returns
    true if type is object, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_object for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_object()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_object() << '\n';
    20  std::cout << j_boolean.is_object() << '\n';
    21  std::cout << j_number_integer.is_object() << '\n';
    22  std::cout << j_number_unsigned_integer.is_object() << '\n';
    23  std::cout << j_number_float.is_object() << '\n';
    24  std::cout << j_object.is_object() << '\n';
    25  std::cout << j_array.is_object() << '\n';
    26  std::cout << j_string.is_object() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_object for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_object()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_object() << '\n';
    20  std::cout << j_boolean.is_object() << '\n';
    21  std::cout << j_number_integer.is_object() << '\n';
    22  std::cout << j_number_unsigned_integer.is_object() << '\n';
    23  std::cout << j_number_float.is_object() << '\n';
    24  std::cout << j_object.is_object() << '\n';
    25  std::cout << j_array.is_object() << '\n';
    26  std::cout << j_string.is_object() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -272,7 +272,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_object.cpp -o is_object 
    Since
    version 1.0.0
    -

    Definition at line 2289 of file json.hpp.

    +

    Definition at line 2263 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html b/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html index ca6bc2aa5..978add563 100644 --- a/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html +++ b/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html @@ -288,7 +288,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows the constructor for different value_t values
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create the different JSON values with default values
    9  json j_boolean(json::value_t::boolean);
    10  json j_number_integer(json::value_t::number_integer);
    11  json j_number_float(json::value_t::number_float);
    12  json j_object(json::value_t::object);
    13  json j_array(json::value_t::array);
    14  json j_string(json::value_t::string);
    15 
    16  // serialize the JSON values
    17  std::cout << j_null << '\n';
    18  std::cout << j_boolean << '\n';
    19  std::cout << j_number_integer << '\n';
    20  std::cout << j_number_float << '\n';
    21  std::cout << j_object << '\n';
    22  std::cout << j_array << '\n';
    23  std::cout << j_string << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the constructor for different value_t values
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create the different JSON values with default values
    9  json j_boolean(json::value_t::boolean);
    10  json j_number_integer(json::value_t::number_integer);
    11  json j_number_float(json::value_t::number_float);
    12  json j_object(json::value_t::object);
    13  json j_array(json::value_t::array);
    14  json j_string(json::value_t::string);
    15 
    16  // serialize the JSON values
    17  std::cout << j_null << '\n';
    18  std::cout << j_boolean << '\n';
    19  std::cout << j_number_integer << '\n';
    20  std::cout << j_number_float << '\n';
    21  std::cout << j_object << '\n';
    22  std::cout << j_array << '\n';
    23  std::cout << j_string << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    @@ -321,7 +321,7 @@ false basic_json(const number_unsigned_t) – create a number (unsigned) value
    Since
    version 1.0.0
    -

    Definition at line 971 of file json.hpp.

    +

    Definition at line 945 of file json.hpp.

    @@ -331,7 +331,7 @@ false diff --git a/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html b/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html index fc2a8c4bf..f7123ac56 100644 --- a/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html +++ b/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html @@ -281,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
  • Has the semantics of begin() == end().
  • -
    Example
    The following code uses empty to check if a json object contains any elements.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call empty()
    19  std::cout << std::boolalpha;
    20  std::cout << j_null.empty() << '\n';
    21  std::cout << j_boolean.empty() << '\n';
    22  std::cout << j_number_integer.empty() << '\n';
    23  std::cout << j_number_float.empty() << '\n';
    24  std::cout << j_object.empty() << '\n';
    25  std::cout << j_object_empty.empty() << '\n';
    26  std::cout << j_array.empty() << '\n';
    27  std::cout << j_array_empty.empty() << '\n';
    28  std::cout << j_string.empty() << '\n';
    29 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code uses empty to check if a json object contains any elements.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call empty()
    19  std::cout << std::boolalpha;
    20  std::cout << j_null.empty() << '\n';
    21  std::cout << j_boolean.empty() << '\n';
    22  std::cout << j_number_integer.empty() << '\n';
    23  std::cout << j_number_float.empty() << '\n';
    24  std::cout << j_object.empty() << '\n';
    25  std::cout << j_object_empty.empty() << '\n';
    26  std::cout << j_array.empty() << '\n';
    27  std::cout << j_array_empty.empty() << '\n';
    28  std::cout << j_string.empty() << '\n';
    29 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -296,7 +296,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/empty.cpp -o empty 
    Since
    version 1.0.0
    -

    Definition at line 4272 of file json.hpp.

    +

    Definition at line 4246 of file json.hpp.

    @@ -306,7 +306,7 @@ false diff --git a/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html b/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html index 98a373139..db089c020 100644 --- a/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html +++ b/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    2
     
     {
    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3223 of file json.hpp.

    +

    Definition at line 3197 of file json.hpp.

    @@ -310,7 +310,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html b/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html index 14d5856d2..1f2ee9924 100644 --- a/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html +++ b/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html @@ -266,7 +266,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    -

    Definition at line 1988 of file json.hpp.

    +

    Definition at line 1962 of file json.hpp.

    @@ -276,7 +276,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html b/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html index 76e84ae35..98b702b4b 100644 --- a/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html +++ b/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Logarithmic in the size of the container, O(log(size())).
    -
    Example
    The example shows how push_back and += can be used to add elements to a JSON object. Note how the null value was silently converted to a JSON object.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json object = {{"one", 1}, {"two", 2}};
    9  json null;
    10 
    11  // print values
    12  std::cout << object << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  object.push_back(json::object_t::value_type("three", 3));
    17  object += json::object_t::value_type("four", 4);
    18  null += json::object_t::value_type("A", "a");
    19  null += json::object_t::value_type("B", "b");
    20 
    21  // print values
    22  std::cout << object << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how push_back and += can be used to add elements to a JSON object. Note how the null value was silently converted to a JSON object.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json object = {{"one", 1}, {"two", 2}};
    9  json null;
    10 
    11  // print values
    12  std::cout << object << '\n';
    13  std::cout << null << '\n';
    14 
    15  // add values
    16  object.push_back(json::object_t::value_type("three", 3));
    17  object += json::object_t::value_type("four", 4);
    18  null += json::object_t::value_type("A", "a");
    19  null += json::object_t::value_type("B", "b");
    20 
    21  // print values
    22  std::cout << object << '\n';
    23  std::cout << null << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -280,7 +280,7 @@ null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back__object_t__value.cpp -o push_back__object_t__value 
    Since
    version 1.0.0
    -

    Definition at line 4637 of file json.hpp.

    +

    Definition at line 4611 of file json.hpp.

    @@ -290,7 +290,7 @@ null diff --git a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html index a1d770542..8809057da 100644 --- a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html +++ b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether v is null
    Complexity
    Constant.
    Example
    The example compares several JSON types to the null pointer.
    -
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " == nullptr " << (array == nullptr) << '\n';
    17  std::cout << object << " == nullptr " << (object == nullptr) << '\n';
    18  std::cout << number << " == nullptr " << (number == nullptr) << '\n';
    19  std::cout << string << " == nullptr " << (string == nullptr) << '\n';
    20  std::cout << null << " == nullptr " << (null == nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " == nullptr " << (array == nullptr) << '\n';
    17  std::cout << object << " == nullptr " << (object == nullptr) << '\n';
    18  std::cout << number << " == nullptr " << (number == nullptr) << '\n';
    19  std::cout << string << " == nullptr " << (string == nullptr) << '\n';
    20  std::cout << null << " == nullptr " << (null == nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481

    Output (play with this example online):

    [1,2,3] == nullptr false
     {"A":"a","B":"b"} == nullptr false
     17 == nullptr false
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     null == nullptr true
     

    The example code above can be translated with

    g++ -std=c++11 -Isrc doc/examples/operator__equal__nullptr_t.cpp -o operator__equal__nullptr_t 
    Since
    version 1.0.0
    -

    Definition at line 5149 of file json.hpp.

    +

    Definition at line 5123 of file json.hpp.

    @@ -296,7 +296,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html index 086a677a4..af0a15e02 100644 --- a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html +++ b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether v is null
    Complexity
    Constant.
    Example
    The example compares several JSON types to the null pointer.
    -
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " == nullptr " << (array == nullptr) << '\n';
    17  std::cout << object << " == nullptr " << (object == nullptr) << '\n';
    18  std::cout << number << " == nullptr " << (number == nullptr) << '\n';
    19  std::cout << string << " == nullptr " << (string == nullptr) << '\n';
    20  std::cout << null << " == nullptr " << (null == nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " == nullptr " << (array == nullptr) << '\n';
    17  std::cout << object << " == nullptr " << (object == nullptr) << '\n';
    18  std::cout << number << " == nullptr " << (number == nullptr) << '\n';
    19  std::cout << string << " == nullptr " << (string == nullptr) << '\n';
    20  std::cout << null << " == nullptr " << (null == nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481

    Output (play with this example online):

    [1,2,3] == nullptr false
     {"A":"a","B":"b"} == nullptr false
     17 == nullptr false
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     null == nullptr true
     

    The example code above can be translated with

    g++ -std=c++11 -Isrc doc/examples/operator__equal__nullptr_t.cpp -o operator__equal__nullptr_t 
    Since
    version 1.0.0
    -

    Definition at line 5158 of file json.hpp.

    +

    Definition at line 5132 of file json.hpp.

    @@ -296,7 +296,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html b/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html index 20dbffc1c..9f5d96ca2 100644 --- a/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html +++ b/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html @@ -274,12 +274,12 @@ operator[] with null"
    Complexity
    Constant.
    -
    Example
    The example below shows how array elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON array
    8  json array = {"first", "2nd", "third", "fourth"};
    9 
    10  // output element at index 2 (third element)
    11  std::cout << array.at(2) << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how array elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON array
    8  json array = {"first", "2nd", "third", "fourth"};
    9 
    10  // output element at index 2 (third element)
    11  std::cout << array.at(2) << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "third"
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__size_type_const.cpp -o operatorarray__size_type_const 
    Since
    version 1.0.0
    -

    Definition at line 3182 of file json.hpp.

    +

    Definition at line 3156 of file json.hpp.

    @@ -289,7 +289,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html b/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html index 8a26951f1..838dc17d4 100644 --- a/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html +++ b/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html @@ -272,14 +272,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows the constructor with an object_t parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an object_t value
    8  json::object_t value = { {"one", 1}, {"two", 2} };
    9 
    10  // create a JSON object from the value
    11  json j(value);
    12 
    13  // serialize the JSON object
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:354
    +
    Example
    The following code shows the constructor with an object_t parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an object_t value
    8  json::object_t value = { {"one", 1}, {"two", 2} };
    9 
    10  // create a JSON object from the value
    11  json j(value);
    12 
    13  // serialize the JSON object
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:328
    Output (play with this example online):
    {"one":1,"two":2}
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__object_t.cpp -o basic_json__object_t 
    See also
    basic_json(const CompatibleObjectType&) – create an object value from a compatible STL container
    Since
    version 1.0.0
    -

    Definition at line 1038 of file json.hpp.

    +

    Definition at line 1012 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a9c01092601b6229eee4f971aad263133.html b/classnlohmann_1_1basic__json_a9c01092601b6229eee4f971aad263133.html index abfa26be1..529a415c5 100644 --- a/classnlohmann_1_1basic__json_a9c01092601b6229eee4f971aad263133.html +++ b/classnlohmann_1_1basic__json_a9c01092601b6229eee4f971aad263133.html @@ -268,13 +268,13 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).rbegin().
  • -
    Example
    The following code shows an example for crbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-beginning
    11  json::const_reverse_iterator it = array.crbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:247
    +
    Example
    The following code shows an example for crbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-beginning
    11  json::const_reverse_iterator it = array.crbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:221
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crbegin.cpp -o crbegin 
    Since
    version 1.0.0
    -

    Definition at line 4122 of file json.hpp.

    +

    Definition at line 4096 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html b/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html index e5c0da56d..ee8b3624a 100644 --- a/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html +++ b/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 233 of file json.hpp.

    +

    Definition at line 207 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html b/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html index 7e6bce53d..2f6b496ec 100644 --- a/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html +++ b/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html @@ -281,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    See also
    parse(std::istream&, parser_callback_t) or parse(const string_t&, parser_callback_t) for examples
    Since
    version 1.0.0
    -

    Definition at line 922 of file json.hpp.

    +

    Definition at line 896 of file json.hpp.

    @@ -291,7 +291,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html b/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html index 21257091c..29834b490 100644 --- a/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html +++ b/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html @@ -273,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    log(size()) + count(key)
    -
    Example
    The example shows the effect of erase.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call erase
    11  auto count_one = j_object.erase("one");
    12  auto count_three = j_object.erase("three");
    13 
    14  // print values
    15  std::cout << j_object << '\n';
    16  std::cout << count_one << " " << count_three << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows the effect of erase.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call erase
    11  auto count_one = j_object.erase("one");
    12  auto count_three = j_object.erase("three");
    13 
    14  // print values
    15  std::cout << j_object << '\n';
    16  std::cout << count_one << " " << count_three << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"two":2}
     1 0
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/erase__key_type.cpp -o erase__key_type 
    @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3840 of file json.hpp.

    +

    Definition at line 3814 of file json.hpp.

    @@ -294,7 +294,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html b/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html index 1d63630b9..11ad0775d 100644 --- a/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html +++ b/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 230 of file json.hpp.

    +

    Definition at line 204 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html b/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html index 076d466b5..dbeb628e9 100644 --- a/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html +++ b/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for front.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for front.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/front.cpp -o front 
    Since
    version 1.0.0
    -

    Definition at line 3549 of file json.hpp.

    +

    Definition at line 3523 of file json.hpp.

    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html b/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html index 2e80c5948..174cdce17 100644 --- a/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html +++ b/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html @@ -275,15 +275,15 @@ template<typename ReferenceType , typename std::enable_if<
    Complexity
    Constant.
    -
    Example
    The example shows several calls to get_ref().
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting references
    11  auto r1 = value.get_ref<const json::number_integer_t&>();
    12  auto r2 = value.get_ref<json::number_integer_t&>();
    13 
    14  // print the values
    15  std::cout << r1 << ' ' << r2 << '\n';
    16 
    17  // incompatible type throws exception
    18  try
    19  {
    20  auto r3 = value.get_ref<json::number_float_t&>();
    21  }
    22  catch (std::domain_error& ex)
    23  {
    24  std::cout << ex.what() << '\n';
    25  }
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The example shows several calls to get_ref().
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting references
    11  auto r1 = value.get_ref<const json::number_integer_t&>();
    12  auto r2 = value.get_ref<json::number_integer_t&>();
    13 
    14  // print the values
    15  std::cout << r1 << ' ' << r2 << '\n';
    16 
    17  // incompatible type throws exception
    18  try
    19  {
    20  auto r3 = value.get_ref<json::number_float_t&>();
    21  }
    22  catch (std::domain_error& ex)
    23  {
    24  std::cout << ex.what() << '\n';
    25  }
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    17 17
     incompatible ReferenceType for get_ref, actual type is number
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ref.cpp -o get_ref 
    Since
    version 1.1.0
    -

    Definition at line 2870 of file json.hpp.

    +

    Definition at line 2844 of file json.hpp.

    @@ -293,7 +293,7 @@ incompatible ReferenceType for get_ref, actual type is number diff --git a/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html b/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html index 2443e3005..d896268ea 100644 --- a/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html +++ b/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html @@ -277,7 +277,7 @@ operator[] with null"
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  const json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  const json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    2
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__key_type_const.cpp -o operatorarray__key_type_const 
    See also
    at(const typename object_t::key_type&) for access by reference with range checking
    @@ -285,7 +285,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.1.0
    -

    Definition at line 3431 of file json.hpp.

    +

    Definition at line 3405 of file json.hpp.

    @@ -295,7 +295,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html b/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html index 13e478aeb..26f2496ae 100644 --- a/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html +++ b/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html @@ -267,14 +267,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    Iterator to an element with key equivalent to key. If no such element is found, past-the-end (see end()) iterator is returned.
    Complexity
    Logarithmic in the size of the JSON object.
    -
    Example
    The example shows how find is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call find
    11  auto it_two = j_object.find("two");
    12  auto it_three = j_object.find("three");
    13 
    14  // print values
    15  std::cout << std::boolalpha;
    16  std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
    17  std::cout << "value at key \"two\": " << *it_two << '\n';
    18  std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how find is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call find
    11  auto it_two = j_object.find("two");
    12  auto it_three = j_object.find("three");
    13 
    14  // print values
    15  std::cout << std::boolalpha;
    16  std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
    17  std::cout << "value at key \"two\": " << *it_two << '\n';
    18  std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "two" was found: true
     value at key "two": 2
     "three" was found: false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/find__key_type.cpp -o find__key_type 
    Since
    version 1.0.0
    -

    Definition at line 3931 of file json.hpp.

    +

    Definition at line 3905 of file json.hpp.

    @@ -284,7 +284,7 @@ value at key "two": 2 diff --git a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html index d44f7ee46..87d9dcd88 100644 --- a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html +++ b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    -

    Definition at line 5003 of file json.hpp.

    +

    Definition at line 4977 of file json.hpp.

    @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html index 835e49802..3b591ebfb 100644 --- a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html +++ b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html @@ -282,7 +282,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether lhs is less than rhs
    Complexity
    Linear.
    -
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 < array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 < object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 < number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 < string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array_1 = {1, 2, 3};
    9  json array_2 = {1, 2, 4};
    10  json object_1 = {{"A", "a"}, {"B", "b"}};
    11  json object_2 = {{"B", "b"}, {"A", "a"}};
    12  json number_1 = 17;
    13  json number_2 = 17.0000000000001L;
    14  json string_1 = "foo";
    15  json string_2 = "bar";
    16 
    17  // output values and comparisons
    18  std::cout << std::boolalpha;
    19  std::cout << array_1 << " == " << array_2 << " " << (array_1 < array_2) << '\n';
    20  std::cout << object_1 << " == " << object_2 << " " << (object_1 < object_2) << '\n';
    21  std::cout << number_1 << " == " << number_2 << " " << (number_1 < number_2) << '\n';
    22  std::cout << string_1 << " == " << string_2 << " " << (string_1 < string_2) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    [1,2,3] == [1,2,4] true
     {"A":"a","B":"b"} == {"A":"a","B":"b"} false
     17 == 17.0000000000001 true
    @@ -290,7 +290,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__less.cpp -o operator__less 
    Since
    version 1.0.0
    -

    Definition at line 5240 of file json.hpp.

    +

    Definition at line 5214 of file json.hpp.

    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html b/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html index da8189da7..6f838b475 100644 --- a/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html +++ b/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html @@ -285,13 +285,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    iterator pointing to the first element inserted, or pos if ilist is empty
    Complexity
    Linear in ilist.size() plus linear in the distance between pos and end of the container.
    -
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert range from v2 before the end of array v
    11  auto new_pos = v.insert(v.end(), {7, 8, 9});
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // insert range from v2 before the end of array v
    11  auto new_pos = v.insert(v.end(), {7, 8, 9});
    12 
    13  // output new array and result of insert call
    14  std::cout << *new_pos << '\n';
    15  std::cout << v << '\n';
    16 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    7
     [1,2,3,4,7,8,9]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/insert__ilist.cpp -o insert__ilist 
    Since
    version 1.0.0
    -

    Definition at line 4832 of file json.hpp.

    +

    Definition at line 4806 of file json.hpp.

    @@ -301,7 +301,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html index b2cc8ac6b..82b629d42 100644 --- a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html +++ b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in the length of the input. The parser is a predictive LL(1) parser.
    Note
    A UTF-8 byte order mark is silently ignored.
    -
    Example
    The example below shows how a JSON value is constructed by reading a serialization from a stream.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create stream with serialized JSON
    8  std::stringstream ss;
    9  ss << R"({
    10  "number": 23,
    11  "string": "Hello, world!",
    12  "array": [1, 2, 3, 4, 5],
    13  "boolean": false,
    14  "null": null
    15  })";
    16 
    17  // create JSON value and read the serialization from the stream
    18  json j;
    19  j << ss;
    20 
    21  // serialize JSON
    22  std::cout << std::setw(2) << j << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how a JSON value is constructed by reading a serialization from a stream.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create stream with serialized JSON
    8  std::stringstream ss;
    9  ss << R"({
    10  "number": 23,
    11  "string": "Hello, world!",
    12  "array": [1, 2, 3, 4, 5],
    13  "boolean": false,
    14  "null": null
    15  })";
    16 
    17  // create JSON value and read the serialization from the stream
    18  json j;
    19  j << ss;
    20 
    21  // serialize JSON
    22  std::cout << std::setw(2) << j << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -302,7 +302,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    parse(std::istream&, parser_callback_t) for a variant with a parser callback function to filter values while parsing
    Since
    version 1.0.0
    -

    Definition at line 5554 of file json.hpp.

    +

    Definition at line 5528 of file json.hpp.

    @@ -312,7 +312,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html b/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html index 5aff9f1af..4fbfc64ed 100644 --- a/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html +++ b/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html @@ -269,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    See also
    object_t – type for an object value
    Since
    version 1.0.0
    -

    Definition at line 400 of file json.hpp.

    +

    Definition at line 374 of file json.hpp.

    @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab31368c0b67f8e4f291a45e6498018be.html b/classnlohmann_1_1basic__json_ab31368c0b67f8e4f291a45e6498018be.html index ef73816f2..b41755aab 100644 --- a/classnlohmann_1_1basic__json_ab31368c0b67f8e4f291a45e6498018be.html +++ b/classnlohmann_1_1basic__json_ab31368c0b67f8e4f291a45e6498018be.html @@ -274,13 +274,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how array elements can be read using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON array
    8  json array = {"first", "2nd", "third", "fourth"};
    9 
    10  // output element at index 2 (third element)
    11  std::cout << array.at(2) << '\n';
    12 
    13  // try to read beyond the array limit
    14  try
    15  {
    16  std::cout << array.at(5) << '\n';
    17  }
    18  catch (std::out_of_range)
    19  {
    20  std::cout << "out of range" << '\n';
    21  }
    22 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how array elements can be read using at.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON array
    8  json array = {"first", "2nd", "third", "fourth"};
    9 
    10  // output element at index 2 (third element)
    11  std::cout << array.at(2) << '\n';
    12 
    13  // try to read beyond the array limit
    14  try
    15  {
    16  std::cout << array.at(5) << '\n';
    17  }
    18  catch (std::out_of_range)
    19  {
    20  std::cout << "out of range" << '\n';
    21  }
    22 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "third"
     out of range
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/at__size_type_const.cpp -o at__size_type_const 
    Since
    version 1.0.0
    -

    Definition at line 2994 of file json.hpp.

    +

    Definition at line 2968 of file json.hpp.

    @@ -290,7 +290,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html b/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html index 7bef2dc6c..789faa6fa 100644 --- a/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html +++ b/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    String values are stored as pointers in a basic_json type. That is, for any access to string values, a pointer of type string_t* must be dereferenced.

    Since
    version 1.0.0
    -

    Definition at line 447 of file json.hpp.

    +

    Definition at line 421 of file json.hpp.

    @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab7b7b44891ddbc2df8ba3cbef3609178.html b/classnlohmann_1_1basic__json_ab7b7b44891ddbc2df8ba3cbef3609178.html index 74bb455f1..1096851ff 100644 --- a/classnlohmann_1_1basic__json_ab7b7b44891ddbc2df8ba3cbef3609178.html +++ b/classnlohmann_1_1basic__json_ab7b7b44891ddbc2df8ba3cbef3609178.html @@ -269,16 +269,16 @@ template<typename PointerType , typename std::enable_if<
    Returns
    pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise
    Complexity
    Constant.
    -
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get<const json::number_integer_t*>();
    12  auto p2 = value.get<json::number_integer_t*>();
    13  auto p3 = value.get<json::number_integer_t* const>();
    14  auto p4 = value.get<const json::number_integer_t* const>();
    15  auto p5 = value.get<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get<const json::number_integer_t*>();
    12  auto p2 = value.get<json::number_integer_t*>();
    13  auto p3 = value.get<json::number_integer_t* const>();
    14  auto p4 = value.get<const json::number_integer_t* const>();
    15  auto p5 = value.get<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get__PointerType.cpp -o get__PointerType 
    See also
    get_ptr() for explicit pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2769 of file json.hpp.

    +

    Definition at line 2743 of file json.hpp.

    @@ -288,7 +288,7 @@ true diff --git a/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html b/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html index 3a789fa3e..6e5cd898d 100644 --- a/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html +++ b/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html @@ -280,7 +280,7 @@ template<class CompatibleObjectType , typename std::enable_if<
    -
    Example
    The following code shows the constructor with several compatible object type parameters.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using json = nlohmann::json;
    5 
    6 int main()
    7 {
    8  // create an object from std::map
    9  std::map<std::string, int> c_map
    10  {
    11  {"one", 1}, {"two", 2}, {"three", 3}
    12  };
    13  json j_map(c_map);
    14 
    15  // create an object from std::unordered_map
    16  std::unordered_map<const char*, double> c_umap
    17  {
    18  {"one", 1.2}, {"two", 2.3}, {"three", 3.4}
    19  };
    20  json j_umap(c_umap);
    21 
    22  // create an object from std::multimap
    23  std::multimap<std::string, bool> c_mmap
    24  {
    25  {"one", true}, {"two", true}, {"three", false}, {"three", true}
    26  };
    27  json j_mmap(c_mmap); // only one entry for key "three" is used
    28 
    29  // create an object from std::unordered_multimap
    30  std::unordered_multimap<std::string, bool> c_ummap
    31  {
    32  {"one", true}, {"two", true}, {"three", false}, {"three", true}
    33  };
    34  json j_ummap(c_ummap); // only one entry for key "three" is used
    35 
    36  // serialize the JSON objects
    37  std::cout << j_map << '\n';
    38  std::cout << j_umap << '\n';
    39  std::cout << j_mmap << '\n';
    40  std::cout << j_ummap << '\n';
    41 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the constructor with several compatible object type parameters.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using json = nlohmann::json;
    5 
    6 int main()
    7 {
    8  // create an object from std::map
    9  std::map<std::string, int> c_map
    10  {
    11  {"one", 1}, {"two", 2}, {"three", 3}
    12  };
    13  json j_map(c_map);
    14 
    15  // create an object from std::unordered_map
    16  std::unordered_map<const char*, double> c_umap
    17  {
    18  {"one", 1.2}, {"two", 2.3}, {"three", 3.4}
    19  };
    20  json j_umap(c_umap);
    21 
    22  // create an object from std::multimap
    23  std::multimap<std::string, bool> c_mmap
    24  {
    25  {"one", true}, {"two", true}, {"three", false}, {"three", true}
    26  };
    27  json j_mmap(c_mmap); // only one entry for key "three" is used
    28 
    29  // create an object from std::unordered_multimap
    30  std::unordered_multimap<std::string, bool> c_ummap
    31  {
    32  {"one", true}, {"two", true}, {"three", false}, {"three", true}
    33  };
    34  json j_ummap(c_ummap); // only one entry for key "three" is used
    35 
    36  // serialize the JSON objects
    37  std::cout << j_map << '\n';
    38  std::cout << j_umap << '\n';
    39  std::cout << j_mmap << '\n';
    40  std::cout << j_ummap << '\n';
    41 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {"one":1,"three":3,"two":2}
     {"one":1.2,"three":3.4,"two":2.3}
     {"one":true,"three":false,"two":true}
    @@ -289,7 +289,7 @@ template<class CompatibleObjectType , typename std::enable_if<
     
    See also
    basic_json(const object_t&) – create an object value
    Since
    version 1.0.0
    -

    Definition at line 1070 of file json.hpp.

    +

    Definition at line 1044 of file json.hpp.

    @@ -299,7 +299,7 @@ template<class CompatibleObjectType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_ab7d704826813d13731fbcaf220160826.html b/classnlohmann_1_1basic__json_ab7d704826813d13731fbcaf220160826.html index e93bb60cb..1d1846486 100644 --- a/classnlohmann_1_1basic__json_ab7d704826813d13731fbcaf220160826.html +++ b/classnlohmann_1_1basic__json_ab7d704826813d13731fbcaf220160826.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is an unsigned integer number. This excludes floating-point and (signed) integer values.

    Returns
    true if type is an unsigned integer number, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number_unsigned for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number_unsigned()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number_unsigned() << '\n';
    20  std::cout << j_boolean.is_number_unsigned() << '\n';
    21  std::cout << j_number_integer.is_number_unsigned() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n';
    23  std::cout << j_number_float.is_number_unsigned() << '\n';
    24  std::cout << j_object.is_number_unsigned() << '\n';
    25  std::cout << j_array.is_number_unsigned() << '\n';
    26  std::cout << j_string.is_number_unsigned() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_number_unsigned for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_unsigned_integer = 12345678987654321u;
    12  json j_number_float = 23.42;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_number_unsigned()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_number_unsigned() << '\n';
    20  std::cout << j_boolean.is_number_unsigned() << '\n';
    21  std::cout << j_number_integer.is_number_unsigned() << '\n';
    22  std::cout << j_number_unsigned_integer.is_number_unsigned() << '\n';
    23  std::cout << j_number_float.is_number_unsigned() << '\n';
    24  std::cout << j_object.is_number_unsigned() << '\n';
    25  std::cout << j_array.is_number_unsigned() << '\n';
    26  std::cout << j_string.is_number_unsigned() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -277,7 +277,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 2.0.0
    -

    Definition at line 2245 of file json.hpp.

    +

    Definition at line 2219 of file json.hpp.

    @@ -287,7 +287,7 @@ false diff --git a/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html b/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html index 17de7785b..a9feb3532 100644 --- a/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html +++ b/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html @@ -278,11 +278,11 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    result of the deserialization
    Complexity
    Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser callback function cb has a super-linear complexity.
    Note
    A UTF-8 byte order mark is silently ignored.
    -
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // a JSON text
    8  auto text = R"(
    9  {
    10  "Image": {
    11  "Width": 800,
    12  "Height": 600,
    13  "Title": "View from 15th Floor",
    14  "Thumbnail": {
    15  "Url": "http://www.example.com/image/481989943",
    16  "Height": 125,
    17  "Width": 100
    18  },
    19  "Animated" : false,
    20  "IDs": [116, 943, 234, 38793]
    21  }
    22  }
    23  )";
    24 
    25  // fill a stream with JSON text
    26  std::stringstream ss;
    27  ss << text;
    28 
    29  // parse and serialize JSON
    30  json j_complete = json::parse(ss);
    31  std::cout << std::setw(4) << j_complete << "\n\n";
    32 
    33 
    34  // define parser callback
    35  json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    36  {
    37  // skip object elements with key "Thumbnail"
    38  if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
    39  {
    40  return false;
    41  }
    42  else
    43  {
    44  return true;
    45  }
    46  };
    47 
    48  // fill a stream with JSON text
    49  ss.clear();
    50  ss << text;
    51 
    52  // parse (with callback) and serialize JSON
    53  json j_filtered = json::parse(ss, cb);
    54  std::cout << std::setw(4) << j_filtered << '\n';
    55 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5479
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:922
    +
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // a JSON text
    8  auto text = R"(
    9  {
    10  "Image": {
    11  "Width": 800,
    12  "Height": 600,
    13  "Title": "View from 15th Floor",
    14  "Thumbnail": {
    15  "Url": "http://www.example.com/image/481989943",
    16  "Height": 125,
    17  "Width": 100
    18  },
    19  "Animated" : false,
    20  "IDs": [116, 943, 234, 38793]
    21  }
    22  }
    23  )";
    24 
    25  // fill a stream with JSON text
    26  std::stringstream ss;
    27  ss << text;
    28 
    29  // parse and serialize JSON
    30  json j_complete = json::parse(ss);
    31  std::cout << std::setw(4) << j_complete << "\n\n";
    32 
    33 
    34  // define parser callback
    35  json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    36  {
    37  // skip object elements with key "Thumbnail"
    38  if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
    39  {
    40  return false;
    41  }
    42  else
    43  {
    44  return true;
    45  }
    46  };
    47 
    48  // fill a stream with JSON text
    49  ss.clear();
    50  ss << text;
    51 
    52  // parse (with callback) and serialize JSON
    53  json j_filtered = json::parse(ss, cb);
    54  std::cout << std::setw(4) << j_filtered << '\n';
    55 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5453
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:896
    the parser read a key of a value in an object
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:857
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:831
    Output (play with this example online):
    {
         "Image": {
             "Animated": false,
    @@ -321,7 +321,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    parse(const string_t&, parser_callback_t) for a version that reads from a string
    Since
    version 1.0.0
    -

    Definition at line 5516 of file json.hpp.

    +

    Definition at line 5490 of file json.hpp.

    @@ -331,7 +331,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab856bebfdfbcf45061f1474ea8ba9924.html b/classnlohmann_1_1basic__json_ab856bebfdfbcf45061f1474ea8ba9924.html index d88054798..01f380007 100644 --- a/classnlohmann_1_1basic__json_ab856bebfdfbcf45061f1474ea8ba9924.html +++ b/classnlohmann_1_1basic__json_ab856bebfdfbcf45061f1474ea8ba9924.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON type is primitive (string, number, boolean, or null).

    Returns
    true if type is primitive (string, number, boolean, or null), false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_primitive for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_primitive()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_primitive() << '\n';
    20  std::cout << j_boolean.is_primitive() << '\n';
    21  std::cout << j_number_integer.is_primitive() << '\n';
    22  std::cout << j_number_unsigned_integer.is_primitive() << '\n';
    23  std::cout << j_number_float.is_primitive() << '\n';
    24  std::cout << j_object.is_primitive() << '\n';
    25  std::cout << j_array.is_primitive() << '\n';
    26  std::cout << j_string.is_primitive() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_primitive for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_primitive()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_primitive() << '\n';
    20  std::cout << j_boolean.is_primitive() << '\n';
    21  std::cout << j_number_integer.is_primitive() << '\n';
    22  std::cout << j_number_unsigned_integer.is_primitive() << '\n';
    23  std::cout << j_number_float.is_primitive() << '\n';
    24  std::cout << j_object.is_primitive() << '\n';
    25  std::cout << j_array.is_primitive() << '\n';
    26  std::cout << j_string.is_primitive() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    true
     true
     true
    @@ -272,7 +272,7 @@ true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_primitive.cpp -o is_primitive 
    Since
    version 1.0.0
    -

    Definition at line 2109 of file json.hpp.

    +

    Definition at line 2083 of file json.hpp.

    @@ -282,7 +282,7 @@ true diff --git a/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html b/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html index e4879cd34..28c289597 100644 --- a/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html +++ b/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html @@ -272,8 +272,8 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows the constructor with an string_t parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an string_t value
    8  json::string_t value = "The quick brown fox jumps over the lazy doc";
    9 
    10  // create a JSON string from the value
    11  json j(value);
    12 
    13  // serialize the JSON array
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    StringType string_t
    a type for a string
    Definition: json.hpp:447
    +
    Example
    The following code shows the constructor with an string_t parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an string_t value
    8  json::string_t value = "The quick brown fox jumps over the lazy doc";
    9 
    10  // create a JSON string from the value
    11  json j(value);
    12 
    13  // serialize the JSON array
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    StringType string_t
    a type for a string
    Definition: json.hpp:421
    Output (play with this example online):
    "The quick brown fox jumps over the lazy doc"
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__string_t.cpp -o basic_json__string_t 
    See also
    basic_json(const typename string_t::value_type*) – create a string value from a character pointer
    @@ -281,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje basic_json(const CompatibleStringType&) – create a string value from a compatible string container
    Since
    version 1.0.0
    -

    Definition at line 1163 of file json.hpp.

    +

    Definition at line 1137 of file json.hpp.

    @@ -291,7 +291,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html b/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html index 622c8bb34..040b96a0c 100644 --- a/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html +++ b/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html @@ -261,7 +261,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function allows to access iterator::key() and iterator::value() during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator.

    Note
    The name of this function is not yet final and may change in the future.
    -

    Definition at line 4220 of file json.hpp.

    +

    Definition at line 4194 of file json.hpp.

    @@ -271,7 +271,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_abb5df282f9edf9cca898c6b8a9911111.html b/classnlohmann_1_1basic__json_abb5df282f9edf9cca898c6b8a9911111.html index aec1d2e45..353c74df2 100644 --- a/classnlohmann_1_1basic__json_abb5df282f9edf9cca898c6b8a9911111.html +++ b/classnlohmann_1_1basic__json_abb5df282f9edf9cca898c6b8a9911111.html @@ -264,7 +264,7 @@ template<template< typename U, typename V, typename...Args > class Obje
  • As postcondition, it holds: basic_json().empty() == true.
  • -
    Example
    The following code shows the constructor for a null JSON value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value with default null value
    8  json j;
    9 
    10  // serialize the JSON null value
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the constructor for a null JSON value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value with default null value
    8  json j;
    9 
    10  // serialize the JSON null value
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json.cpp -o basic_json 
    See also
    basic_json(std::nullptr_t) – create a null value
    @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_abc13258393358cb75a32fac86480bc9c.html b/classnlohmann_1_1basic__json_abc13258393358cb75a32fac86480bc9c.html index 9b72ab31c..cb166fcfe 100644 --- a/classnlohmann_1_1basic__json_abc13258393358cb75a32fac86480bc9c.html +++ b/classnlohmann_1_1basic__json_abc13258393358cb75a32fac86480bc9c.html @@ -269,12 +269,12 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).end().
  • -
    Example
    The following code shows an example for cend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to one past the last element
    11  json::const_iterator it = array.cend();
    12 
    13  // decrement the iterator to point to the last element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for cend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to one past the last element
    11  json::const_iterator it = array.cend();
    12 
    13  // decrement the iterator to point to the last element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cend.cpp -o cend 
    Since
    version 1.0.0
    -

    Definition at line 4066 of file json.hpp.

    +

    Definition at line 4040 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html b/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html index f65a42a5f..27bdf250f 100644 --- a/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html +++ b/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje number_unsigned_t – type for number values (unsigned integer)
    Since
    version 1.0.0
    -

    Definition at line 544 of file json.hpp.

    +

    Definition at line 518 of file json.hpp.

    @@ -284,7 +284,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html b/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html index 716b024ec..0a1223e2c 100644 --- a/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html +++ b/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html @@ -269,16 +269,16 @@ template<typename PointerType , typename std::enable_if<
    Returns
    pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise
    Complexity
    Constant.
    -
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get<const json::number_integer_t*>();
    12  auto p2 = value.get<json::number_integer_t*>();
    13  auto p3 = value.get<json::number_integer_t* const>();
    14  auto p4 = value.get<const json::number_integer_t* const>();
    15  auto p5 = value.get<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get<const json::number_integer_t*>();
    12  auto p2 = value.get<json::number_integer_t*>();
    13  auto p3 = value.get<json::number_integer_t* const>();
    14  auto p4 = value.get<const json::number_integer_t* const>();
    15  auto p5 = value.get<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get__PointerType.cpp -o get__PointerType 
    See also
    get_ptr() for explicit pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2755 of file json.hpp.

    +

    Definition at line 2729 of file json.hpp.

    @@ -288,7 +288,7 @@ true diff --git a/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html b/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html index a6c141537..105eff1f0 100644 --- a/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html +++ b/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html @@ -276,7 +276,7 @@ template<typename T >
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    2
     
     {
    @@ -302,7 +302,7 @@ template<typename T > 
    value() for access by value with a default value
    Since
    version 1.1.0
    -

    Definition at line 3382 of file json.hpp.

    +

    Definition at line 3356 of file json.hpp.

    @@ -312,7 +312,7 @@ template<typename T > diff --git a/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html b/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html index 97a0d025a..e884526e3 100644 --- a/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html +++ b/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 217 of file json.hpp.

    +

    Definition at line 191 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_acbc1c415072afe69b5e69b87f496e44b.html b/classnlohmann_1_1basic__json_acbc1c415072afe69b5e69b87f496e44b.html index ffc8b8812..76ff18f4b 100644 --- a/classnlohmann_1_1basic__json_acbc1c415072afe69b5e69b87f496e44b.html +++ b/classnlohmann_1_1basic__json_acbc1c415072afe69b5e69b87f496e44b.html @@ -269,12 +269,12 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).begin().
  • -
    Example
    The following code shows an example for cbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  const json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to the first element
    11  json::const_iterator it = array.cbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for cbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  const json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to the first element
    11  json::const_iterator it = array.cbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cbegin.cpp -o cbegin 
    Since
    version 1.0.0
    -

    Definition at line 4031 of file json.hpp.

    +

    Definition at line 4005 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html b/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html index 0cb2561d0..9ce980b12 100644 --- a/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html +++ b/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    Return the type of the JSON value as a value from the value_t enumeration.

    Returns
    the type of the JSON value
    Complexity
    Constant.
    -
    Example
    The following code exemplifies type() for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call type()
    17  std::cout << std::boolalpha;
    18  std::cout << (j_null.type() == json::value_t::null) << '\n';
    19  std::cout << (j_boolean.type() == json::value_t::boolean) << '\n';
    20  std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n';
    21  std::cout << (j_number_float.type() == json::value_t::number_float) << '\n';
    22  std::cout << (j_object.type() == json::value_t::object) << '\n';
    23  std::cout << (j_array.type() == json::value_t::array) << '\n';
    24  std::cout << (j_string.type() == json::value_t::string) << '\n';
    25 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies type() for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call type()
    17  std::cout << std::boolalpha;
    18  std::cout << (j_null.type() == json::value_t::null) << '\n';
    19  std::cout << (j_boolean.type() == json::value_t::boolean) << '\n';
    20  std::cout << (j_number_integer.type() == json::value_t::number_integer) << '\n';
    21  std::cout << (j_number_float.type() == json::value_t::number_float) << '\n';
    22  std::cout << (j_object.type() == json::value_t::object) << '\n';
    23  std::cout << (j_array.type() == json::value_t::array) << '\n';
    24  std::cout << (j_string.type() == json::value_t::string) << '\n';
    25 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    @@ -278,7 +278,7 @@ true The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/type.cpp -o type 
    Since
    version 1.0.0
    -

    Definition at line 2088 of file json.hpp.

    +

    Definition at line 2062 of file json.hpp.

    @@ -288,7 +288,7 @@ true diff --git a/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html b/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html index d1642c713..fb7bba11f 100644 --- a/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html +++ b/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html @@ -268,13 +268,13 @@ Illustration from cppreference.com
  • Has the semantics of reverse_iterator(begin()).
  • -
    Example
    The following code shows an example for rend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-end
    11  json::reverse_iterator it = array.rend();
    12 
    13  // increment the iterator to point to the first element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    json_reverse_iterator< typename basic_json::iterator > reverse_iterator
    a reverse iterator for a basic_json container
    Definition: json.hpp:245
    +
    Example
    The following code shows an example for rend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get an iterator to the reverse-end
    11  json::reverse_iterator it = array.rend();
    12 
    13  // increment the iterator to point to the first element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    json_reverse_iterator< typename basic_json::iterator > reverse_iterator
    a reverse iterator for a basic_json container
    Definition: json.hpp:219
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/rend.cpp -o rend 
    Since
    version 1.0.0
    -

    Definition at line 4145 of file json.hpp.

    +

    Definition at line 4119 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html b/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html index 4cd53aade..f4620ce57 100644 --- a/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html +++ b/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html @@ -274,8 +274,8 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in the size of init.
    -
    Example
    The following code shows an example for the object function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON objects
    8  json j_no_init_list = json::object();
    9  json j_empty_init_list = json::object({});
    10  json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
    11  //json j_invalid_list = json::object({ "one", 1 }); // would throw
    12 
    13  // serialize the JSON objects
    14  std::cout << j_no_init_list << '\n';
    15  std::cout << j_empty_init_list << '\n';
    16  std::cout << j_list_of_pairs << '\n';
    17 }
    static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an object from an initializer list
    Definition: json.hpp:1676
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for the object function.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON objects
    8  json j_no_init_list = json::object();
    9  json j_empty_init_list = json::object({});
    10  json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
    11  //json j_invalid_list = json::object({ "one", 1 }); // would throw
    12 
    13  // serialize the JSON objects
    14  std::cout << j_no_init_list << '\n';
    15  std::cout << j_empty_init_list << '\n';
    16  std::cout << j_list_of_pairs << '\n';
    17 }
    static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an object from an initializer list
    Definition: json.hpp:1650
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {}
     {}
     {"one":1,"two":2}
    @@ -285,7 +285,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     array(std::initializer_list<basic_json>) – create a JSON array value from an initializer list
    Since
    version 1.0.0
    -

    Definition at line 1676 of file json.hpp.

    +

    Definition at line 1650 of file json.hpp.

    @@ -295,7 +295,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html b/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html index 9b9078fad..5a30bfc62 100644 --- a/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html +++ b/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html @@ -274,7 +274,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if<
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of several JSON integer number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create values of different integer types
    8  short n42 = 42;
    9  int n23 = 23;
    10  long n1024 = 1024;
    11  int_least32_t n17 = 17;
    12  uint8_t n8 = 8;
    13 
    14  // create JSON numbers
    15  json j42(n42);
    16  json j23(n23);
    17  json j1024(n1024);
    18  json j17(n17);
    19  json j8(n8);
    20 
    21  // serialize the JSON numbers
    22  std::cout << j42 << '\n';
    23  std::cout << j23 << '\n';
    24  std::cout << j1024 << '\n';
    25  std::cout << j17 << '\n';
    26  std::cout << j8 << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows the construction of several JSON integer number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create values of different integer types
    8  short n42 = 42;
    9  int n23 = 23;
    10  long n1024 = 1024;
    11  int_least32_t n17 = 17;
    12  uint8_t n8 = 8;
    13 
    14  // create JSON numbers
    15  json j42(n42);
    16  json j23(n23);
    17  json j1024(n1024);
    18  json j17(n17);
    19  json j8(n8);
    20 
    21  // serialize the JSON numbers
    22  std::cout << j42 << '\n';
    23  std::cout << j23 << '\n';
    24  std::cout << j1024 << '\n';
    25  std::cout << j17 << '\n';
    26  std::cout << j8 << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    42
     23
     1024
    @@ -286,7 +286,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if<
     basic_json(const int) – create a number value (integer)
    Since
    version 1.0.0
    -

    Definition at line 1337 of file json.hpp.

    +

    Definition at line 1311 of file json.hpp.

    @@ -296,7 +296,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_ad2f716992118a42aa8f8d57950a8d0bb.html b/classnlohmann_1_1basic__json_ad2f716992118a42aa8f8d57950a8d0bb.html index 769f19d27..5d289c509 100644 --- a/classnlohmann_1_1basic__json_ad2f716992118a42aa8f8d57950a8d0bb.html +++ b/classnlohmann_1_1basic__json_ad2f716992118a42aa8f8d57950a8d0bb.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON value is a string.

    Returns
    true if type is string, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_string for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_string()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_string() << '\n';
    20  std::cout << j_boolean.is_string() << '\n';
    21  std::cout << j_number_integer.is_string() << '\n';
    22  std::cout << j_number_unsigned_integer.is_string() << '\n';
    23  std::cout << j_number_float.is_string() << '\n';
    24  std::cout << j_object.is_string() << '\n';
    25  std::cout << j_array.is_string() << '\n';
    26  std::cout << j_string.is_string() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_string for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_string()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_string() << '\n';
    20  std::cout << j_boolean.is_string() << '\n';
    21  std::cout << j_number_integer.is_string() << '\n';
    22  std::cout << j_number_unsigned_integer.is_string() << '\n';
    23  std::cout << j_number_float.is_string() << '\n';
    24  std::cout << j_object.is_string() << '\n';
    25  std::cout << j_array.is_string() << '\n';
    26  std::cout << j_string.is_string() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -272,7 +272,7 @@ true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_string.cpp -o is_string 
    Since
    version 1.0.0
    -

    Definition at line 2327 of file json.hpp.

    +

    Definition at line 2301 of file json.hpp.

    @@ -282,7 +282,7 @@ true diff --git a/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html b/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html index 0ed4e656a..eb6c0ec5f 100644 --- a/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html +++ b/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html @@ -269,12 +269,12 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).begin().
  • -
    Example
    The following code shows an example for cbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  const json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to the first element
    11  json::const_iterator it = array.cbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for cbegin.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  const json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to the first element
    11  json::const_iterator it = array.cbegin();
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cbegin.cpp -o cbegin 
    Since
    version 1.0.0
    -

    Definition at line 4007 of file json.hpp.

    +

    Definition at line 3981 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html b/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html index 96d9a37fb..9474e76a8 100644 --- a/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html +++ b/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html @@ -281,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
  • Has the semantics of returning b.size() where b is the largest possible JSON value.
  • -
    Example
    The following code calls max_size on the different value types. Note the output is implementation specific.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call max_size()
    17  std::cout << j_null.max_size() << '\n';
    18  std::cout << j_boolean.max_size() << '\n';
    19  std::cout << j_number_integer.max_size() << '\n';
    20  std::cout << j_number_float.max_size() << '\n';
    21  std::cout << j_object.max_size() << '\n';
    22  std::cout << j_array.max_size() << '\n';
    23  std::cout << j_string.max_size() << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code calls max_size on the different value types. Note the output is implementation specific.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call max_size()
    17  std::cout << j_null.max_size() << '\n';
    18  std::cout << j_boolean.max_size() << '\n';
    19  std::cout << j_number_integer.max_size() << '\n';
    20  std::cout << j_number_float.max_size() << '\n';
    21  std::cout << j_object.max_size() << '\n';
    22  std::cout << j_array.max_size() << '\n';
    23  std::cout << j_string.max_size() << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    0
     1
     1
    @@ -292,7 +292,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/max_size.cpp -o max_size 
    Since
    version 1.0.0
    -

    Definition at line 4392 of file json.hpp.

    +

    Definition at line 4366 of file json.hpp.

    @@ -302,7 +302,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html b/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html index ff20e7d15..49d4aefd5 100644 --- a/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html +++ b/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html @@ -276,7 +276,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Note
    Floating-point numbers are set to 0.0 which will be serialized to 0. The vale type remains number_float_t.
    Complexity
    Linear in the size of the JSON value.
    -
    Example
    The example below shows the effect of clear to different JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call clear()
    17  j_null.clear();
    18  j_boolean.clear();
    19  j_number_integer.clear();
    20  j_number_float.clear();
    21  j_object.clear();
    22  j_array.clear();
    23  j_string.clear();
    24 
    25  // serialize the cleared values()
    26  std::cout << j_null << '\n';
    27  std::cout << j_boolean << '\n';
    28  std::cout << j_number_integer << '\n';
    29  std::cout << j_number_float << '\n';
    30  std::cout << j_object << '\n';
    31  std::cout << j_array << '\n';
    32  std::cout << j_string << '\n';
    33 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows the effect of clear to different JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_array = {1, 2, 4, 8, 16};
    14  json j_string = "Hello, world";
    15 
    16  // call clear()
    17  j_null.clear();
    18  j_boolean.clear();
    19  j_number_integer.clear();
    20  j_number_float.clear();
    21  j_object.clear();
    22  j_array.clear();
    23  j_string.clear();
    24 
    25  // serialize the cleared values()
    26  std::cout << j_null << '\n';
    27  std::cout << j_boolean << '\n';
    28  std::cout << j_number_integer << '\n';
    29  std::cout << j_number_float << '\n';
    30  std::cout << j_object << '\n';
    31  std::cout << j_array << '\n';
    32  std::cout << j_string << '\n';
    33 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    null
     false
     0
    @@ -287,7 +287,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/clear.cpp -o clear 
    Since
    version 1.0.0
    -

    Definition at line 4451 of file json.hpp.

    +

    Definition at line 4425 of file json.hpp.

    @@ -297,7 +297,7 @@ false diff --git a/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html b/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html index 94c8cc15c..f6e4ec70c 100644 --- a/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html +++ b/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html @@ -278,7 +278,7 @@ operator[] with null"
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  const json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  const json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    2
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__key_type_const.cpp -o operatorarray__key_type_const 
    See also
    at(const typename object_t::key_type&) for access by reference with range checking
    @@ -286,7 +286,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3349 of file json.hpp.

    +

    Definition at line 3323 of file json.hpp.

    @@ -296,7 +296,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html b/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html index 7eae69726..22c3243dc 100644 --- a/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html +++ b/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html @@ -260,13 +260,13 @@ template<template< typename U, typename V, typename...Args > class Obje

    Create a null JSON value. This is the explicitly version of the null value constructor as it takes a null pointer as parameter. It allows to create null values by explicitly assigning a nullptr to a JSON value. The passed null pointer itself is not read – it is only used to choose the right constructor.

    Complexity
    Constant.
    -
    Example
    The following code shows the constructor with null pointer parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON null value
    8  json j(nullptr);
    9 
    10  // serialize the JSON null value
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the constructor with null pointer parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON null value
    8  json j(nullptr);
    9 
    10  // serialize the JSON null value
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__nullptr_t.cpp -o basic_json__nullptr_t 
    See also
    basic_json() – default constructor (implicitly creating a null value)
    Since
    version 1.0.0
    -

    Definition at line 1015 of file json.hpp.

    +

    Definition at line 989 of file json.hpp.

    @@ -276,7 +276,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ae129dc8ccd58cc3c64614db7d40a7dc9.html b/classnlohmann_1_1basic__json_ae129dc8ccd58cc3c64614db7d40a7dc9.html index 85611588b..d5bf6c952 100644 --- a/classnlohmann_1_1basic__json_ae129dc8ccd58cc3c64614db7d40a7dc9.html +++ b/classnlohmann_1_1basic__json_ae129dc8ccd58cc3c64614db7d40a7dc9.html @@ -269,12 +269,12 @@ Illustration from cppreference.com
  • Has the semantics of const_cast<const basic_json&>(*this).end().
  • -
    Example
    The following code shows an example for cend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to one past the last element
    11  json::const_iterator it = array.cend();
    12 
    13  // decrement the iterator to point to the last element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows an example for cend.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create an array value
    8  json array = {1, 2, 3, 4, 5};
    9 
    10  // get am iterator to one past the last element
    11  json::const_iterator it = array.cend();
    12 
    13  // decrement the iterator to point to the last element
    14  --it;
    15 
    16  // serialize the element that the iterator points to
    17  std::cout << *it << '\n';
    18 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cend.cpp -o cend 
    Since
    version 1.0.0
    -

    Definition at line 4090 of file json.hpp.

    +

    Definition at line 4064 of file json.hpp.

    @@ -284,7 +284,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html b/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html index b3ad11272..cde39937b 100644 --- a/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html +++ b/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 247 of file json.hpp.

    +

    Definition at line 221 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html index d1d9cdfc0..9c6ca8b93 100644 --- a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html +++ b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    whether v is not null
    Complexity
    Constant.
    Example
    The example compares several JSON types to the null pointer.
    -
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " != nullptr " << (array != nullptr) << '\n';
    17  std::cout << object << " != nullptr " << (object != nullptr) << '\n';
    18  std::cout << number << " != nullptr " << (number != nullptr) << '\n';
    19  std::cout << string << " != nullptr " << (string != nullptr) << '\n';
    20  std::cout << null << " != nullptr " << (null != nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create several JSON values
    8  json array = {1, 2, 3};
    9  json object = {{"A", "a"}, {"B", "b"}};
    10  json number = 17;
    11  json string = "foo";
    12  json null;
    13 
    14  // output values and comparisons
    15  std::cout << std::boolalpha;
    16  std::cout << array << " != nullptr " << (array != nullptr) << '\n';
    17  std::cout << object << " != nullptr " << (object != nullptr) << '\n';
    18  std::cout << number << " != nullptr " << (number != nullptr) << '\n';
    19  std::cout << string << " != nullptr " << (string != nullptr) << '\n';
    20  std::cout << null << " != nullptr " << (null != nullptr) << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481

    Output (play with this example online):

    [1,2,3] != nullptr true
     {"A":"a","B":"b"} != nullptr true
     17 != nullptr true
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     null != nullptr false
     

    The example code above can be translated with

    g++ -std=c++11 -Isrc doc/examples/operator__notequal__nullptr_t.cpp -o operator__notequal__nullptr_t 
    Since
    version 1.0.0
    -

    Definition at line 5202 of file json.hpp.

    +

    Definition at line 5176 of file json.hpp.

    @@ -296,7 +296,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html b/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html index 3af2a8a13..afc73ef8e 100644 --- a/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html +++ b/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html @@ -266,13 +266,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below demonstrates boolean values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create boolean values
    8  json j_truth = true;
    9  json j_falsity = false;
    10 
    11  // serialize the JSON booleans
    12  std::cout << j_truth << '\n';
    13  std::cout << j_falsity << '\n';
    14 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below demonstrates boolean values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create boolean values
    8  json j_truth = true;
    9  json j_falsity = false;
    10 
    11  // serialize the JSON booleans
    12  std::cout << j_truth << '\n';
    13  std::cout << j_falsity << '\n';
    14 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    true
     false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__boolean_t.cpp -o basic_json__boolean_t 
    Since
    version 1.0.0
    -

    Definition at line 1236 of file json.hpp.

    +

    Definition at line 1210 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html b/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html index 3b01b3968..1cc39d301 100644 --- a/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html +++ b/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html @@ -280,7 +280,7 @@ template<class CompatibleStringType , typename std::enable_if<
    -
    Example
    The following code shows the construction of a string value from a compatible type.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a string value
    8  std::string s = "The quick brown fox jumps over the lazy dog.";
    9 
    10  // create a JSON string value
    11  json j = s;
    12 
    13  // serialize the JSON string
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code shows the construction of a string value from a compatible type.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a string value
    8  std::string s = "The quick brown fox jumps over the lazy dog.";
    9 
    10  // create a JSON string value
    11  json j = s;
    12 
    13  // serialize the JSON string
    14  std::cout << j << '\n';
    15 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "The quick brown fox jumps over the lazy dog."
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__CompatibleStringType.cpp -o basic_json__CompatibleStringType 
    See also
    basic_json(const string_t&) – create a string value
    @@ -288,7 +288,7 @@ template<class CompatibleStringType , typename std::enable_if< basic_json(const typename string_t::value_type*) – create a string value from a character pointer
    Since
    version 1.0.0
    -

    Definition at line 1218 of file json.hpp.

    +

    Definition at line 1192 of file json.hpp.

    @@ -298,7 +298,7 @@ template<class CompatibleStringType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html index 66a76f272..a3d16670b 100644 --- a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html +++ b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje -

    Definition at line 857 of file json.hpp.

    +

    Definition at line 831 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html b/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html index 2ca59663c..e71dcaad8 100644 --- a/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html +++ b/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html @@ -295,13 +295,13 @@ belong to container"
    Returns
    iterator pointing to the first element inserted, or pos if first==last
    Complexity
    Linear in std::distance(first, last) plus linear in the distance between pos and end of the container.
    -
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // create a JSON array to copy values from
    11  json v2 = {"one", "two", "three", "four"};
    12 
    13  // insert range from v2 before the end of array v
    14  auto new_pos = v.insert(v.end(), v2.begin(), v2.end());
    15 
    16  // output new array and result of insert call
    17  std::cout << *new_pos << '\n';
    18  std::cout << v << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON array
    8  json v = {1, 2, 3, 4};
    9 
    10  // create a JSON array to copy values from
    11  json v2 = {"one", "two", "three", "four"};
    12 
    13  // insert range from v2 before the end of array v
    14  auto new_pos = v.insert(v.end(), v2.begin(), v2.end());
    15 
    16  // output new array and result of insert call
    17  std::cout << *new_pos << '\n';
    18  std::cout << v << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "one"
     [1,2,3,4,"one","two","three","four"]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/insert__range.cpp -o insert__range 
    Since
    version 1.0.0
    -

    Definition at line 4774 of file json.hpp.

    +

    Definition at line 4748 of file json.hpp.

    @@ -311,7 +311,7 @@ belong to container" diff --git a/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html b/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html index 858f91025..ab005f8f4 100644 --- a/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html +++ b/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 225 of file json.hpp.

    +

    Definition at line 199 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html b/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html index 13ff90fe5..9a5f57101 100644 --- a/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html +++ b/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html @@ -274,7 +274,7 @@ template<typename ValueType , typename std::enable_if<
    Complexity
    Linear in the size of the JSON value.
    -
    Example
    The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard std::vector<short>, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string, json>.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using json = nlohmann::json;
    5 
    6 int main()
    7 {
    8  // create a JSON value with different types
    9  json json_types =
    10  {
    11  {"boolean", true},
    12  {
    13  "number", {
    14  {"integer", 42},
    15  {"floating-point", 17.23}
    16  }
    17  },
    18  {"string", "Hello, world!"},
    19  {"array", {1, 2, 3, 4, 5}},
    20  {"null", nullptr}
    21  };
    22 
    23  // use implicit conversions
    24  bool v1 = json_types["boolean"];
    25  int v2 = json_types["number"]["integer"];
    26  short v3 = json_types["number"]["integer"];
    27  float v4 = json_types["number"]["floating-point"];
    28  int v5 = json_types["number"]["floating-point"];
    29  std::string v6 = json_types["string"];
    30  std::vector<short> v7 = json_types["array"];
    31  std::unordered_map<std::string, json> v8 = json_types;
    32 
    33  // print the conversion results
    34  std::cout << v1 << '\n';
    35  std::cout << v2 << ' ' << v3 << '\n';
    36  std::cout << v4 << ' ' << v5 << '\n';
    37  std::cout << v6 << '\n';
    38 
    39  for (auto i : v7)
    40  {
    41  std::cout << i << ' ';
    42  }
    43  std::cout << "\n\n";
    44 
    45  for (auto i : v8)
    46  {
    47  std::cout << i.first << ": " << i.second << '\n';
    48  }
    49 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows several conversions from JSON values to other types. There a few things to note: (1) Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard std::vector<short>, (3) A JSON object can be converted to C++ associative containers such as std::unordered_map<std::string, json>.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using json = nlohmann::json;
    5 
    6 int main()
    7 {
    8  // create a JSON value with different types
    9  json json_types =
    10  {
    11  {"boolean", true},
    12  {
    13  "number", {
    14  {"integer", 42},
    15  {"floating-point", 17.23}
    16  }
    17  },
    18  {"string", "Hello, world!"},
    19  {"array", {1, 2, 3, 4, 5}},
    20  {"null", nullptr}
    21  };
    22 
    23  // use implicit conversions
    24  bool v1 = json_types["boolean"];
    25  int v2 = json_types["number"]["integer"];
    26  short v3 = json_types["number"]["integer"];
    27  float v4 = json_types["number"]["floating-point"];
    28  int v5 = json_types["number"]["floating-point"];
    29  std::string v6 = json_types["string"];
    30  std::vector<short> v7 = json_types["array"];
    31  std::unordered_map<std::string, json> v8 = json_types;
    32 
    33  // print the conversion results
    34  std::cout << v1 << '\n';
    35  std::cout << v2 << ' ' << v3 << '\n';
    36  std::cout << v4 << ' ' << v5 << '\n';
    37  std::cout << v6 << '\n';
    38 
    39  for (auto i : v7)
    40  {
    41  std::cout << i << ' ';
    42  }
    43  std::cout << "\n\n";
    44 
    45  for (auto i : v8)
    46  {
    47  std::cout << i.first << ": " << i.second << '\n';
    48  }
    49 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -289,7 +289,7 @@ array: [1,2,3,4,5]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__ValueType.cpp -o operator__ValueType 
    Since
    version 1.0.0
    -

    Definition at line 2912 of file json.hpp.

    +

    Definition at line 2886 of file json.hpp.

    @@ -299,7 +299,7 @@ array: [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html b/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html index 253ffbf4e..621f5f9f2 100644 --- a/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html +++ b/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html @@ -294,7 +294,7 @@ value() with null"
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be queried with a default value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object with different entry types
    8  json j =
    9  {
    10  {"integer", 1},
    11  {"floating", 42.23},
    12  {"string", "hello world"},
    13  {"boolean", true},
    14  {"object", {{"key1", 1}, {"key2", 2}}},
    15  {"array", {1, 2, 3}}
    16  };
    17 
    18  // access existing values
    19  int v_integer = j.value("integer", 0);
    20  double v_floating = j.value("floating", 47.11);
    21 
    22  // access nonexisting values and rely on default value
    23  std::string v_string = j.value("nonexisting", "oops");
    24  bool v_boolean = j.value("nonexisting", false);
    25 
    26  // output values
    27  std::cout << std::boolalpha << v_integer << " " << v_floating
    28  << " " << v_string << " " << v_boolean << "\n";
    29 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how object elements can be queried with a default value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object with different entry types
    8  json j =
    9  {
    10  {"integer", 1},
    11  {"floating", 42.23},
    12  {"string", "hello world"},
    13  {"boolean", true},
    14  {"object", {{"key1", 1}, {"key2", 2}}},
    15  {"array", {1, 2, 3}}
    16  };
    17 
    18  // access existing values
    19  int v_integer = j.value("integer", 0);
    20  double v_floating = j.value("floating", 47.11);
    21 
    22  // access nonexisting values and rely on default value
    23  std::string v_string = j.value("nonexisting", "oops");
    24  bool v_boolean = j.value("nonexisting", false);
    25 
    26  // output values
    27  std::cout << std::boolalpha << v_integer << " " << v_floating
    28  << " " << v_string << " " << v_boolean << "\n";
    29 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    1 42.23 oops false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__value.cpp -o basic_json__value 
    See also
    at(const typename object_t::key_type&) for access by reference with range checking
    @@ -302,7 +302,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3524 of file json.hpp.

    +

    Definition at line 3498 of file json.hpp.

    @@ -312,7 +312,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html b/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html index a7610cd0e..5e41438d8 100644 --- a/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html +++ b/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html @@ -269,15 +269,15 @@ template<typename PointerType , typename std::enable_if<
    Returns
    pointer to the internally stored JSON value if the requested pointer type PointerType fits to the JSON value; nullptr otherwise
    Complexity
    Constant.
    -
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get_ptr<const json::number_integer_t*>();
    12  auto p2 = value.get_ptr<json::number_integer_t*>();
    13  auto p3 = value.get_ptr<json::number_integer_t* const>();
    14  auto p4 = value.get_ptr<const json::number_integer_t* const>();
    15  auto p5 = value.get_ptr<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    +
    Example
    The example below shows how pointers to internal values of a JSON value can be requested. Note that no type conversions are made and a nullptr is returned if the value and the requested pointer type does not match.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON number
    8  json value = 17;
    9 
    10  // explicitly getting pointers
    11  auto p1 = value.get_ptr<const json::number_integer_t*>();
    12  auto p2 = value.get_ptr<json::number_integer_t*>();
    13  auto p3 = value.get_ptr<json::number_integer_t* const>();
    14  auto p4 = value.get_ptr<const json::number_integer_t* const>();
    15  auto p5 = value.get_ptr<json::number_float_t*>();
    16 
    17  // print the pointees
    18  std::cout << *p1 << ' ' << *p2 << ' ' << *p3 << ' ' << *p4 << '\n';
    19  std::cout << std::boolalpha << (p5 == nullptr) << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr 
    Since
    version 1.0.0
    -

    Definition at line 2819 of file json.hpp.

    +

    Definition at line 2793 of file json.hpp.

    @@ -287,7 +287,7 @@ true diff --git a/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html b/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html index d101a9293..c1a0cefc2 100644 --- a/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html +++ b/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html @@ -261,7 +261,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function allows to access iterator::key() and iterator::value() during range-based for loops. In these loops, a reference to the JSON values is returned, so there is no access to the underlying iterator.

    Note
    The name of this function is not yet final and may change in the future.
    -

    Definition at line 4228 of file json.hpp.

    +

    Definition at line 4202 of file json.hpp.

    @@ -271,7 +271,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html b/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html index 065d5c86e..e64a30888 100644 --- a/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html +++ b/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html @@ -254,7 +254,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    Boolean values are stored directly inside a basic_json type.

    Since
    version 1.0.0
    -

    Definition at line 473 of file json.hpp.

    +

    Definition at line 447 of file json.hpp.

    @@ -264,7 +264,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html b/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html index 4fb76fc61..006bd25c2 100644 --- a/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html +++ b/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html @@ -247,7 +247,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 222 of file json.hpp.

    +

    Definition at line 196 of file json.hpp.

    @@ -257,7 +257,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html b/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html index 2f79bfda1..7fde475cc 100644 --- a/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html +++ b/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html @@ -266,13 +266,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON arrays can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create two JSON values
    8  json j1 = {1, 2, 3, 4, 5};
    9  json j2 = {{"pi", 3.141592653589793}, {"e", 2.718281828459045}};
    10 
    11  // swap the values
    12  j1.swap(j2);
    13 
    14  // output the values
    15  std::cout << "j1 = " << j1 << '\n';
    16  std::cout << "j2 = " << j2 << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how JSON arrays can be swapped.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create two JSON values
    8  json j1 = {1, 2, 3, 4, 5};
    9  json j2 = {{"pi", 3.141592653589793}, {"e", 2.718281828459045}};
    10 
    11  // swap the values
    12  j1.swap(j2);
    13 
    14  // output the values
    15  std::cout << "j1 = " << j1 << '\n';
    16  std::cout << "j2 = " << j2 << '\n';
    17 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    j1 = {"e":2.71828182845905,"pi":3.14159265358979}
     j2 = [1,2,3,4,5]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/swap__reference.cpp -o swap__reference 
    Since
    version 1.0.0
    -

    Definition at line 4870 of file json.hpp.

    +

    Definition at line 4844 of file json.hpp.

    @@ -282,7 +282,7 @@ j2 = [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html b/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html index 87f2f24bd..fbb23f1ae 100644 --- a/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html +++ b/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html @@ -299,14 +299,14 @@ construct with iterators from null"
    Complexity
    Linear in distance between first and last.
    -
    Example
    The example below shows several ways to create JSON values by specifying a subrange with iterators.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
    9  json j_number = 42;
    10  json j_object = {{"one", "eins"}, {"two", "zwei"}};
    11 
    12  // create copies using iterators
    13  json j_array_range(j_array.begin() + 1, j_array.end() - 2);
    14  json j_number_range(j_number.begin(), j_number.end());
    15  json j_object_range(j_object.begin(), j_object.find("two"));
    16 
    17  // serialize the values
    18  std::cout << j_array_range << '\n';
    19  std::cout << j_number_range << '\n';
    20  std::cout << j_object_range << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows several ways to create JSON values by specifying a subrange with iterators.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_array = {"alpha", "bravo", "charly", "delta", "easy"};
    9  json j_number = 42;
    10  json j_object = {{"one", "eins"}, {"two", "zwei"}};
    11 
    12  // create copies using iterators
    13  json j_array_range(j_array.begin() + 1, j_array.end() - 2);
    14  json j_number_range(j_number.begin(), j_number.end());
    15  json j_object_range(j_object.begin(), j_object.find("two"));
    16 
    17  // serialize the values
    18  std::cout << j_array_range << '\n';
    19  std::cout << j_number_range << '\n';
    20  std::cout << j_object_range << '\n';
    21 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    ["bravo","charly"]
     42
     {"one":"eins"}
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__InputIt_InputIt.cpp -o basic_json__InputIt_InputIt 
    Since
    version 1.0.0
    -

    Definition at line 1746 of file json.hpp.

    +

    Definition at line 1720 of file json.hpp.

    @@ -316,7 +316,7 @@ construct with iterators from null" diff --git a/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html b/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html index 0e5f8d1ff..5eed1d3da 100644 --- a/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html +++ b/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html @@ -308,7 +308,7 @@ initializer list"
    Complexity
    Linear in the size of the initializer list init.
    -
    Example
    The example below shows how JSON values are created from initializer lists
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_empty_init_list = json({});
    9  json j_object = { {"one", 1}, {"two", 2} };
    10  json j_array = {1, 2, 3, 4};
    11  json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
    12  json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
    13 
    14  // serialize the JSON value
    15  std::cout << j_empty_init_list << '\n';
    16  std::cout << j_object << '\n';
    17  std::cout << j_array << '\n';
    18  std::cout << j_nested_object << '\n';
    19  std::cout << j_nested_array << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example below shows how JSON values are created from initializer lists
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_empty_init_list = json({});
    9  json j_object = { {"one", 1}, {"two", 2} };
    10  json j_array = {1, 2, 3, 4};
    11  json j_nested_object = { {"one", {1}}, {"two", {1, 2}} };
    12  json j_nested_array = { {{1}, "one"}, {{1, 2}, "two"} };
    13 
    14  // serialize the JSON value
    15  std::cout << j_empty_init_list << '\n';
    16  std::cout << j_object << '\n';
    17  std::cout << j_array << '\n';
    18  std::cout << j_nested_object << '\n';
    19  std::cout << j_nested_array << '\n';
    20 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    {}
     {"one":1,"two":2}
     [1,2,3,4]
    @@ -320,7 +320,7 @@ initializer list"
     object(std::initializer_list<basic_json>) – create a JSON object value from an initializer list
    Since
    version 1.0.0
    -

    Definition at line 1544 of file json.hpp.

    +

    Definition at line 1518 of file json.hpp.

    @@ -330,7 +330,7 @@ initializer list" diff --git a/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html b/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html index bf6ea8d32..0f1f72a86 100644 --- a/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html +++ b/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    This function returns true iff the JSON type is structured (array or object).

    Returns
    true if type is structured (array or object), false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_structured for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_structured()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_structured() << '\n';
    20  std::cout << j_boolean.is_structured() << '\n';
    21  std::cout << j_number_integer.is_structured() << '\n';
    22  std::cout << j_number_unsigned_integer.is_structured() << '\n';
    23  std::cout << j_number_float.is_structured() << '\n';
    24  std::cout << j_object.is_structured() << '\n';
    25  std::cout << j_array.is_structured() << '\n';
    26  std::cout << j_string.is_structured() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The following code exemplifies is_structured for all JSON types.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_number_unsigned_integer = 12345678987654321u;
    13  json j_object = {{"one", 1}, {"two", 2}};
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_string = "Hello, world";
    16 
    17  // call is_structured()
    18  std::cout << std::boolalpha;
    19  std::cout << j_null.is_structured() << '\n';
    20  std::cout << j_boolean.is_structured() << '\n';
    21  std::cout << j_number_integer.is_structured() << '\n';
    22  std::cout << j_number_unsigned_integer.is_structured() << '\n';
    23  std::cout << j_number_float.is_structured() << '\n';
    24  std::cout << j_object.is_structured() << '\n';
    25  std::cout << j_array.is_structured() << '\n';
    26  std::cout << j_string.is_structured() << '\n';
    27 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    false
     false
     false
    @@ -272,7 +272,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_structured.cpp -o is_structured 
    Since
    version 1.0.0
    -

    Definition at line 2129 of file json.hpp.

    +

    Definition at line 2103 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html b/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html index 311dee36c..fcd107ee0 100644 --- a/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html +++ b/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html @@ -267,14 +267,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    Iterator to an element with key equivalent to key. If no such element is found, past-the-end (see end()) iterator is returned.
    Complexity
    Logarithmic in the size of the JSON object.
    -
    Example
    The example shows how find is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call find
    11  auto it_two = j_object.find("two");
    12  auto it_three = j_object.find("three");
    13 
    14  // print values
    15  std::cout << std::boolalpha;
    16  std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
    17  std::cout << "value at key \"two\": " << *it_two << '\n';
    18  std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    +
    Example
    The example shows how find is used.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json j_object = {{"one", 1}, {"two", 2}};
    9 
    10  // call find
    11  auto it_two = j_object.find("two");
    12  auto it_three = j_object.find("three");
    13 
    14  // print values
    15  std::cout << std::boolalpha;
    16  std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
    17  std::cout << "value at key \"two\": " << *it_two << '\n';
    18  std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
    19 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    Output (play with this example online):
    "two" was found: true
     value at key "two": 2
     "three" was found: false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/find__key_type.cpp -o find__key_type 
    Since
    version 1.0.0
    -

    Definition at line 3914 of file json.hpp.

    +

    Definition at line 3888 of file json.hpp.

    @@ -284,7 +284,7 @@ value at key "two": 2 diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 981a1aa42..bc39acc35 100644 --- a/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -92,7 +92,7 @@ Files diff --git a/functions.html b/functions.html index 6f504e023..fdf8a3584 100644 --- a/functions.html +++ b/functions.html @@ -134,7 +134,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_0x7e.html b/functions_0x7e.html index a2e854e9c..4f9c51246 100644 --- a/functions_0x7e.html +++ b/functions_0x7e.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_b.html b/functions_b.html index 5ba933a50..9b8b165a6 100644 --- a/functions_b.html +++ b/functions_b.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_c.html b/functions_c.html index 28ff89899..b2cf03fdd 100644 --- a/functions_c.html +++ b/functions_c.html @@ -152,7 +152,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_d.html b/functions_d.html index e8105b9fd..2e0992d53 100644 --- a/functions_d.html +++ b/functions_d.html @@ -129,7 +129,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_e.html b/functions_e.html index cbf31020c..7d7d2bd00 100644 --- a/functions_e.html +++ b/functions_e.html @@ -131,7 +131,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_enum.html b/functions_enum.html index aae0b06a2..6502cc885 100644 --- a/functions_enum.html +++ b/functions_enum.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_f.html b/functions_f.html index bfb7abbb1..2f1463fa9 100644 --- a/functions_f.html +++ b/functions_f.html @@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func.html b/functions_func.html index 03a119edc..e1b94a2b3 100644 --- a/functions_func.html +++ b/functions_func.html @@ -419,7 +419,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_g.html b/functions_g.html index 07dc1a758..1798805f7 100644 --- a/functions_g.html +++ b/functions_g.html @@ -134,7 +134,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_i.html b/functions_i.html index 4114defbe..5580899a2 100644 --- a/functions_i.html +++ b/functions_i.html @@ -170,7 +170,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_j.html b/functions_j.html index 53ef4dd5b..6f9017c3a 100644 --- a/functions_j.html +++ b/functions_j.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_k.html b/functions_k.html index 44153149b..c5fc49d77 100644 --- a/functions_k.html +++ b/functions_k.html @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_m.html b/functions_m.html index 12a2c740d..2d6448111 100644 --- a/functions_m.html +++ b/functions_m.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_n.html b/functions_n.html index 948e4474a..8f454962e 100644 --- a/functions_n.html +++ b/functions_n.html @@ -131,7 +131,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_o.html b/functions_o.html index 7691914d0..40b81f070 100644 --- a/functions_o.html +++ b/functions_o.html @@ -216,7 +216,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_p.html b/functions_p.html index b8de4402d..a88c239e8 100644 --- a/functions_p.html +++ b/functions_p.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_r.html b/functions_r.html index 7f0d70dc0..8746be406 100644 --- a/functions_r.html +++ b/functions_r.html @@ -137,7 +137,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_rela.html b/functions_rela.html index 9ef678973..996e14064 100644 --- a/functions_rela.html +++ b/functions_rela.html @@ -124,7 +124,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_s.html b/functions_s.html index 71287dbad..e9dba0c95 100644 --- a/functions_s.html +++ b/functions_s.html @@ -134,7 +134,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_t.html b/functions_t.html index eaa080395..f1ab2dda1 100644 --- a/functions_t.html +++ b/functions_t.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_type.html b/functions_type.html index dbe1daf9f..2df018d5a 100644 --- a/functions_type.html +++ b/functions_type.html @@ -165,7 +165,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_v.html b/functions_v.html index 7da101b77..20dfda9c7 100644 --- a/functions_v.html +++ b/functions_v.html @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/graph_legend.html b/graph_legend.html index 95c64aaf4..83c687040 100644 --- a/graph_legend.html +++ b/graph_legend.html @@ -108,7 +108,7 @@ A yellow dashed arrow denotes a relation between a template instance and the tem diff --git a/hierarchy.html b/hierarchy.html index 1055321f5..6ff2a0975 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/index.html b/index.html index 280369b2f..1d0dfc461 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ -JSON for Modern C++: Main Page +JSON for Modern C++: JSON for Modern C++ @@ -76,23 +76,34 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    -
    JSON for Modern C++ Documentation
    +
    JSON for Modern C++

    These pages contain the API documentation of JSON for Modern C++, a C++11 header-only JSON class.

    -

    Class nlohmann::basic_json is a good entry point for the documentation.

    - + +
    Author
    Niels Lohmann
    See also
    https://github.com/nlohmann/json to download the source code
    Version
    2.0.0
    diff --git a/index_8md_source.html b/index_8md_source.html new file mode 100644 index 000000000..53e1fe54b --- /dev/null +++ b/index_8md_source.html @@ -0,0 +1,90 @@ + + + + + + +JSON for Modern C++: index.md Source File + + + + + + + + + + + +
    +
    + + + + + + +
    +
    JSON for Modern C++ +  2.0.0 +
    +
    +
    + + + + +
    + +
    +
    + + +
    + +
    + +
    +
    +
    index.md
    +
    +
    +
    1 # JSON for Modern C++
    2 
    3 These pages contain the API documentation of JSON for Modern C++, a C++11 header-only JSON class.
    4 
    5 - @link nlohmann::basic_json `basic_json` class @endlink
    6 - Types
    7  - @link nlohmann::basic_json::array_t arrays @endlink
    8  - @link nlohmann::basic_json::object_t objects @endlink
    9  - @link nlohmann::basic_json::string_t strings @endlink
    10  - @link nlohmann::basic_json::boolean_t booleans @endlink
    11  - numbers
    12  - @link nlohmann::basic_json::number_integer_t signed integers @endlink
    13  - @link nlohmann::basic_json::number_unsigned_t unsigned integers @endlink
    14  - @link nlohmann::basic_json::number_float_t floating-point @endlink
    15 
    16 @copyright Copyright &copy; 2013-2016 Niels Lohmann. The code is licensed under the [MIT License](http://opensource.org/licenses/MIT).
    17 
    18 @author [Niels Lohmann](http://nlohmann.me)
    19 @see https://github.com/nlohmann/json to download the source code
    20 
    21 @version 2.0.0
    + + + + diff --git a/json_8hpp_source.html b/json_8hpp_source.html index 7683fccd6..a929a23c6 100644 --- a/json_8hpp_source.html +++ b/json_8hpp_source.html @@ -83,221 +83,221 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    json.hpp
    -
    1 
    38 #ifndef NLOHMANN_JSON_HPP
    39 #define NLOHMANN_JSON_HPP
    40 
    41 #include <algorithm>
    42 #include <array>
    43 #include <cassert>
    44 #include <ciso646>
    45 #include <cmath>
    46 #include <cstddef>
    47 #include <cstdio>
    48 #include <cstdlib>
    49 #include <functional>
    50 #include <initializer_list>
    51 #include <iomanip>
    52 #include <iostream>
    53 #include <iterator>
    54 #include <limits>
    55 #include <map>
    56 #include <memory>
    57 #include <sstream>
    58 #include <stdexcept>
    59 #include <string>
    60 #include <type_traits>
    61 #include <utility>
    62 #include <vector>
    63 
    64 // enable ssize_t on MinGW
    65 #ifdef __GNUC__
    66  #ifdef __MINGW32__
    67  #include <sys/types.h>
    68  #endif
    69 #endif
    70 
    71 // disable float-equal warnings on GCC/clang
    72 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    73  #pragma GCC diagnostic push
    74  #pragma GCC diagnostic ignored "-Wfloat-equal"
    75 #endif
    76 
    77 // enable ssize_t for MSVC
    78 #ifdef _MSC_VER
    79  #include <basetsd.h>
    80  using ssize_t = SSIZE_T;
    81 #endif
    82 
    88 namespace nlohmann
    89 {
    90 
    91 
    96 namespace
    97 {
    102 template<typename T>
    103 struct has_mapped_type
    104 {
    105  private:
    106  template<typename C> static char test(typename C::mapped_type*);
    107  template<typename C> static char (&test(...))[2];
    108  public:
    109  static constexpr bool value = sizeof(test<T>(0)) == 1;
    110 };
    111 
    112 }
    113 
    184 template <
    185  template<typename U, typename V, typename... Args> class ObjectType = std::map,
    186  template<typename U, typename... Args> class ArrayType = std::vector,
    187  class StringType = std::string,
    188  class BooleanType = bool,
    189  class NumberIntegerType = int64_t,
    190  class NumberUnsignedType = uint64_t,
    191  class NumberFloatType = double,
    192  template<typename U> class AllocatorType = std::allocator
    193  >
    195 {
    196  private:
    198  using basic_json_t = basic_json<ObjectType,
    199  ArrayType,
    200  StringType,
    201  BooleanType,
    202  NumberIntegerType,
    203  NumberUnsignedType,
    204  NumberFloatType,
    205  AllocatorType>;
    206 
    207  public:
    208 
    210  // container types //
    212 
    215 
    218 
    222  using const_reference = const value_type&;
    223 
    225  using difference_type = std::ptrdiff_t;
    227  using size_type = std::size_t;
    228 
    230  using allocator_type = AllocatorType<basic_json>;
    231 
    233  using pointer = typename std::allocator_traits<allocator_type>::pointer;
    235  using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
    236 
    237  // forward declaration
    238  template<typename Base> class json_reverse_iterator;
    239 
    241  class iterator;
    243  class const_iterator;
    248 
    250 
    251 
    256  {
    257  return allocator_type();
    258  }
    259 
    260 
    262  // JSON value data types //
    264 
    267 
    350  using object_t = ObjectType<StringType,
    351  basic_json,
    352  std::less<StringType>,
    353  AllocatorType<std::pair<const StringType,
    354  basic_json>>>;
    355 
    400  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
    401 
    447  using string_t = StringType;
    448 
    473  using boolean_t = BooleanType;
    474 
    544  using number_integer_t = NumberIntegerType;
    545 
    616  using number_unsigned_t = NumberUnsignedType;
    617 
    684  using number_float_t = NumberFloatType;
    685 
    687 
    688 
    690  // JSON type enumeration //
    692 
    703  enum class value_t : uint8_t
    704  {
    705  null,
    706  object,
    707  array,
    708  string,
    709  boolean,
    710  number_integer,
    711  number_unsigned,
    712  number_float,
    713  discarded
    714  };
    715 
    716 
    717  private:
    719  template<typename T, typename... Args>
    720  static T* create(Args&& ... args)
    721  {
    722  AllocatorType<T> alloc;
    723  auto deleter = [&](T * object)
    724  {
    725  alloc.deallocate(object, 1);
    726  };
    727  std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
    728  alloc.construct(object.get(), std::forward<Args>(args)...);
    729  return object.release();
    730  }
    731 
    733  // JSON value storage //
    735 
    743  union json_value
    744  {
    746  object_t* object;
    748  array_t* array;
    750  string_t* string;
    752  boolean_t boolean;
    754  number_integer_t number_integer;
    756  number_unsigned_t number_unsigned;
    758  number_float_t number_float;
    759 
    761  json_value() noexcept = default;
    763  json_value(boolean_t v) noexcept : boolean(v) {}
    765  json_value(number_integer_t v) noexcept : number_integer(v) {}
    767  json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
    769  json_value(number_float_t v) noexcept : number_float(v) {}
    771  json_value(value_t t)
    772  {
    773  switch (t)
    774  {
    775  case value_t::object:
    776  {
    777  object = create<object_t>();
    778  break;
    779  }
    780 
    781  case value_t::array:
    782  {
    783  array = create<array_t>();
    784  break;
    785  }
    786 
    787  case value_t::string:
    788  {
    789  string = create<string_t>("");
    790  break;
    791  }
    792 
    793  case value_t::boolean:
    794  {
    795  boolean = boolean_t(false);
    796  break;
    797  }
    798 
    799  case value_t::number_integer:
    800  {
    801  number_integer = number_integer_t(0);
    802  break;
    803  }
    804 
    805  case value_t::number_unsigned:
    806  {
    807  number_unsigned = number_unsigned_t(0);
    808  break;
    809  }
    810 
    811  case value_t::number_float:
    812  {
    813  number_float = number_float_t(0.0);
    814  break;
    815  }
    816 
    817  default:
    818  {
    819  break;
    820  }
    821  }
    822  }
    823 
    825  json_value(const string_t& value)
    826  {
    827  string = create<string_t>(value);
    828  }
    829 
    831  json_value(const object_t& value)
    832  {
    833  object = create<object_t>(value);
    834  }
    835 
    837  json_value(const array_t& value)
    838  {
    839  array = create<array_t>(value);
    840  }
    841  };
    842 
    843 
    844  public:
    846  // JSON parser callback //
    848 
    857  enum class parse_event_t : uint8_t
    858  {
    860  object_start,
    862  object_end,
    864  array_start,
    866  array_end,
    868  key,
    870  value
    871  };
    872 
    922  using parser_callback_t = std::function<bool(int depth, parse_event_t event, basic_json& parsed)>;
    923 
    924 
    926  // constructors //
    928 
    931 
    972  : m_type(value_type), m_value(value_type)
    973  {}
    974 
    994  basic_json() noexcept = default;
    995 
    1015  basic_json(std::nullptr_t) noexcept
    1016  : basic_json(value_t::null)
    1017  {}
    1018 
    1038  basic_json(const object_t& val)
    1039  : m_type(value_t::object), m_value(val)
    1040  {}
    1041 
    1065  template <class CompatibleObjectType, typename
    1066  std::enable_if<
    1067  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    1068  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    1069  = 0>
    1070  basic_json(const CompatibleObjectType& val)
    1071  : m_type(value_t::object)
    1072  {
    1073  using std::begin;
    1074  using std::end;
    1075  m_value.object = create<object_t>(begin(val), end(val));
    1076  }
    1077 
    1097  basic_json(const array_t& val)
    1098  : m_type(value_t::array), m_value(val)
    1099  {}
    1100 
    1124  template <class CompatibleArrayType, typename
    1125  std::enable_if<
    1126  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1127  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1128  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1129  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1130  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1131  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1132  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1133  = 0>
    1134  basic_json(const CompatibleArrayType& val)
    1135  : m_type(value_t::array)
    1136  {
    1137  using std::begin;
    1138  using std::end;
    1139  m_value.array = create<array_t>(begin(val), end(val));
    1140  }
    1141 
    1163  basic_json(const string_t& val)
    1164  : m_type(value_t::string), m_value(val)
    1165  {}
    1166 
    1187  basic_json(const typename string_t::value_type* val)
    1188  : basic_json(string_t(val))
    1189  {}
    1190 
    1214  template <class CompatibleStringType, typename
    1215  std::enable_if<
    1216  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1217  = 0>
    1218  basic_json(const CompatibleStringType& val)
    1219  : basic_json(string_t(val))
    1220  {}
    1221 
    1237  : m_type(value_t::boolean), m_value(val)
    1238  {}
    1239 
    1265  template<typename T,
    1266  typename std::enable_if<
    1267  not (std::is_same<T, int>::value)
    1268  and std::is_same<T, number_integer_t>::value
    1269  , int>::type
    1270  = 0>
    1272  : m_type(value_t::number_integer), m_value(val)
    1273  {}
    1274 
    1300  basic_json(const int val)
    1301  : m_type(value_t::number_integer),
    1302  m_value(static_cast<number_integer_t>(val))
    1303  {}
    1304 
    1330  template<typename CompatibleNumberIntegerType, typename
    1331  std::enable_if<
    1332  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1333  std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
    1334  std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
    1335  CompatibleNumberIntegerType>::type
    1336  = 0>
    1337  basic_json(const CompatibleNumberIntegerType val) noexcept
    1338  : m_type(value_t::number_integer),
    1339  m_value(static_cast<number_integer_t>(val))
    1340  {}
    1341 
    1359  template<typename T,
    1360  typename std::enable_if<
    1361  not (std::is_same<T, int>::value)
    1362  and std::is_same<T, number_unsigned_t>::value
    1363  , int>::type
    1364  = 0>
    1366  : m_type(value_t::number_unsigned), m_value(val)
    1367  {}
    1368 
    1389  template < typename CompatibleNumberUnsignedType, typename
    1390  std::enable_if <
    1391  std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
    1392  std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
    1393  !std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
    1394  CompatibleNumberUnsignedType >::type
    1395  = 0 >
    1396  basic_json(const CompatibleNumberUnsignedType val) noexcept
    1397  : m_type(value_t::number_unsigned),
    1398  m_value(static_cast<number_unsigned_t>(val))
    1399  {}
    1400 
    1426  : m_type(value_t::number_float), m_value(val)
    1427  {
    1428  // replace infinity and NAN by null
    1429  if (not std::isfinite(val))
    1430  {
    1431  m_type = value_t::null;
    1432  m_value = json_value();
    1433  }
    1434  }
    1435 
    1466  template<typename CompatibleNumberFloatType, typename = typename
    1467  std::enable_if<
    1468  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1469  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1470  >
    1471  basic_json(const CompatibleNumberFloatType val) noexcept
    1472  : basic_json(number_float_t(val))
    1473  {}
    1474 
    1544  basic_json(std::initializer_list<basic_json> init,
    1545  bool type_deduction = true,
    1546  value_t manual_type = value_t::array)
    1547  {
    1548  // the initializer list could describe an object
    1549  bool is_an_object = true;
    1550 
    1551  // check if each element is an array with two elements whose first
    1552  // element is a string
    1553  for (const auto& element : init)
    1554  {
    1555  if (not element.is_array() or element.size() != 2
    1556  or not element[0].is_string())
    1557  {
    1558  // we found an element that makes it impossible to use the
    1559  // initializer list as object
    1560  is_an_object = false;
    1561  break;
    1562  }
    1563  }
    1564 
    1565  // adjust type if type deduction is not wanted
    1566  if (not type_deduction)
    1567  {
    1568  // if array is wanted, do not create an object though possible
    1569  if (manual_type == value_t::array)
    1570  {
    1571  is_an_object = false;
    1572  }
    1573 
    1574  // if object is wanted but impossible, throw an exception
    1575  if (manual_type == value_t::object and not is_an_object)
    1576  {
    1577  throw std::domain_error("cannot create object from initializer list");
    1578  }
    1579  }
    1580 
    1581  if (is_an_object)
    1582  {
    1583  // the initializer list is a list of pairs -> create object
    1584  m_type = value_t::object;
    1585  m_value = value_t::object;
    1586 
    1587  assert(m_value.object != nullptr);
    1588 
    1589  for (auto& element : init)
    1590  {
    1591  m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1]));
    1592  }
    1593  }
    1594  else
    1595  {
    1596  // the initializer list describes an array -> create array
    1597  m_type = value_t::array;
    1598  m_value.array = create<array_t>(std::move(init));
    1599  }
    1600  }
    1601 
    1636  static basic_json array(std::initializer_list<basic_json> init =
    1637  std::initializer_list<basic_json>())
    1638  {
    1639  return basic_json(init, false, value_t::array);
    1640  }
    1641 
    1676  static basic_json object(std::initializer_list<basic_json> init =
    1677  std::initializer_list<basic_json>())
    1678  {
    1679  return basic_json(init, false, value_t::object);
    1680  }
    1681 
    1700  basic_json(size_type cnt, const basic_json& val)
    1701  : m_type(value_t::array)
    1702  {
    1703  m_value.array = create<array_t>(cnt, val);
    1704  }
    1705 
    1740  template <class InputIT, typename
    1741  std::enable_if<
    1742  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1743  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1744  , int>::type
    1745  = 0>
    1746  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1747  {
    1748  // make sure iterator fits the current value
    1749  if (first.m_object != last.m_object)
    1750  {
    1751  throw std::domain_error("iterators are not compatible");
    1752  }
    1753 
    1754  // check if iterator range is complete for primitive values
    1755  switch (m_type)
    1756  {
    1757  case value_t::boolean:
    1758  case value_t::number_float:
    1759  case value_t::number_integer:
    1760  case value_t::number_unsigned:
    1761  case value_t::string:
    1762  {
    1763  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1764  {
    1765  throw std::out_of_range("iterators out of range");
    1766  }
    1767  break;
    1768  }
    1769 
    1770  default:
    1771  {
    1772  break;
    1773  }
    1774  }
    1775 
    1776  switch (m_type)
    1777  {
    1778  case value_t::number_integer:
    1779  {
    1780  assert(first.m_object != nullptr);
    1781  m_value.number_integer = first.m_object->m_value.number_integer;
    1782  break;
    1783  }
    1784 
    1785  case value_t::number_unsigned:
    1786  {
    1787  assert(first.m_object != nullptr);
    1788  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
    1789  break;
    1790  }
    1791 
    1792  case value_t::number_float:
    1793  {
    1794  assert(first.m_object != nullptr);
    1795  m_value.number_float = first.m_object->m_value.number_float;
    1796  break;
    1797  }
    1798 
    1799  case value_t::boolean:
    1800  {
    1801  assert(first.m_object != nullptr);
    1802  m_value.boolean = first.m_object->m_value.boolean;
    1803  break;
    1804  }
    1805 
    1806  case value_t::string:
    1807  {
    1808  assert(first.m_object != nullptr);
    1809  m_value = *first.m_object->m_value.string;
    1810  break;
    1811  }
    1812 
    1813  case value_t::object:
    1814  {
    1815  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1816  break;
    1817  }
    1818 
    1819  case value_t::array:
    1820  {
    1821  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1822  break;
    1823  }
    1824 
    1825  default:
    1826  {
    1827  assert(first.m_object != nullptr);
    1828  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1829  }
    1830  }
    1831  }
    1832 
    1834  // other constructors and destructor //
    1836 
    1857  basic_json(const basic_json& other)
    1858  : m_type(other.m_type)
    1859  {
    1860  switch (m_type)
    1861  {
    1862  case value_t::object:
    1863  {
    1864  assert(other.m_value.object != nullptr);
    1865  m_value = *other.m_value.object;
    1866  break;
    1867  }
    1868 
    1869  case value_t::array:
    1870  {
    1871  assert(other.m_value.array != nullptr);
    1872  m_value = *other.m_value.array;
    1873  break;
    1874  }
    1875 
    1876  case value_t::string:
    1877  {
    1878  assert(other.m_value.string != nullptr);
    1879  m_value = *other.m_value.string;
    1880  break;
    1881  }
    1882 
    1883  case value_t::boolean:
    1884  {
    1885  m_value = other.m_value.boolean;
    1886  break;
    1887  }
    1888 
    1889  case value_t::number_integer:
    1890  {
    1891  m_value = other.m_value.number_integer;
    1892  break;
    1893  }
    1894 
    1895  case value_t::number_unsigned:
    1896  {
    1897  m_value = other.m_value.number_unsigned;
    1898  break;
    1899  }
    1900 
    1901  case value_t::number_float:
    1902  {
    1903  m_value = other.m_value.number_float;
    1904  break;
    1905  }
    1906 
    1907  default:
    1908  {
    1909  break;
    1910  }
    1911  }
    1912  }
    1913 
    1932  basic_json(basic_json&& other) noexcept
    1933  : m_type(std::move(other.m_type)),
    1934  m_value(std::move(other.m_value))
    1935  {
    1936  // invalidate payload
    1937  other.m_type = value_t::null;
    1938  other.m_value = {};
    1939  }
    1940 
    1962  reference& operator=(basic_json other) noexcept (
    1963  std::is_nothrow_move_constructible<value_t>::value and
    1964  std::is_nothrow_move_assignable<value_t>::value and
    1965  std::is_nothrow_move_constructible<json_value>::value and
    1966  std::is_nothrow_move_assignable<json_value>::value
    1967  )
    1968  {
    1969  using std::swap;
    1970  swap(m_type, other.m_type);
    1971  swap(m_value, other.m_value);
    1972  return *this;
    1973  }
    1974 
    1989  {
    1990  switch (m_type)
    1991  {
    1992  case value_t::object:
    1993  {
    1994  AllocatorType<object_t> alloc;
    1995  alloc.destroy(m_value.object);
    1996  alloc.deallocate(m_value.object, 1);
    1997  break;
    1998  }
    1999 
    2000  case value_t::array:
    2001  {
    2002  AllocatorType<array_t> alloc;
    2003  alloc.destroy(m_value.array);
    2004  alloc.deallocate(m_value.array, 1);
    2005  break;
    2006  }
    2007 
    2008  case value_t::string:
    2009  {
    2010  AllocatorType<string_t> alloc;
    2011  alloc.destroy(m_value.string);
    2012  alloc.deallocate(m_value.string, 1);
    2013  break;
    2014  }
    2015 
    2016  default:
    2017  {
    2018  // all other types need no specific destructor
    2019  break;
    2020  }
    2021  }
    2022  }
    2023 
    2025 
    2026  public:
    2028  // object inspection //
    2030 
    2033 
    2057  string_t dump(const int indent = -1) const
    2058  {
    2059  std::stringstream ss;
    2060 
    2061  if (indent >= 0)
    2062  {
    2063  dump(ss, true, static_cast<unsigned int>(indent));
    2064  }
    2065  else
    2066  {
    2067  dump(ss, false, 0);
    2068  }
    2069 
    2070  return ss.str();
    2071  }
    2072 
    2088  value_t type() const noexcept
    2089  {
    2090  return m_type;
    2091  }
    2092 
    2109  bool is_primitive() const noexcept
    2110  {
    2111  return is_null() or is_string() or is_boolean() or is_number();
    2112  }
    2113 
    2129  bool is_structured() const noexcept
    2130  {
    2131  return is_array() or is_object();
    2132  }
    2133 
    2148  bool is_null() const noexcept
    2149  {
    2150  return m_type == value_t::null;
    2151  }
    2152 
    2167  bool is_boolean() const noexcept
    2168  {
    2169  return m_type == value_t::boolean;
    2170  }
    2171 
    2194  bool is_number() const noexcept
    2195  {
    2196  return is_number_integer() or is_number_float();
    2197  }
    2198 
    2220  bool is_number_integer() const noexcept
    2221  {
    2222  return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
    2223  }
    2224 
    2245  bool is_number_unsigned() const noexcept
    2246  {
    2247  return m_type == value_t::number_unsigned;
    2248  }
    2249 
    2270  bool is_number_float() const noexcept
    2271  {
    2272  return m_type == value_t::number_float;
    2273  }
    2274 
    2289  bool is_object() const noexcept
    2290  {
    2291  return m_type == value_t::object;
    2292  }
    2293 
    2308  bool is_array() const noexcept
    2309  {
    2310  return m_type == value_t::array;
    2311  }
    2312 
    2327  bool is_string() const noexcept
    2328  {
    2329  return m_type == value_t::string;
    2330  }
    2331 
    2351  bool is_discarded() const noexcept
    2352  {
    2353  return m_type == value_t::discarded;
    2354  }
    2355 
    2371  operator value_t() const noexcept
    2372  {
    2373  return m_type;
    2374  }
    2375 
    2377 
    2378  private:
    2380  // value access //
    2382 
    2384  template <class T, typename
    2385  std::enable_if<
    2386  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2387  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2388  , int>::type = 0>
    2389  T get_impl(T*) const
    2390  {
    2391  if (is_object())
    2392  {
    2393  assert(m_value.object != nullptr);
    2394  return T(m_value.object->begin(), m_value.object->end());
    2395  }
    2396  else
    2397  {
    2398  throw std::domain_error("type must be object, but is " + type_name());
    2399  }
    2400  }
    2401 
    2403  object_t get_impl(object_t*) const
    2404  {
    2405  if (is_object())
    2406  {
    2407  assert(m_value.object != nullptr);
    2408  return *(m_value.object);
    2409  }
    2410  else
    2411  {
    2412  throw std::domain_error("type must be object, but is " + type_name());
    2413  }
    2414  }
    2415 
    2417  template <class T, typename
    2418  std::enable_if<
    2419  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2420  not std::is_same<basic_json_t, typename T::value_type>::value and
    2421  not std::is_arithmetic<T>::value and
    2422  not std::is_convertible<std::string, T>::value and
    2423  not has_mapped_type<T>::value
    2424  , int>::type = 0>
    2425  T get_impl(T*) const
    2426  {
    2427  if (is_array())
    2428  {
    2429  T to_vector;
    2430  assert(m_value.array != nullptr);
    2431  std::transform(m_value.array->begin(), m_value.array->end(),
    2432  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2433  {
    2434  return i.get<typename T::value_type>();
    2435  });
    2436  return to_vector;
    2437  }
    2438  else
    2439  {
    2440  throw std::domain_error("type must be array, but is " + type_name());
    2441  }
    2442  }
    2443 
    2445  template <class T, typename
    2446  std::enable_if<
    2447  std::is_convertible<basic_json_t, T>::value and
    2448  not std::is_same<basic_json_t, T>::value
    2449  , int>::type = 0>
    2450  std::vector<T> get_impl(std::vector<T>*) const
    2451  {
    2452  if (is_array())
    2453  {
    2454  std::vector<T> to_vector;
    2455  assert(m_value.array != nullptr);
    2456  to_vector.reserve(m_value.array->size());
    2457  std::transform(m_value.array->begin(), m_value.array->end(),
    2458  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2459  {
    2460  return i.get<T>();
    2461  });
    2462  return to_vector;
    2463  }
    2464  else
    2465  {
    2466  throw std::domain_error("type must be array, but is " + type_name());
    2467  }
    2468  }
    2469 
    2471  template <class T, typename
    2472  std::enable_if<
    2473  std::is_same<basic_json, typename T::value_type>::value and
    2474  not has_mapped_type<T>::value
    2475  , int>::type = 0>
    2476  T get_impl(T*) const
    2477  {
    2478  if (is_array())
    2479  {
    2480  assert(m_value.array != nullptr);
    2481  return T(m_value.array->begin(), m_value.array->end());
    2482  }
    2483  else
    2484  {
    2485  throw std::domain_error("type must be array, but is " + type_name());
    2486  }
    2487  }
    2488 
    2490  array_t get_impl(array_t*) const
    2491  {
    2492  if (is_array())
    2493  {
    2494  assert(m_value.array != nullptr);
    2495  return *(m_value.array);
    2496  }
    2497  else
    2498  {
    2499  throw std::domain_error("type must be array, but is " + type_name());
    2500  }
    2501  }
    2502 
    2504  template <typename T, typename
    2505  std::enable_if<
    2506  std::is_convertible<string_t, T>::value
    2507  , int>::type = 0>
    2508  T get_impl(T*) const
    2509  {
    2510  if (is_string())
    2511  {
    2512  assert(m_value.string != nullptr);
    2513  return *m_value.string;
    2514  }
    2515  else
    2516  {
    2517  throw std::domain_error("type must be string, but is " + type_name());
    2518  }
    2519  }
    2520 
    2522  template<typename T, typename
    2523  std::enable_if<
    2524  std::is_arithmetic<T>::value
    2525  , int>::type = 0>
    2526  T get_impl(T*) const
    2527  {
    2528  switch (m_type)
    2529  {
    2530  case value_t::number_integer:
    2531  {
    2532  return static_cast<T>(m_value.number_integer);
    2533  }
    2534 
    2535  case value_t::number_unsigned:
    2536  {
    2537  return static_cast<T>(m_value.number_unsigned);
    2538  }
    2539 
    2540  case value_t::number_float:
    2541  {
    2542  return static_cast<T>(m_value.number_float);
    2543  }
    2544 
    2545  default:
    2546  {
    2547  throw std::domain_error("type must be number, but is " + type_name());
    2548  }
    2549  }
    2550  }
    2551 
    2553  boolean_t get_impl(boolean_t*) const
    2554  {
    2555  if (is_boolean())
    2556  {
    2557  return m_value.boolean;
    2558  }
    2559  else
    2560  {
    2561  throw std::domain_error("type must be boolean, but is " + type_name());
    2562  }
    2563  }
    2564 
    2566  object_t* get_impl_ptr(object_t*) noexcept
    2567  {
    2568  return is_object() ? m_value.object : nullptr;
    2569  }
    2570 
    2572  const object_t* get_impl_ptr(const object_t*) const noexcept
    2573  {
    2574  return is_object() ? m_value.object : nullptr;
    2575  }
    2576 
    2578  array_t* get_impl_ptr(array_t*) noexcept
    2579  {
    2580  return is_array() ? m_value.array : nullptr;
    2581  }
    2582 
    2584  const array_t* get_impl_ptr(const array_t*) const noexcept
    2585  {
    2586  return is_array() ? m_value.array : nullptr;
    2587  }
    2588 
    2590  string_t* get_impl_ptr(string_t*) noexcept
    2591  {
    2592  return is_string() ? m_value.string : nullptr;
    2593  }
    2594 
    2596  const string_t* get_impl_ptr(const string_t*) const noexcept
    2597  {
    2598  return is_string() ? m_value.string : nullptr;
    2599  }
    2600 
    2602  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2603  {
    2604  return is_boolean() ? &m_value.boolean : nullptr;
    2605  }
    2606 
    2608  const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2609  {
    2610  return is_boolean() ? &m_value.boolean : nullptr;
    2611  }
    2612 
    2614  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2615  {
    2616  return is_number_integer() ? &m_value.number_integer : nullptr;
    2617  }
    2618 
    2620  const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2621  {
    2622  return is_number_integer() ? &m_value.number_integer : nullptr;
    2623  }
    2624 
    2626  number_unsigned_t* get_impl_ptr(number_unsigned_t*) noexcept
    2627  {
    2628  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2629  }
    2630 
    2632  const number_unsigned_t* get_impl_ptr(const number_unsigned_t*) const noexcept
    2633  {
    2634  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2635  }
    2636 
    2638  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2639  {
    2640  return is_number_float() ? &m_value.number_float : nullptr;
    2641  }
    2642 
    2644  const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2645  {
    2646  return is_number_float() ? &m_value.number_float : nullptr;
    2647  }
    2648 
    2660  template<typename ReferenceType, typename ThisType>
    2661  static ReferenceType get_ref_impl(ThisType& obj)
    2662  {
    2663  // delegate the call to get_ptr<>()
    2664  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2665  auto ptr = obj.template get_ptr<PointerType>();
    2666 
    2667  if (ptr != nullptr)
    2668  {
    2669  return *ptr;
    2670  }
    2671  else
    2672  {
    2673  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2674  obj.type_name());
    2675  }
    2676  }
    2677 
    2678  public:
    2679 
    2682 
    2716  template<typename ValueType, typename
    2717  std::enable_if<
    2718  not std::is_pointer<ValueType>::value
    2719  , int>::type = 0>
    2720  ValueType get() const
    2721  {
    2722  return get_impl(static_cast<ValueType*>(nullptr));
    2723  }
    2724 
    2751  template<typename PointerType, typename
    2752  std::enable_if<
    2753  std::is_pointer<PointerType>::value
    2754  , int>::type = 0>
    2755  PointerType get() noexcept
    2756  {
    2757  // delegate the call to get_ptr
    2758  return get_ptr<PointerType>();
    2759  }
    2760 
    2765  template<typename PointerType, typename
    2766  std::enable_if<
    2767  std::is_pointer<PointerType>::value
    2768  , int>::type = 0>
    2769  const PointerType get() const noexcept
    2770  {
    2771  // delegate the call to get_ptr
    2772  return get_ptr<PointerType>();
    2773  }
    2774 
    2800  template<typename PointerType, typename
    2801  std::enable_if<
    2802  std::is_pointer<PointerType>::value
    2803  , int>::type = 0>
    2804  PointerType get_ptr() noexcept
    2805  {
    2806  // delegate the call to get_impl_ptr<>()
    2807  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2808  }
    2809 
    2814  template<typename PointerType, typename
    2815  std::enable_if<
    2816  std::is_pointer<PointerType>::value
    2817  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2818  , int>::type = 0>
    2819  const PointerType get_ptr() const noexcept
    2820  {
    2821  // delegate the call to get_impl_ptr<>() const
    2822  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2823  }
    2824 
    2851  template<typename ReferenceType, typename
    2852  std::enable_if<
    2853  std::is_reference<ReferenceType>::value
    2854  , int>::type = 0>
    2855  ReferenceType get_ref()
    2856  {
    2857  // delegate call to get_ref_impl
    2858  return get_ref_impl<ReferenceType>(*this);
    2859  }
    2860 
    2865  template<typename ReferenceType, typename
    2866  std::enable_if<
    2867  std::is_reference<ReferenceType>::value
    2868  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2869  , int>::type = 0>
    2870  ReferenceType get_ref() const
    2871  {
    2872  // delegate call to get_ref_impl
    2873  return get_ref_impl<ReferenceType>(*this);
    2874  }
    2875 
    2904  template < typename ValueType, typename
    2905  std::enable_if <
    2906  not std::is_pointer<ValueType>::value
    2907  and not std::is_same<ValueType, typename string_t::value_type>::value
    2908 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2909  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2910 #endif
    2911  , int >::type = 0 >
    2912  operator ValueType() const
    2913  {
    2914  // delegate the call to get<>() const
    2915  return get<ValueType>();
    2916  }
    2917 
    2919 
    2920 
    2922  // element access //
    2924 
    2927 
    2951  {
    2952  // at only works for arrays
    2953  if (is_array())
    2954  {
    2955  try
    2956  {
    2957  assert(m_value.array != nullptr);
    2958  return m_value.array->at(idx);
    2959  }
    2960  catch (std::out_of_range&)
    2961  {
    2962  // create better exception explanation
    2963  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2964  }
    2965  }
    2966  else
    2967  {
    2968  throw std::domain_error("cannot use at() with " + type_name());
    2969  }
    2970  }
    2971 
    2995  {
    2996  // at only works for arrays
    2997  if (is_array())
    2998  {
    2999  try
    3000  {
    3001  assert(m_value.array != nullptr);
    3002  return m_value.array->at(idx);
    3003  }
    3004  catch (std::out_of_range&)
    3005  {
    3006  // create better exception explanation
    3007  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3008  }
    3009  }
    3010  else
    3011  {
    3012  throw std::domain_error("cannot use at() with " + type_name());
    3013  }
    3014  }
    3015 
    3042  reference at(const typename object_t::key_type& key)
    3043  {
    3044  // at only works for objects
    3045  if (is_object())
    3046  {
    3047  try
    3048  {
    3049  assert(m_value.object != nullptr);
    3050  return m_value.object->at(key);
    3051  }
    3052  catch (std::out_of_range&)
    3053  {
    3054  // create better exception explanation
    3055  throw std::out_of_range("key '" + key + "' not found");
    3056  }
    3057  }
    3058  else
    3059  {
    3060  throw std::domain_error("cannot use at() with " + type_name());
    3061  }
    3062  }
    3063 
    3090  const_reference at(const typename object_t::key_type& key) const
    3091  {
    3092  // at only works for objects
    3093  if (is_object())
    3094  {
    3095  try
    3096  {
    3097  assert(m_value.object != nullptr);
    3098  return m_value.object->at(key);
    3099  }
    3100  catch (std::out_of_range&)
    3101  {
    3102  // create better exception explanation
    3103  throw std::out_of_range("key '" + key + "' not found");
    3104  }
    3105  }
    3106  else
    3107  {
    3108  throw std::domain_error("cannot use at() with " + type_name());
    3109  }
    3110  }
    3111 
    3138  {
    3139  // implicitly convert null to object
    3140  if (is_null())
    3141  {
    3142  m_type = value_t::array;
    3143  m_value.array = create<array_t>();
    3144  }
    3145 
    3146  // [] only works for arrays
    3147  if (is_array())
    3148  {
    3149  assert(m_value.array != nullptr);
    3150  for (size_t i = m_value.array->size(); i <= idx; ++i)
    3151  {
    3152  m_value.array->push_back(basic_json());
    3153  }
    3154 
    3155  return m_value.array->operator[](idx);
    3156  }
    3157  else
    3158  {
    3159  throw std::domain_error("cannot use operator[] with " + type_name());
    3160  }
    3161  }
    3162 
    3183  {
    3184  // at only works for arrays
    3185  if (is_array())
    3186  {
    3187  assert(m_value.array != nullptr);
    3188  return m_value.array->operator[](idx);
    3189  }
    3190  else
    3191  {
    3192  throw std::domain_error("cannot use operator[] with " + type_name());
    3193  }
    3194  }
    3195 
    3223  reference operator[](const typename object_t::key_type& key)
    3224  {
    3225  // implicitly convert null to object
    3226  if (is_null())
    3227  {
    3228  m_type = value_t::object;
    3229  m_value.object = create<object_t>();
    3230  }
    3231 
    3232  // [] only works for objects
    3233  if (is_object())
    3234  {
    3235  assert(m_value.object != nullptr);
    3236  return m_value.object->operator[](key);
    3237  }
    3238  else
    3239  {
    3240  throw std::domain_error("cannot use operator[] with " + type_name());
    3241  }
    3242  }
    3243 
    3271  const_reference operator[](const typename object_t::key_type& key) const
    3272  {
    3273  // [] only works for objects
    3274  if (is_object())
    3275  {
    3276  assert(m_value.object != nullptr);
    3277  assert(m_value.object->find(key) != m_value.object->end());
    3278  return m_value.object->find(key)->second;
    3279  }
    3280  else
    3281  {
    3282  throw std::domain_error("cannot use operator[] with " + type_name());
    3283  }
    3284  }
    3285 
    3313  template<typename T, std::size_t n>
    3314  reference operator[](T * (&key)[n])
    3315  {
    3316  return operator[](static_cast<const T>(key));
    3317  }
    3318 
    3348  template<typename T, std::size_t n>
    3349  const_reference operator[](T * (&key)[n]) const
    3350  {
    3351  return operator[](static_cast<const T>(key));
    3352  }
    3353 
    3381  template<typename T>
    3383  {
    3384  // implicitly convert null to object
    3385  if (is_null())
    3386  {
    3387  m_type = value_t::object;
    3388  m_value = value_t::object;
    3389  }
    3390 
    3391  // at only works for objects
    3392  if (is_object())
    3393  {
    3394  assert(m_value.object != nullptr);
    3395  return m_value.object->operator[](key);
    3396  }
    3397  else
    3398  {
    3399  throw std::domain_error("cannot use operator[] with " + type_name());
    3400  }
    3401  }
    3402 
    3430  template<typename T>
    3432  {
    3433  // at only works for objects
    3434  if (is_object())
    3435  {
    3436  assert(m_value.object != nullptr);
    3437  assert(m_value.object->find(key) != m_value.object->end());
    3438  return m_value.object->find(key)->second;
    3439  }
    3440  else
    3441  {
    3442  throw std::domain_error("cannot use operator[] with " + type_name());
    3443  }
    3444  }
    3445 
    3494  template <class ValueType, typename
    3495  std::enable_if<
    3496  std::is_convertible<basic_json_t, ValueType>::value
    3497  , int>::type = 0>
    3498  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3499  {
    3500  // at only works for objects
    3501  if (is_object())
    3502  {
    3503  // if key is found, return value and given default value otherwise
    3504  const auto it = find(key);
    3505  if (it != end())
    3506  {
    3507  return *it;
    3508  }
    3509  else
    3510  {
    3511  return default_value;
    3512  }
    3513  }
    3514  else
    3515  {
    3516  throw std::domain_error("cannot use value() with " + type_name());
    3517  }
    3518  }
    3519 
    3524  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3525  {
    3526  return value(key, string_t(default_value));
    3527  }
    3528 
    3550  {
    3551  return *begin();
    3552  }
    3553 
    3558  {
    3559  return *cbegin();
    3560  }
    3561 
    3584  {
    3585  auto tmp = end();
    3586  --tmp;
    3587  return *tmp;
    3588  }
    3589 
    3594  {
    3595  auto tmp = cend();
    3596  --tmp;
    3597  return *tmp;
    3598  }
    3599 
    3644  template <class InteratorType, typename
    3645  std::enable_if<
    3646  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3647  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3648  , int>::type
    3649  = 0>
    3650  InteratorType erase(InteratorType pos)
    3651  {
    3652  // make sure iterator fits the current value
    3653  if (this != pos.m_object)
    3654  {
    3655  throw std::domain_error("iterator does not fit current value");
    3656  }
    3657 
    3658  InteratorType result = end();
    3659 
    3660  switch (m_type)
    3661  {
    3662  case value_t::boolean:
    3663  case value_t::number_float:
    3664  case value_t::number_integer:
    3665  case value_t::number_unsigned:
    3666  case value_t::string:
    3667  {
    3668  if (not pos.m_it.primitive_iterator.is_begin())
    3669  {
    3670  throw std::out_of_range("iterator out of range");
    3671  }
    3672 
    3673  if (is_string())
    3674  {
    3675  delete m_value.string;
    3676  m_value.string = nullptr;
    3677  }
    3678 
    3679  m_type = value_t::null;
    3680  break;
    3681  }
    3682 
    3683  case value_t::object:
    3684  {
    3685  assert(m_value.object != nullptr);
    3686  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3687  break;
    3688  }
    3689 
    3690  case value_t::array:
    3691  {
    3692  assert(m_value.array != nullptr);
    3693  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3694  break;
    3695  }
    3696 
    3697  default:
    3698  {
    3699  throw std::domain_error("cannot use erase() with " + type_name());
    3700  }
    3701  }
    3702 
    3703  return result;
    3704  }
    3705 
    3750  template <class InteratorType, typename
    3751  std::enable_if<
    3752  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3753  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3754  , int>::type
    3755  = 0>
    3756  InteratorType erase(InteratorType first, InteratorType last)
    3757  {
    3758  // make sure iterator fits the current value
    3759  if (this != first.m_object or this != last.m_object)
    3760  {
    3761  throw std::domain_error("iterators do not fit current value");
    3762  }
    3763 
    3764  InteratorType result = end();
    3765 
    3766  switch (m_type)
    3767  {
    3768  case value_t::boolean:
    3769  case value_t::number_float:
    3770  case value_t::number_integer:
    3771  case value_t::number_unsigned:
    3772  case value_t::string:
    3773  {
    3774  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3775  {
    3776  throw std::out_of_range("iterators out of range");
    3777  }
    3778 
    3779  if (is_string())
    3780  {
    3781  delete m_value.string;
    3782  m_value.string = nullptr;
    3783  }
    3784 
    3785  m_type = value_t::null;
    3786  break;
    3787  }
    3788 
    3789  case value_t::object:
    3790  {
    3791  assert(m_value.object != nullptr);
    3792  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3793  last.m_it.object_iterator);
    3794  break;
    3795  }
    3796 
    3797  case value_t::array:
    3798  {
    3799  assert(m_value.array != nullptr);
    3800  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3801  last.m_it.array_iterator);
    3802  break;
    3803  }
    3804 
    3805  default:
    3806  {
    3807  throw std::domain_error("cannot use erase() with " + type_name());
    3808  }
    3809  }
    3810 
    3811  return result;
    3812  }
    3813 
    3840  size_type erase(const typename object_t::key_type& key)
    3841  {
    3842  // this erase only works for objects
    3843  if (is_object())
    3844  {
    3845  assert(m_value.object != nullptr);
    3846  return m_value.object->erase(key);
    3847  }
    3848  else
    3849  {
    3850  throw std::domain_error("cannot use erase() with " + type_name());
    3851  }
    3852  }
    3853 
    3878  void erase(const size_type idx)
    3879  {
    3880  // this erase only works for arrays
    3881  if (is_array())
    3882  {
    3883  if (idx >= size())
    3884  {
    3885  throw std::out_of_range("index out of range");
    3886  }
    3887 
    3888  assert(m_value.array != nullptr);
    3889  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3890  }
    3891  else
    3892  {
    3893  throw std::domain_error("cannot use erase() with " + type_name());
    3894  }
    3895  }
    3896 
    3914  iterator find(typename object_t::key_type key)
    3915  {
    3916  auto result = end();
    3917 
    3918  if (is_object())
    3919  {
    3920  assert(m_value.object != nullptr);
    3921  result.m_it.object_iterator = m_value.object->find(key);
    3922  }
    3923 
    3924  return result;
    3925  }
    3926 
    3931  const_iterator find(typename object_t::key_type key) const
    3932  {
    3933  auto result = cend();
    3934 
    3935  if (is_object())
    3936  {
    3937  assert(m_value.object != nullptr);
    3938  result.m_it.object_iterator = m_value.object->find(key);
    3939  }
    3940 
    3941  return result;
    3942  }
    3943 
    3962  size_type count(typename object_t::key_type key) const
    3963  {
    3964  // return 0 for all nonobject types
    3965  assert(not is_object() or m_value.object != nullptr);
    3966  return is_object() ? m_value.object->count(key) : 0;
    3967  }
    3968 
    3970 
    3971 
    3973  // iterators //
    3975 
    3978 
    3998  {
    3999  iterator result(this);
    4000  result.set_begin();
    4001  return result;
    4002  }
    4003 
    4008  {
    4009  return cbegin();
    4010  }
    4011 
    4032  {
    4033  const_iterator result(this);
    4034  result.set_begin();
    4035  return result;
    4036  }
    4037 
    4057  {
    4058  iterator result(this);
    4059  result.set_end();
    4060  return result;
    4061  }
    4062 
    4067  {
    4068  return cend();
    4069  }
    4070 
    4091  {
    4092  const_iterator result(this);
    4093  result.set_end();
    4094  return result;
    4095  }
    4096 
    4115  {
    4116  return reverse_iterator(end());
    4117  }
    4118 
    4123  {
    4124  return crbegin();
    4125  }
    4126 
    4146  {
    4147  return reverse_iterator(begin());
    4148  }
    4149 
    4154  {
    4155  return crend();
    4156  }
    4157 
    4177  {
    4178  return const_reverse_iterator(cend());
    4179  }
    4180 
    4200  {
    4201  return const_reverse_iterator(cbegin());
    4202  }
    4203 
    4204  private:
    4205  // forward declaration
    4206  template<typename IteratorType> class iteration_proxy;
    4207 
    4208  public:
    4220  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    4221  {
    4222  return iteration_proxy<iterator>(cont);
    4223  }
    4224 
    4228  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4229  {
    4230  return iteration_proxy<const_iterator>(cont);
    4231  }
    4232 
    4234 
    4235 
    4237  // capacity //
    4239 
    4242 
    4272  bool empty() const noexcept
    4273  {
    4274  switch (m_type)
    4275  {
    4276  case value_t::null:
    4277  {
    4278  // null values are empty
    4279  return true;
    4280  }
    4281 
    4282  case value_t::array:
    4283  {
    4284  assert(m_value.array != nullptr);
    4285  return m_value.array->empty();
    4286  }
    4287 
    4288  case value_t::object:
    4289  {
    4290  assert(m_value.object != nullptr);
    4291  return m_value.object->empty();
    4292  }
    4293 
    4294  default:
    4295  {
    4296  // all other types are nonempty
    4297  return false;
    4298  }
    4299  }
    4300  }
    4301 
    4330  size_type size() const noexcept
    4331  {
    4332  switch (m_type)
    4333  {
    4334  case value_t::null:
    4335  {
    4336  // null values are empty
    4337  return 0;
    4338  }
    4339 
    4340  case value_t::array:
    4341  {
    4342  assert(m_value.array != nullptr);
    4343  return m_value.array->size();
    4344  }
    4345 
    4346  case value_t::object:
    4347  {
    4348  assert(m_value.object != nullptr);
    4349  return m_value.object->size();
    4350  }
    4351 
    4352  default:
    4353  {
    4354  // all other types have size 1
    4355  return 1;
    4356  }
    4357  }
    4358  }
    4359 
    4392  size_type max_size() const noexcept
    4393  {
    4394  switch (m_type)
    4395  {
    4396  case value_t::array:
    4397  {
    4398  assert(m_value.array != nullptr);
    4399  return m_value.array->max_size();
    4400  }
    4401 
    4402  case value_t::object:
    4403  {
    4404  assert(m_value.object != nullptr);
    4405  return m_value.object->max_size();
    4406  }
    4407 
    4408  default:
    4409  {
    4410  // all other types have max_size() == size()
    4411  return size();
    4412  }
    4413  }
    4414  }
    4415 
    4417 
    4418 
    4420  // modifiers //
    4422 
    4425 
    4451  void clear() noexcept
    4452  {
    4453  switch (m_type)
    4454  {
    4455  case value_t::number_integer:
    4456  {
    4457  m_value.number_integer = 0;
    4458  break;
    4459  }
    4460 
    4461  case value_t::number_unsigned:
    4462  {
    4463  m_value.number_unsigned = 0;
    4464  break;
    4465  }
    4466 
    4467  case value_t::number_float:
    4468  {
    4469  m_value.number_float = 0.0;
    4470  break;
    4471  }
    4472 
    4473  case value_t::boolean:
    4474  {
    4475  m_value.boolean = false;
    4476  break;
    4477  }
    4478 
    4479  case value_t::string:
    4480  {
    4481  assert(m_value.string != nullptr);
    4482  m_value.string->clear();
    4483  break;
    4484  }
    4485 
    4486  case value_t::array:
    4487  {
    4488  assert(m_value.array != nullptr);
    4489  m_value.array->clear();
    4490  break;
    4491  }
    4492 
    4493  case value_t::object:
    4494  {
    4495  assert(m_value.object != nullptr);
    4496  m_value.object->clear();
    4497  break;
    4498  }
    4499 
    4500  default:
    4501  {
    4502  break;
    4503  }
    4504  }
    4505  }
    4506 
    4527  void push_back(basic_json&& val)
    4528  {
    4529  // push_back only works for null objects or arrays
    4530  if (not(is_null() or is_array()))
    4531  {
    4532  throw std::domain_error("cannot use push_back() with " + type_name());
    4533  }
    4534 
    4535  // transform null object into an array
    4536  if (is_null())
    4537  {
    4538  m_type = value_t::array;
    4539  m_value = value_t::array;
    4540  }
    4541 
    4542  // add element to array (move semantics)
    4543  assert(m_value.array != nullptr);
    4544  m_value.array->push_back(std::move(val));
    4545  // invalidate object
    4546  val.m_type = value_t::null;
    4547  }
    4548 
    4553  reference operator+=(basic_json&& val)
    4554  {
    4555  push_back(std::move(val));
    4556  return *this;
    4557  }
    4558 
    4563  void push_back(const basic_json& val)
    4564  {
    4565  // push_back only works for null objects or arrays
    4566  if (not(is_null() or is_array()))
    4567  {
    4568  throw std::domain_error("cannot use push_back() with " + type_name());
    4569  }
    4570 
    4571  // transform null object into an array
    4572  if (is_null())
    4573  {
    4574  m_type = value_t::array;
    4575  m_value = value_t::array;
    4576  }
    4577 
    4578  // add element to array
    4579  assert(m_value.array != nullptr);
    4580  m_value.array->push_back(val);
    4581  }
    4582 
    4587  reference operator+=(const basic_json& val)
    4588  {
    4589  push_back(val);
    4590  return *this;
    4591  }
    4592 
    4613  void push_back(const typename object_t::value_type& val)
    4614  {
    4615  // push_back only works for null objects or objects
    4616  if (not(is_null() or is_object()))
    4617  {
    4618  throw std::domain_error("cannot use push_back() with " + type_name());
    4619  }
    4620 
    4621  // transform null object into an object
    4622  if (is_null())
    4623  {
    4624  m_type = value_t::object;
    4625  m_value = value_t::object;
    4626  }
    4627 
    4628  // add element to array
    4629  assert(m_value.object != nullptr);
    4630  m_value.object->insert(val);
    4631  }
    4632 
    4637  reference operator+=(const typename object_t::value_type& val)
    4638  {
    4639  push_back(val);
    4640  return operator[](val.first);
    4641  }
    4642 
    4665  iterator insert(const_iterator pos, const basic_json& val)
    4666  {
    4667  // insert only works for arrays
    4668  if (is_array())
    4669  {
    4670  // check if iterator pos fits to this JSON value
    4671  if (pos.m_object != this)
    4672  {
    4673  throw std::domain_error("iterator does not fit current value");
    4674  }
    4675 
    4676  // insert to array and return iterator
    4677  iterator result(this);
    4678  assert(m_value.array != nullptr);
    4679  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4680  return result;
    4681  }
    4682  else
    4683  {
    4684  throw std::domain_error("cannot use insert() with " + type_name());
    4685  }
    4686  }
    4687 
    4692  iterator insert(const_iterator pos, basic_json&& val)
    4693  {
    4694  return insert(pos, val);
    4695  }
    4696 
    4721  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4722  {
    4723  // insert only works for arrays
    4724  if (is_array())
    4725  {
    4726  // check if iterator pos fits to this JSON value
    4727  if (pos.m_object != this)
    4728  {
    4729  throw std::domain_error("iterator does not fit current value");
    4730  }
    4731 
    4732  // insert to array and return iterator
    4733  iterator result(this);
    4734  assert(m_value.array != nullptr);
    4735  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4736  return result;
    4737  }
    4738  else
    4739  {
    4740  throw std::domain_error("cannot use insert() with " + type_name());
    4741  }
    4742  }
    4743 
    4775  {
    4776  // insert only works for arrays
    4777  if (not is_array())
    4778  {
    4779  throw std::domain_error("cannot use insert() with " + type_name());
    4780  }
    4781 
    4782  // check if iterator pos fits to this JSON value
    4783  if (pos.m_object != this)
    4784  {
    4785  throw std::domain_error("iterator does not fit current value");
    4786  }
    4787 
    4788  if (first.m_object != last.m_object)
    4789  {
    4790  throw std::domain_error("iterators do not fit");
    4791  }
    4792 
    4793  if (first.m_object == this or last.m_object == this)
    4794  {
    4795  throw std::domain_error("passed iterators may not belong to container");
    4796  }
    4797 
    4798  // insert to array and return iterator
    4799  iterator result(this);
    4800  assert(m_value.array != nullptr);
    4801  result.m_it.array_iterator = m_value.array->insert(
    4802  pos.m_it.array_iterator,
    4803  first.m_it.array_iterator,
    4804  last.m_it.array_iterator);
    4805  return result;
    4806  }
    4807 
    4832  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4833  {
    4834  // insert only works for arrays
    4835  if (not is_array())
    4836  {
    4837  throw std::domain_error("cannot use insert() with " + type_name());
    4838  }
    4839 
    4840  // check if iterator pos fits to this JSON value
    4841  if (pos.m_object != this)
    4842  {
    4843  throw std::domain_error("iterator does not fit current value");
    4844  }
    4845 
    4846  // insert to array and return iterator
    4847  iterator result(this);
    4848  assert(m_value.array != nullptr);
    4849  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4850  return result;
    4851  }
    4852 
    4870  void swap(reference other) noexcept (
    4871  std::is_nothrow_move_constructible<value_t>::value and
    4872  std::is_nothrow_move_assignable<value_t>::value and
    4873  std::is_nothrow_move_constructible<json_value>::value and
    4874  std::is_nothrow_move_assignable<json_value>::value
    4875  )
    4876  {
    4877  std::swap(m_type, other.m_type);
    4878  std::swap(m_value, other.m_value);
    4879  }
    4880 
    4901  void swap(array_t& other)
    4902  {
    4903  // swap only works for arrays
    4904  if (is_array())
    4905  {
    4906  assert(m_value.array != nullptr);
    4907  std::swap(*(m_value.array), other);
    4908  }
    4909  else
    4910  {
    4911  throw std::domain_error("cannot use swap() with " + type_name());
    4912  }
    4913  }
    4914 
    4935  void swap(object_t& other)
    4936  {
    4937  // swap only works for objects
    4938  if (is_object())
    4939  {
    4940  assert(m_value.object != nullptr);
    4941  std::swap(*(m_value.object), other);
    4942  }
    4943  else
    4944  {
    4945  throw std::domain_error("cannot use swap() with " + type_name());
    4946  }
    4947  }
    4948 
    4969  void swap(string_t& other)
    4970  {
    4971  // swap only works for strings
    4972  if (is_string())
    4973  {
    4974  assert(m_value.string != nullptr);
    4975  std::swap(*(m_value.string), other);
    4976  }
    4977  else
    4978  {
    4979  throw std::domain_error("cannot use swap() with " + type_name());
    4980  }
    4981  }
    4982 
    4984 
    4985 
    4987  // lexicographical comparison operators //
    4989 
    4992 
    4993  private:
    5003  friend bool operator<(const value_t lhs, const value_t rhs)
    5004  {
    5005  static constexpr std::array<uint8_t, 8> order = {{
    5006  0, // null
    5007  3, // object
    5008  4, // array
    5009  5, // string
    5010  1, // boolean
    5011  2, // integer
    5012  2, // unsigned
    5013  2, // float
    5014  }
    5015  };
    5016 
    5017  // discarded values are not comparable
    5018  if (lhs == value_t::discarded or rhs == value_t::discarded)
    5019  {
    5020  return false;
    5021  }
    5022 
    5023  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    5024  }
    5025 
    5026  public:
    5050  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    5051  {
    5052  const auto lhs_type = lhs.type();
    5053  const auto rhs_type = rhs.type();
    5054 
    5055  if (lhs_type == rhs_type)
    5056  {
    5057  switch (lhs_type)
    5058  {
    5059  case value_t::array:
    5060  {
    5061  assert(lhs.m_value.array != nullptr);
    5062  assert(rhs.m_value.array != nullptr);
    5063  return *lhs.m_value.array == *rhs.m_value.array;
    5064  }
    5065  case value_t::object:
    5066  {
    5067  assert(lhs.m_value.object != nullptr);
    5068  assert(rhs.m_value.object != nullptr);
    5069  return *lhs.m_value.object == *rhs.m_value.object;
    5070  }
    5071  case value_t::null:
    5072  {
    5073  return true;
    5074  }
    5075  case value_t::string:
    5076  {
    5077  assert(lhs.m_value.string != nullptr);
    5078  assert(rhs.m_value.string != nullptr);
    5079  return *lhs.m_value.string == *rhs.m_value.string;
    5080  }
    5081  case value_t::boolean:
    5082  {
    5083  return lhs.m_value.boolean == rhs.m_value.boolean;
    5084  }
    5085  case value_t::number_integer:
    5086  {
    5087  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    5088  }
    5089  case value_t::number_unsigned:
    5090  {
    5091  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
    5092  }
    5093  case value_t::number_float:
    5094  {
    5095  return lhs.m_value.number_float == rhs.m_value.number_float;
    5096  }
    5097  default:
    5098  {
    5099  return false;
    5100  }
    5101  }
    5102  }
    5103  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5104  {
    5105  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    5106  }
    5107  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5108  {
    5109  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    5110  }
    5111  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5112  {
    5113  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
    5114  }
    5115  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5116  {
    5117  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5118  }
    5119  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5120  {
    5121  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
    5122  }
    5123  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5124  {
    5125  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5126  }
    5127 
    5128  return false;
    5129  }
    5130 
    5149  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    5150  {
    5151  return v.is_null();
    5152  }
    5153 
    5158  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    5159  {
    5160  return v.is_null();
    5161  }
    5162 
    5179  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    5180  {
    5181  return not (lhs == rhs);
    5182  }
    5183 
    5202  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    5203  {
    5204  return not v.is_null();
    5205  }
    5206 
    5211  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    5212  {
    5213  return not v.is_null();
    5214  }
    5215 
    5240  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    5241  {
    5242  const auto lhs_type = lhs.type();
    5243  const auto rhs_type = rhs.type();
    5244 
    5245  if (lhs_type == rhs_type)
    5246  {
    5247  switch (lhs_type)
    5248  {
    5249  case value_t::array:
    5250  {
    5251  assert(lhs.m_value.array != nullptr);
    5252  assert(rhs.m_value.array != nullptr);
    5253  return *lhs.m_value.array < *rhs.m_value.array;
    5254  }
    5255  case value_t::object:
    5256  {
    5257  assert(lhs.m_value.object != nullptr);
    5258  assert(rhs.m_value.object != nullptr);
    5259  return *lhs.m_value.object < *rhs.m_value.object;
    5260  }
    5261  case value_t::null:
    5262  {
    5263  return false;
    5264  }
    5265  case value_t::string:
    5266  {
    5267  assert(lhs.m_value.string != nullptr);
    5268  assert(rhs.m_value.string != nullptr);
    5269  return *lhs.m_value.string < *rhs.m_value.string;
    5270  }
    5271  case value_t::boolean:
    5272  {
    5273  return lhs.m_value.boolean < rhs.m_value.boolean;
    5274  }
    5275  case value_t::number_integer:
    5276  {
    5277  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5278  }
    5279  case value_t::number_unsigned:
    5280  {
    5281  return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
    5282  }
    5283  case value_t::number_float:
    5284  {
    5285  return lhs.m_value.number_float < rhs.m_value.number_float;
    5286  }
    5287  default:
    5288  {
    5289  return false;
    5290  }
    5291  }
    5292  }
    5293  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5294  {
    5295  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
    5296  }
    5297  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5298  {
    5299  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
    5300  }
    5301  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5302  {
    5303  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
    5304  }
    5305  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5306  {
    5307  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5308  }
    5309  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5310  {
    5311  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5312  }
    5313  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5314  {
    5315  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
    5316  }
    5317 
    5318  // We only reach this line if we cannot compare values. In that case,
    5319  // we compare types. Note we have to call the operator explicitly,
    5320  // because MSVC has problems otherwise.
    5321  return operator<(lhs_type, rhs_type);
    5322  }
    5323 
    5341  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5342  {
    5343  return not (rhs < lhs);
    5344  }
    5345 
    5363  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5364  {
    5365  return not (lhs <= rhs);
    5366  }
    5367 
    5385  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5386  {
    5387  return not (lhs < rhs);
    5388  }
    5389 
    5391 
    5392 
    5394  // serialization //
    5396 
    5399 
    5422  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5423  {
    5424  // read width member and use it as indentation parameter if nonzero
    5425  const bool pretty_print = (o.width() > 0);
    5426  const auto indentation = (pretty_print ? o.width() : 0);
    5427 
    5428  // reset width to 0 for subsequent calls to this stream
    5429  o.width(0);
    5430 
    5431  // do the actual serialization
    5432  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5433  return o;
    5434  }
    5435 
    5440  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5441  {
    5442  return o << j;
    5443  }
    5444 
    5446 
    5447 
    5449  // deserialization //
    5451 
    5454 
    5479  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5480  {
    5481  return parser(s, cb).parse();
    5482  }
    5483 
    5508  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5509  {
    5510  return parser(i, cb).parse();
    5511  }
    5512 
    5516  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5517  {
    5518  return parser(i, cb).parse();
    5519  }
    5520 
    5544  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5545  {
    5546  j = parser(i).parse();
    5547  return i;
    5548  }
    5549 
    5554  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5555  {
    5556  j = parser(i).parse();
    5557  return i;
    5558  }
    5559 
    5561 
    5562 
    5563  private:
    5565  // convenience functions //
    5567 
    5569  string_t type_name() const
    5570  {
    5571  switch (m_type)
    5572  {
    5573  case value_t::null:
    5574  return "null";
    5575  case value_t::object:
    5576  return "object";
    5577  case value_t::array:
    5578  return "array";
    5579  case value_t::string:
    5580  return "string";
    5581  case value_t::boolean:
    5582  return "boolean";
    5583  case value_t::discarded:
    5584  return "discarded";
    5585  default:
    5586  return "number";
    5587  }
    5588  }
    5589 
    5598  static std::size_t extra_space(const string_t& s) noexcept
    5599  {
    5600  std::size_t result = 0;
    5601 
    5602  for (const auto& c : s)
    5603  {
    5604  switch (c)
    5605  {
    5606  case '"':
    5607  case '\\':
    5608  case '\b':
    5609  case '\f':
    5610  case '\n':
    5611  case '\r':
    5612  case '\t':
    5613  {
    5614  // from c (1 byte) to \x (2 bytes)
    5615  result += 1;
    5616  break;
    5617  }
    5618 
    5619  default:
    5620  {
    5621  if (c >= 0x00 and c <= 0x1f)
    5622  {
    5623  // from c (1 byte) to \uxxxx (6 bytes)
    5624  result += 5;
    5625  }
    5626  break;
    5627  }
    5628  }
    5629  }
    5630 
    5631  return result;
    5632  }
    5633 
    5647  static string_t escape_string(const string_t& s) noexcept
    5648  {
    5649  const auto space = extra_space(s);
    5650  if (space == 0)
    5651  {
    5652  return s;
    5653  }
    5654 
    5655  // create a result string of necessary size
    5656  string_t result(s.size() + space, '\\');
    5657  std::size_t pos = 0;
    5658 
    5659  for (const auto& c : s)
    5660  {
    5661  switch (c)
    5662  {
    5663  // quotation mark (0x22)
    5664  case '"':
    5665  {
    5666  result[pos + 1] = '"';
    5667  pos += 2;
    5668  break;
    5669  }
    5670 
    5671  // reverse solidus (0x5c)
    5672  case '\\':
    5673  {
    5674  // nothing to change
    5675  pos += 2;
    5676  break;
    5677  }
    5678 
    5679  // backspace (0x08)
    5680  case '\b':
    5681  {
    5682  result[pos + 1] = 'b';
    5683  pos += 2;
    5684  break;
    5685  }
    5686 
    5687  // formfeed (0x0c)
    5688  case '\f':
    5689  {
    5690  result[pos + 1] = 'f';
    5691  pos += 2;
    5692  break;
    5693  }
    5694 
    5695  // newline (0x0a)
    5696  case '\n':
    5697  {
    5698  result[pos + 1] = 'n';
    5699  pos += 2;
    5700  break;
    5701  }
    5702 
    5703  // carriage return (0x0d)
    5704  case '\r':
    5705  {
    5706  result[pos + 1] = 'r';
    5707  pos += 2;
    5708  break;
    5709  }
    5710 
    5711  // horizontal tab (0x09)
    5712  case '\t':
    5713  {
    5714  result[pos + 1] = 't';
    5715  pos += 2;
    5716  break;
    5717  }
    5718 
    5719  default:
    5720  {
    5721  if (c >= 0x00 and c <= 0x1f)
    5722  {
    5723  // convert a number 0..15 to its hex representation (0..f)
    5724  auto hexify = [](const char v) -> char
    5725  {
    5726  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5727  };
    5728 
    5729  // print character c as \uxxxx
    5730  for (const char m :
    5731  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5732  })
    5733  {
    5734  result[++pos] = m;
    5735  }
    5736 
    5737  ++pos;
    5738  }
    5739  else
    5740  {
    5741  // all other characters are added as-is
    5742  result[pos++] = c;
    5743  }
    5744  break;
    5745  }
    5746  }
    5747  }
    5748 
    5749  return result;
    5750  }
    5751 
    5769  void dump(std::ostream& o,
    5770  const bool pretty_print,
    5771  const unsigned int indent_step,
    5772  const unsigned int current_indent = 0) const
    5773  {
    5774  // variable to hold indentation for recursive calls
    5775  unsigned int new_indent = current_indent;
    5776 
    5777  switch (m_type)
    5778  {
    5779  case value_t::object:
    5780  {
    5781  assert(m_value.object != nullptr);
    5782 
    5783  if (m_value.object->empty())
    5784  {
    5785  o << "{}";
    5786  return;
    5787  }
    5788 
    5789  o << "{";
    5790 
    5791  // increase indentation
    5792  if (pretty_print)
    5793  {
    5794  new_indent += indent_step;
    5795  o << "\n";
    5796  }
    5797 
    5798  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5799  {
    5800  if (i != m_value.object->cbegin())
    5801  {
    5802  o << (pretty_print ? ",\n" : ",");
    5803  }
    5804  o << string_t(new_indent, ' ') << "\""
    5805  << escape_string(i->first) << "\":"
    5806  << (pretty_print ? " " : "");
    5807  i->second.dump(o, pretty_print, indent_step, new_indent);
    5808  }
    5809 
    5810  // decrease indentation
    5811  if (pretty_print)
    5812  {
    5813  new_indent -= indent_step;
    5814  o << "\n";
    5815  }
    5816 
    5817  o << string_t(new_indent, ' ') + "}";
    5818  return;
    5819  }
    5820 
    5821  case value_t::array:
    5822  {
    5823  assert(m_value.array != nullptr);
    5824 
    5825  if (m_value.array->empty())
    5826  {
    5827  o << "[]";
    5828  return;
    5829  }
    5830 
    5831  o << "[";
    5832 
    5833  // increase indentation
    5834  if (pretty_print)
    5835  {
    5836  new_indent += indent_step;
    5837  o << "\n";
    5838  }
    5839 
    5840  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5841  {
    5842  if (i != m_value.array->cbegin())
    5843  {
    5844  o << (pretty_print ? ",\n" : ",");
    5845  }
    5846  o << string_t(new_indent, ' ');
    5847  i->dump(o, pretty_print, indent_step, new_indent);
    5848  }
    5849 
    5850  // decrease indentation
    5851  if (pretty_print)
    5852  {
    5853  new_indent -= indent_step;
    5854  o << "\n";
    5855  }
    5856 
    5857  o << string_t(new_indent, ' ') << "]";
    5858  return;
    5859  }
    5860 
    5861  case value_t::string:
    5862  {
    5863  assert(m_value.string != nullptr);
    5864  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5865  return;
    5866  }
    5867 
    5868  case value_t::boolean:
    5869  {
    5870  o << (m_value.boolean ? "true" : "false");
    5871  return;
    5872  }
    5873 
    5874  case value_t::number_integer:
    5875  {
    5876  o << m_value.number_integer;
    5877  return;
    5878  }
    5879 
    5880  case value_t::number_unsigned:
    5881  {
    5882  o << m_value.number_unsigned;
    5883  return;
    5884  }
    5885 
    5886  case value_t::number_float:
    5887  {
    5888  // If the number is an integer then output as a fixed with with
    5889  // precision 1 to output "0.0", "1.0" etc as expected for some
    5890  // round trip tests otherwise 15 digits of precision allows
    5891  // round-trip IEEE 754 string->double->string; to be safe, we
    5892  // read this value from
    5893  // std::numeric_limits<number_float_t>::digits10
    5894  if (std::fmod(m_value.number_float, 1) == 0)
    5895  {
    5896  o << std::fixed << std::setprecision(1);
    5897  }
    5898  else
    5899  {
    5900  // std::defaultfloat not supported in gcc version < 5
    5901  o.unsetf(std::ios_base::floatfield);
    5902  o << std::setprecision(std::numeric_limits<double>::digits10);
    5903  }
    5904  o << m_value.number_float;
    5905  return;
    5906  }
    5907 
    5908  case value_t::discarded:
    5909  {
    5910  o << "<discarded>";
    5911  return;
    5912  }
    5913 
    5914  case value_t::null:
    5915  {
    5916  o << "null";
    5917  return;
    5918  }
    5919  }
    5920  }
    5921 
    5922  private:
    5924  // member variables //
    5926 
    5928  value_t m_type = value_t::null;
    5929 
    5931  json_value m_value = {};
    5932 
    5933 
    5934  private:
    5936  // iterators //
    5938 
    5948  class primitive_iterator_t
    5949  {
    5950  public:
    5952  void set_begin()
    5953  {
    5954  m_it = begin_value;
    5955  }
    5956 
    5958  void set_end()
    5959  {
    5960  m_it = end_value;
    5961  }
    5962 
    5964  bool is_begin() const
    5965  {
    5966  return (m_it == begin_value);
    5967  }
    5968 
    5970  bool is_end() const
    5971  {
    5972  return (m_it == end_value);
    5973  }
    5974 
    5976  operator difference_type& ()
    5977  {
    5978  return m_it;
    5979  }
    5980 
    5982  operator difference_type () const
    5983  {
    5984  return m_it;
    5985  }
    5986 
    5987  private:
    5988  static constexpr difference_type begin_value = 0;
    5989  static constexpr difference_type end_value = begin_value + 1;
    5990 
    5992  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    5993  };
    5994 
    6002  struct internal_iterator
    6003  {
    6005  typename object_t::iterator object_iterator;
    6007  typename array_t::iterator array_iterator;
    6009  primitive_iterator_t primitive_iterator;
    6010 
    6012  internal_iterator()
    6013  : object_iterator(), array_iterator(), primitive_iterator()
    6014  {}
    6015  };
    6016 
    6018  template<typename IteratorType>
    6019  class iteration_proxy
    6020  {
    6021  private:
    6023  class iteration_proxy_internal
    6024  {
    6025  private:
    6027  IteratorType anchor;
    6029  size_t array_index = 0;
    6030 
    6031  public:
    6032  iteration_proxy_internal(IteratorType it)
    6033  : anchor(it)
    6034  {}
    6035 
    6037  iteration_proxy_internal& operator*()
    6038  {
    6039  return *this;
    6040  }
    6041 
    6043  iteration_proxy_internal& operator++()
    6044  {
    6045  ++anchor;
    6046  ++array_index;
    6047 
    6048  return *this;
    6049  }
    6050 
    6052  bool operator!= (const iteration_proxy_internal& o) const
    6053  {
    6054  return anchor != o.anchor;
    6055  }
    6056 
    6058  typename basic_json::string_t key() const
    6059  {
    6060  assert(anchor.m_object != nullptr);
    6061 
    6062  switch (anchor.m_object->type())
    6063  {
    6064  // use integer array index as key
    6065  case value_t::array:
    6066  {
    6067  return std::to_string(array_index);
    6068  }
    6069 
    6070  // use key from the object
    6071  case value_t::object:
    6072  {
    6073  return anchor.key();
    6074  }
    6075 
    6076  // use an empty key for all primitive types
    6077  default:
    6078  {
    6079  return "";
    6080  }
    6081  }
    6082  }
    6083 
    6085  typename IteratorType::reference value() const
    6086  {
    6087  return anchor.value();
    6088  }
    6089  };
    6090 
    6092  typename IteratorType::reference container;
    6093 
    6094  public:
    6096  iteration_proxy(typename IteratorType::reference cont)
    6097  : container(cont)
    6098  {}
    6099 
    6101  iteration_proxy_internal begin()
    6102  {
    6103  return iteration_proxy_internal(container.begin());
    6104  }
    6105 
    6107  iteration_proxy_internal end()
    6108  {
    6109  return iteration_proxy_internal(container.end());
    6110  }
    6111  };
    6112 
    6113  public:
    6127  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    6128  {
    6130  friend class basic_json;
    6131 
    6132  public:
    6142  using iterator_category = std::bidirectional_iterator_tag;
    6143 
    6145  const_iterator() = default;
    6146 
    6148  const_iterator(pointer object) : m_object(object)
    6149  {
    6150  assert(m_object != nullptr);
    6151 
    6152  switch (m_object->m_type)
    6153  {
    6155  {
    6156  m_it.object_iterator = typename object_t::iterator();
    6157  break;
    6158  }
    6159 
    6161  {
    6162  m_it.array_iterator = typename array_t::iterator();
    6163  break;
    6164  }
    6165 
    6166  default:
    6167  {
    6168  m_it.primitive_iterator = primitive_iterator_t();
    6169  break;
    6170  }
    6171  }
    6172  }
    6173 
    6175  const_iterator(const iterator& other) : m_object(other.m_object)
    6176  {
    6177  assert(m_object != nullptr);
    6178 
    6179  switch (m_object->m_type)
    6180  {
    6182  {
    6183  m_it.object_iterator = other.m_it.object_iterator;
    6184  break;
    6185  }
    6186 
    6188  {
    6189  m_it.array_iterator = other.m_it.array_iterator;
    6190  break;
    6191  }
    6192 
    6193  default:
    6194  {
    6195  m_it.primitive_iterator = other.m_it.primitive_iterator;
    6196  break;
    6197  }
    6198  }
    6199  }
    6200 
    6202  const_iterator(const const_iterator& other) noexcept
    6203  : m_object(other.m_object), m_it(other.m_it)
    6204  {}
    6205 
    6208  std::is_nothrow_move_constructible<pointer>::value and
    6209  std::is_nothrow_move_assignable<pointer>::value and
    6210  std::is_nothrow_move_constructible<internal_iterator>::value and
    6211  std::is_nothrow_move_assignable<internal_iterator>::value
    6212  )
    6213  {
    6214  std::swap(m_object, other.m_object);
    6215  std::swap(m_it, other.m_it);
    6216  return *this;
    6217  }
    6218 
    6219  private:
    6221  void set_begin()
    6222  {
    6223  assert(m_object != nullptr);
    6224 
    6225  switch (m_object->m_type)
    6226  {
    6228  {
    6229  assert(m_object->m_value.object != nullptr);
    6230  m_it.object_iterator = m_object->m_value.object->begin();
    6231  break;
    6232  }
    6233 
    6235  {
    6236  assert(m_object->m_value.array != nullptr);
    6237  m_it.array_iterator = m_object->m_value.array->begin();
    6238  break;
    6239  }
    6240 
    6242  {
    6243  // set to end so begin()==end() is true: null is empty
    6244  m_it.primitive_iterator.set_end();
    6245  break;
    6246  }
    6247 
    6248  default:
    6249  {
    6250  m_it.primitive_iterator.set_begin();
    6251  break;
    6252  }
    6253  }
    6254  }
    6255 
    6257  void set_end()
    6258  {
    6259  assert(m_object != nullptr);
    6260 
    6261  switch (m_object->m_type)
    6262  {
    6264  {
    6265  assert(m_object->m_value.object != nullptr);
    6266  m_it.object_iterator = m_object->m_value.object->end();
    6267  break;
    6268  }
    6269 
    6271  {
    6272  assert(m_object->m_value.array != nullptr);
    6273  m_it.array_iterator = m_object->m_value.array->end();
    6274  break;
    6275  }
    6276 
    6277  default:
    6278  {
    6279  m_it.primitive_iterator.set_end();
    6280  break;
    6281  }
    6282  }
    6283  }
    6284 
    6285  public:
    6288  {
    6289  assert(m_object != nullptr);
    6290 
    6291  switch (m_object->m_type)
    6292  {
    6294  {
    6295  assert(m_object->m_value.object);
    6296  assert(m_it.object_iterator != m_object->m_value.object->end());
    6297  return m_it.object_iterator->second;
    6298  }
    6299 
    6301  {
    6302  assert(m_object->m_value.array);
    6303  assert(m_it.array_iterator != m_object->m_value.array->end());
    6304  return *m_it.array_iterator;
    6305  }
    6306 
    6308  {
    6309  throw std::out_of_range("cannot get value");
    6310  }
    6311 
    6312  default:
    6313  {
    6314  if (m_it.primitive_iterator.is_begin())
    6315  {
    6316  return *m_object;
    6317  }
    6318  else
    6319  {
    6320  throw std::out_of_range("cannot get value");
    6321  }
    6322  }
    6323  }
    6324  }
    6325 
    6328  {
    6329  assert(m_object != nullptr);
    6330 
    6331  switch (m_object->m_type)
    6332  {
    6334  {
    6335  assert(m_object->m_value.object);
    6336  assert(m_it.object_iterator != m_object->m_value.object->end());
    6337  return &(m_it.object_iterator->second);
    6338  }
    6339 
    6341  {
    6342  assert(m_object->m_value.array);
    6343  assert(m_it.array_iterator != m_object->m_value.array->end());
    6344  return &*m_it.array_iterator;
    6345  }
    6346 
    6347  default:
    6348  {
    6349  if (m_it.primitive_iterator.is_begin())
    6350  {
    6351  return m_object;
    6352  }
    6353  else
    6354  {
    6355  throw std::out_of_range("cannot get value");
    6356  }
    6357  }
    6358  }
    6359  }
    6360 
    6363  {
    6364  auto result = *this;
    6365  ++(*this);
    6366  return result;
    6367  }
    6368 
    6371  {
    6372  assert(m_object != nullptr);
    6373 
    6374  switch (m_object->m_type)
    6375  {
    6377  {
    6378  ++m_it.object_iterator;
    6379  break;
    6380  }
    6381 
    6383  {
    6384  ++m_it.array_iterator;
    6385  break;
    6386  }
    6387 
    6388  default:
    6389  {
    6390  ++m_it.primitive_iterator;
    6391  break;
    6392  }
    6393  }
    6394 
    6395  return *this;
    6396  }
    6397 
    6400  {
    6401  auto result = *this;
    6402  --(*this);
    6403  return result;
    6404  }
    6405 
    6408  {
    6409  assert(m_object != nullptr);
    6410 
    6411  switch (m_object->m_type)
    6412  {
    6414  {
    6415  --m_it.object_iterator;
    6416  break;
    6417  }
    6418 
    6420  {
    6421  --m_it.array_iterator;
    6422  break;
    6423  }
    6424 
    6425  default:
    6426  {
    6427  --m_it.primitive_iterator;
    6428  break;
    6429  }
    6430  }
    6431 
    6432  return *this;
    6433  }
    6434 
    6436  bool operator==(const const_iterator& other) const
    6437  {
    6438  // if objects are not the same, the comparison is undefined
    6439  if (m_object != other.m_object)
    6440  {
    6441  throw std::domain_error("cannot compare iterators of different containers");
    6442  }
    6443 
    6444  assert(m_object != nullptr);
    6445 
    6446  switch (m_object->m_type)
    6447  {
    6449  {
    6450  return (m_it.object_iterator == other.m_it.object_iterator);
    6451  }
    6452 
    6454  {
    6455  return (m_it.array_iterator == other.m_it.array_iterator);
    6456  }
    6457 
    6458  default:
    6459  {
    6460  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6461  }
    6462  }
    6463  }
    6464 
    6466  bool operator!=(const const_iterator& other) const
    6467  {
    6468  return not operator==(other);
    6469  }
    6470 
    6472  bool operator<(const const_iterator& other) const
    6473  {
    6474  // if objects are not the same, the comparison is undefined
    6475  if (m_object != other.m_object)
    6476  {
    6477  throw std::domain_error("cannot compare iterators of different containers");
    6478  }
    6479 
    6480  assert(m_object != nullptr);
    6481 
    6482  switch (m_object->m_type)
    6483  {
    6485  {
    6486  throw std::domain_error("cannot compare order of object iterators");
    6487  }
    6488 
    6490  {
    6491  return (m_it.array_iterator < other.m_it.array_iterator);
    6492  }
    6493 
    6494  default:
    6495  {
    6496  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6497  }
    6498  }
    6499  }
    6500 
    6502  bool operator<=(const const_iterator& other) const
    6503  {
    6504  return not other.operator < (*this);
    6505  }
    6506 
    6508  bool operator>(const const_iterator& other) const
    6509  {
    6510  return not operator<=(other);
    6511  }
    6512 
    6514  bool operator>=(const const_iterator& other) const
    6515  {
    6516  return not operator<(other);
    6517  }
    6518 
    6521  {
    6522  assert(m_object != nullptr);
    6523 
    6524  switch (m_object->m_type)
    6525  {
    6527  {
    6528  throw std::domain_error("cannot use offsets with object iterators");
    6529  }
    6530 
    6532  {
    6533  m_it.array_iterator += i;
    6534  break;
    6535  }
    6536 
    6537  default:
    6538  {
    6539  m_it.primitive_iterator += i;
    6540  break;
    6541  }
    6542  }
    6543 
    6544  return *this;
    6545  }
    6546 
    6549  {
    6550  return operator+=(-i);
    6551  }
    6552 
    6555  {
    6556  auto result = *this;
    6557  result += i;
    6558  return result;
    6559  }
    6560 
    6563  {
    6564  auto result = *this;
    6565  result -= i;
    6566  return result;
    6567  }
    6568 
    6571  {
    6572  assert(m_object != nullptr);
    6573 
    6574  switch (m_object->m_type)
    6575  {
    6577  {
    6578  throw std::domain_error("cannot use offsets with object iterators");
    6579  }
    6580 
    6582  {
    6583  return m_it.array_iterator - other.m_it.array_iterator;
    6584  }
    6585 
    6586  default:
    6587  {
    6588  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6589  }
    6590  }
    6591  }
    6592 
    6595  {
    6596  assert(m_object != nullptr);
    6597 
    6598  switch (m_object->m_type)
    6599  {
    6601  {
    6602  throw std::domain_error("cannot use operator[] for object iterators");
    6603  }
    6604 
    6606  {
    6607  return *(m_it.array_iterator + n);
    6608  }
    6609 
    6611  {
    6612  throw std::out_of_range("cannot get value");
    6613  }
    6614 
    6615  default:
    6616  {
    6617  if (m_it.primitive_iterator == -n)
    6618  {
    6619  return *m_object;
    6620  }
    6621  else
    6622  {
    6623  throw std::out_of_range("cannot get value");
    6624  }
    6625  }
    6626  }
    6627  }
    6628 
    6630  typename object_t::key_type key() const
    6631  {
    6632  assert(m_object != nullptr);
    6633 
    6634  if (m_object->is_object())
    6635  {
    6636  return m_it.object_iterator->first;
    6637  }
    6638  else
    6639  {
    6640  throw std::domain_error("cannot use key() for non-object iterators");
    6641  }
    6642  }
    6643 
    6646  {
    6647  return operator*();
    6648  }
    6649 
    6650  private:
    6652  pointer m_object = nullptr;
    6654  internal_iterator m_it = internal_iterator();
    6655  };
    6656 
    6669  class iterator : public const_iterator
    6670  {
    6671  public:
    6673  using pointer = typename basic_json::pointer;
    6675 
    6677  iterator() = default;
    6678 
    6680  iterator(pointer object) noexcept
    6681  : base_iterator(object)
    6682  {}
    6683 
    6685  iterator(const iterator& other) noexcept
    6686  : base_iterator(other)
    6687  {}
    6688 
    6690  iterator& operator=(iterator other) noexcept(
    6691  std::is_nothrow_move_constructible<pointer>::value and
    6692  std::is_nothrow_move_assignable<pointer>::value and
    6693  std::is_nothrow_move_constructible<internal_iterator>::value and
    6694  std::is_nothrow_move_assignable<internal_iterator>::value
    6695  )
    6696  {
    6697  base_iterator::operator=(other);
    6698  return *this;
    6699  }
    6700 
    6703  {
    6704  return const_cast<reference>(base_iterator::operator*());
    6705  }
    6706 
    6709  {
    6710  return const_cast<pointer>(base_iterator::operator->());
    6711  }
    6712 
    6715  {
    6716  iterator result = *this;
    6717  base_iterator::operator++();
    6718  return result;
    6719  }
    6720 
    6723  {
    6724  base_iterator::operator++();
    6725  return *this;
    6726  }
    6727 
    6730  {
    6731  iterator result = *this;
    6732  base_iterator::operator--();
    6733  return result;
    6734  }
    6735 
    6738  {
    6739  base_iterator::operator--();
    6740  return *this;
    6741  }
    6742 
    6745  {
    6746  base_iterator::operator+=(i);
    6747  return *this;
    6748  }
    6749 
    6752  {
    6753  base_iterator::operator-=(i);
    6754  return *this;
    6755  }
    6756 
    6759  {
    6760  auto result = *this;
    6761  result += i;
    6762  return result;
    6763  }
    6764 
    6767  {
    6768  auto result = *this;
    6769  result -= i;
    6770  return result;
    6771  }
    6772 
    6773  difference_type operator-(const iterator& other) const
    6774  {
    6775  return base_iterator::operator-(other);
    6776  }
    6777 
    6780  {
    6781  return const_cast<reference>(base_iterator::operator[](n));
    6782  }
    6783 
    6786  {
    6787  return const_cast<reference>(base_iterator::value());
    6788  }
    6789  };
    6790 
    6808  template<typename Base>
    6809  class json_reverse_iterator : public std::reverse_iterator<Base>
    6810  {
    6811  public:
    6813  using base_iterator = std::reverse_iterator<Base>;
    6815  using reference = typename Base::reference;
    6816 
    6818  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6819  : base_iterator(it)
    6820  {}
    6821 
    6824  : base_iterator(it)
    6825  {}
    6826 
    6829  {
    6830  return base_iterator::operator++(1);
    6831  }
    6832 
    6835  {
    6836  base_iterator::operator++();
    6837  return *this;
    6838  }
    6839 
    6842  {
    6843  return base_iterator::operator--(1);
    6844  }
    6845 
    6848  {
    6849  base_iterator::operator--();
    6850  return *this;
    6851  }
    6852 
    6855  {
    6856  base_iterator::operator+=(i);
    6857  return *this;
    6858  }
    6859 
    6862  {
    6863  auto result = *this;
    6864  result += i;
    6865  return result;
    6866  }
    6867 
    6870  {
    6871  auto result = *this;
    6872  result -= i;
    6873  return result;
    6874  }
    6875 
    6878  {
    6879  return this->base() - other.base();
    6880  }
    6881 
    6884  {
    6885  return *(this->operator+(n));
    6886  }
    6887 
    6889  typename object_t::key_type key() const
    6890  {
    6891  auto it = --this->base();
    6892  return it.key();
    6893  }
    6894 
    6897  {
    6898  auto it = --this->base();
    6899  return it.operator * ();
    6900  }
    6901  };
    6902 
    6903 
    6904  private:
    6906  // lexer and parser //
    6908 
    6916  class lexer
    6917  {
    6918  public:
    6920  enum class token_type
    6921  {
    6922  uninitialized,
    6923  literal_true,
    6924  literal_false,
    6925  literal_null,
    6926  value_string,
    6927  value_number,
    6928  begin_array,
    6929  begin_object,
    6930  end_array,
    6931  end_object,
    6932  name_separator,
    6933  value_separator,
    6934  parse_error,
    6935  end_of_input
    6936  };
    6937 
    6939  using lexer_char_t = unsigned char;
    6940 
    6942  explicit lexer(const string_t& s) noexcept
    6943  : m_stream(nullptr), m_buffer(s)
    6944  {
    6945  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    6946  assert(m_content != nullptr);
    6947  m_start = m_cursor = m_content;
    6948  m_limit = m_content + s.size();
    6949  }
    6950 
    6952  explicit lexer(std::istream* s) noexcept
    6953  : m_stream(s), m_buffer()
    6954  {
    6955  assert(m_stream != nullptr);
    6956  getline(*m_stream, m_buffer);
    6957  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    6958  assert(m_content != nullptr);
    6959  m_start = m_cursor = m_content;
    6960  m_limit = m_content + m_buffer.size();
    6961  }
    6962 
    6964  lexer() = default;
    6965 
    6966  // switch off unwanted functions
    6967  lexer(const lexer&) = delete;
    6968  lexer operator=(const lexer&) = delete;
    6969 
    6985  static string_t to_unicode(const std::size_t codepoint1,
    6986  const std::size_t codepoint2 = 0)
    6987  {
    6988  string_t result;
    6989 
    6990  // calculate the codepoint from the given code points
    6991  std::size_t codepoint = codepoint1;
    6992 
    6993  // check if codepoint1 is a high surrogate
    6994  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    6995  {
    6996  // check if codepoint2 is a low surrogate
    6997  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    6998  {
    6999  codepoint =
    7000  // high surrogate occupies the most significant 22 bits
    7001  (codepoint1 << 10)
    7002  // low surrogate occupies the least significant 15 bits
    7003  + codepoint2
    7004  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    7005  // in the result so we have to subtract with:
    7006  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    7007  - 0x35FDC00;
    7008  }
    7009  else
    7010  {
    7011  throw std::invalid_argument("missing or wrong low surrogate");
    7012  }
    7013  }
    7014 
    7015  if (codepoint < 0x80)
    7016  {
    7017  // 1-byte characters: 0xxxxxxx (ASCII)
    7018  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    7019  }
    7020  else if (codepoint <= 0x7ff)
    7021  {
    7022  // 2-byte characters: 110xxxxx 10xxxxxx
    7023  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    7024  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7025  }
    7026  else if (codepoint <= 0xffff)
    7027  {
    7028  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    7029  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    7030  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7031  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7032  }
    7033  else if (codepoint <= 0x10ffff)
    7034  {
    7035  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    7036  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    7037  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    7038  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7039  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7040  }
    7041  else
    7042  {
    7043  throw std::out_of_range("code points above 0x10FFFF are invalid");
    7044  }
    7045 
    7046  return result;
    7047  }
    7048 
    7050  static std::string token_type_name(token_type t)
    7051  {
    7052  switch (t)
    7053  {
    7054  case token_type::uninitialized:
    7055  return "<uninitialized>";
    7056  case token_type::literal_true:
    7057  return "true literal";
    7058  case token_type::literal_false:
    7059  return "false literal";
    7060  case token_type::literal_null:
    7061  return "null literal";
    7062  case token_type::value_string:
    7063  return "string literal";
    7064  case token_type::value_number:
    7065  return "number literal";
    7066  case token_type::begin_array:
    7067  return "'['";
    7068  case token_type::begin_object:
    7069  return "'{'";
    7070  case token_type::end_array:
    7071  return "']'";
    7072  case token_type::end_object:
    7073  return "'}'";
    7074  case token_type::name_separator:
    7075  return "':'";
    7076  case token_type::value_separator:
    7077  return "','";
    7078  case token_type::parse_error:
    7079  return "<parse error>";
    7080  case token_type::end_of_input:
    7081  return "end of input";
    7082  default:
    7083  {
    7084  // catch non-enum values
    7085  return "unknown token"; // LCOV_EXCL_LINE
    7086  }
    7087  }
    7088  }
    7089 
    7100  token_type scan() noexcept
    7101  {
    7102  // pointer for backtracking information
    7103  m_marker = nullptr;
    7104 
    7105  // remember the begin of the token
    7106  m_start = m_cursor;
    7107  assert(m_start != nullptr);
    7108 
    7109 
    7110  {
    7111  lexer_char_t yych;
    7112  unsigned int yyaccept = 0;
    7113  static const unsigned char yybm[] =
    7114  {
    7115  0, 0, 0, 0, 0, 0, 0, 0,
    7116  0, 32, 32, 0, 0, 32, 0, 0,
    7117  64, 64, 64, 64, 64, 64, 64, 64,
    7118  64, 64, 64, 64, 64, 64, 64, 64,
    7119  96, 64, 0, 64, 64, 64, 64, 64,
    7120  64, 64, 64, 64, 64, 64, 64, 64,
    7121  192, 192, 192, 192, 192, 192, 192, 192,
    7122  192, 192, 64, 64, 64, 64, 64, 64,
    7123  64, 64, 64, 64, 64, 64, 64, 64,
    7124  64, 64, 64, 64, 64, 64, 64, 64,
    7125  64, 64, 64, 64, 64, 64, 64, 64,
    7126  64, 64, 64, 64, 0, 64, 64, 64,
    7127  64, 64, 64, 64, 64, 64, 64, 64,
    7128  64, 64, 64, 64, 64, 64, 64, 64,
    7129  64, 64, 64, 64, 64, 64, 64, 64,
    7130  64, 64, 64, 64, 64, 64, 64, 64,
    7131  64, 64, 64, 64, 64, 64, 64, 64,
    7132  64, 64, 64, 64, 64, 64, 64, 64,
    7133  64, 64, 64, 64, 64, 64, 64, 64,
    7134  64, 64, 64, 64, 64, 64, 64, 64,
    7135  64, 64, 64, 64, 64, 64, 64, 64,
    7136  64, 64, 64, 64, 64, 64, 64, 64,
    7137  64, 64, 64, 64, 64, 64, 64, 64,
    7138  64, 64, 64, 64, 64, 64, 64, 64,
    7139  64, 64, 64, 64, 64, 64, 64, 64,
    7140  64, 64, 64, 64, 64, 64, 64, 64,
    7141  64, 64, 64, 64, 64, 64, 64, 64,
    7142  64, 64, 64, 64, 64, 64, 64, 64,
    7143  64, 64, 64, 64, 64, 64, 64, 64,
    7144  64, 64, 64, 64, 64, 64, 64, 64,
    7145  64, 64, 64, 64, 64, 64, 64, 64,
    7146  64, 64, 64, 64, 64, 64, 64, 64,
    7147  };
    7148  if ((m_limit - m_cursor) < 5)
    7149  {
    7150  yyfill(); // LCOV_EXCL_LINE;
    7151  }
    7152  yych = *m_cursor;
    7153  if (yych <= ':')
    7154  {
    7155  if (yych <= ' ')
    7156  {
    7157  if (yych <= '\n')
    7158  {
    7159  if (yych <= 0x00)
    7160  {
    7161  goto basic_json_parser_28;
    7162  }
    7163  if (yych <= 0x08)
    7164  {
    7165  goto basic_json_parser_30;
    7166  }
    7167  if (yych >= '\n')
    7168  {
    7169  goto basic_json_parser_4;
    7170  }
    7171  }
    7172  else
    7173  {
    7174  if (yych == '\r')
    7175  {
    7176  goto basic_json_parser_2;
    7177  }
    7178  if (yych <= 0x1F)
    7179  {
    7180  goto basic_json_parser_30;
    7181  }
    7182  }
    7183  }
    7184  else
    7185  {
    7186  if (yych <= ',')
    7187  {
    7188  if (yych == '"')
    7189  {
    7190  goto basic_json_parser_27;
    7191  }
    7192  if (yych <= '+')
    7193  {
    7194  goto basic_json_parser_30;
    7195  }
    7196  goto basic_json_parser_16;
    7197  }
    7198  else
    7199  {
    7200  if (yych <= '/')
    7201  {
    7202  if (yych <= '-')
    7203  {
    7204  goto basic_json_parser_23;
    7205  }
    7206  goto basic_json_parser_30;
    7207  }
    7208  else
    7209  {
    7210  if (yych <= '0')
    7211  {
    7212  goto basic_json_parser_24;
    7213  }
    7214  if (yych <= '9')
    7215  {
    7216  goto basic_json_parser_26;
    7217  }
    7218  goto basic_json_parser_18;
    7219  }
    7220  }
    7221  }
    7222  }
    7223  else
    7224  {
    7225  if (yych <= 'n')
    7226  {
    7227  if (yych <= ']')
    7228  {
    7229  if (yych == '[')
    7230  {
    7231  goto basic_json_parser_8;
    7232  }
    7233  if (yych <= '\\')
    7234  {
    7235  goto basic_json_parser_30;
    7236  }
    7237  goto basic_json_parser_10;
    7238  }
    7239  else
    7240  {
    7241  if (yych == 'f')
    7242  {
    7243  goto basic_json_parser_22;
    7244  }
    7245  if (yych <= 'm')
    7246  {
    7247  goto basic_json_parser_30;
    7248  }
    7249  goto basic_json_parser_20;
    7250  }
    7251  }
    7252  else
    7253  {
    7254  if (yych <= '{')
    7255  {
    7256  if (yych == 't')
    7257  {
    7258  goto basic_json_parser_21;
    7259  }
    7260  if (yych <= 'z')
    7261  {
    7262  goto basic_json_parser_30;
    7263  }
    7264  goto basic_json_parser_12;
    7265  }
    7266  else
    7267  {
    7268  if (yych <= '}')
    7269  {
    7270  if (yych <= '|')
    7271  {
    7272  goto basic_json_parser_30;
    7273  }
    7274  goto basic_json_parser_14;
    7275  }
    7276  else
    7277  {
    7278  if (yych == 0xEF)
    7279  {
    7280  goto basic_json_parser_6;
    7281  }
    7282  goto basic_json_parser_30;
    7283  }
    7284  }
    7285  }
    7286  }
    7287 basic_json_parser_2:
    7288  ++m_cursor;
    7289  yych = *m_cursor;
    7290  goto basic_json_parser_5;
    7291 basic_json_parser_3:
    7292  {
    7293  return scan();
    7294  }
    7295 basic_json_parser_4:
    7296  ++m_cursor;
    7297  if (m_limit <= m_cursor)
    7298  {
    7299  yyfill(); // LCOV_EXCL_LINE;
    7300  }
    7301  yych = *m_cursor;
    7302 basic_json_parser_5:
    7303  if (yybm[0 + yych] & 32)
    7304  {
    7305  goto basic_json_parser_4;
    7306  }
    7307  goto basic_json_parser_3;
    7308 basic_json_parser_6:
    7309  yyaccept = 0;
    7310  yych = *(m_marker = ++m_cursor);
    7311  if (yych == 0xBB)
    7312  {
    7313  goto basic_json_parser_64;
    7314  }
    7315 basic_json_parser_7:
    7316  {
    7317  return token_type::parse_error;
    7318  }
    7319 basic_json_parser_8:
    7320  ++m_cursor;
    7321  {
    7322  return token_type::begin_array;
    7323  }
    7324 basic_json_parser_10:
    7325  ++m_cursor;
    7326  {
    7327  return token_type::end_array;
    7328  }
    7329 basic_json_parser_12:
    7330  ++m_cursor;
    7331  {
    7332  return token_type::begin_object;
    7333  }
    7334 basic_json_parser_14:
    7335  ++m_cursor;
    7336  {
    7337  return token_type::end_object;
    7338  }
    7339 basic_json_parser_16:
    7340  ++m_cursor;
    7341  {
    7342  return token_type::value_separator;
    7343  }
    7344 basic_json_parser_18:
    7345  ++m_cursor;
    7346  {
    7347  return token_type::name_separator;
    7348  }
    7349 basic_json_parser_20:
    7350  yyaccept = 0;
    7351  yych = *(m_marker = ++m_cursor);
    7352  if (yych == 'u')
    7353  {
    7354  goto basic_json_parser_60;
    7355  }
    7356  goto basic_json_parser_7;
    7357 basic_json_parser_21:
    7358  yyaccept = 0;
    7359  yych = *(m_marker = ++m_cursor);
    7360  if (yych == 'r')
    7361  {
    7362  goto basic_json_parser_56;
    7363  }
    7364  goto basic_json_parser_7;
    7365 basic_json_parser_22:
    7366  yyaccept = 0;
    7367  yych = *(m_marker = ++m_cursor);
    7368  if (yych == 'a')
    7369  {
    7370  goto basic_json_parser_51;
    7371  }
    7372  goto basic_json_parser_7;
    7373 basic_json_parser_23:
    7374  yych = *++m_cursor;
    7375  if (yych <= '/')
    7376  {
    7377  goto basic_json_parser_7;
    7378  }
    7379  if (yych <= '0')
    7380  {
    7381  goto basic_json_parser_50;
    7382  }
    7383  if (yych <= '9')
    7384  {
    7385  goto basic_json_parser_41;
    7386  }
    7387  goto basic_json_parser_7;
    7388 basic_json_parser_24:
    7389  yyaccept = 1;
    7390  yych = *(m_marker = ++m_cursor);
    7391  if (yych <= 'D')
    7392  {
    7393  if (yych == '.')
    7394  {
    7395  goto basic_json_parser_43;
    7396  }
    7397  }
    7398  else
    7399  {
    7400  if (yych <= 'E')
    7401  {
    7402  goto basic_json_parser_44;
    7403  }
    7404  if (yych == 'e')
    7405  {
    7406  goto basic_json_parser_44;
    7407  }
    7408  }
    7409 basic_json_parser_25:
    7410  {
    7411  return token_type::value_number;
    7412  }
    7413 basic_json_parser_26:
    7414  yyaccept = 1;
    7415  yych = *(m_marker = ++m_cursor);
    7416  goto basic_json_parser_42;
    7417 basic_json_parser_27:
    7418  yyaccept = 0;
    7419  yych = *(m_marker = ++m_cursor);
    7420  if (yych <= 0x0F)
    7421  {
    7422  goto basic_json_parser_7;
    7423  }
    7424  goto basic_json_parser_32;
    7425 basic_json_parser_28:
    7426  ++m_cursor;
    7427  {
    7428  return token_type::end_of_input;
    7429  }
    7430 basic_json_parser_30:
    7431  yych = *++m_cursor;
    7432  goto basic_json_parser_7;
    7433 basic_json_parser_31:
    7434  ++m_cursor;
    7435  if (m_limit <= m_cursor)
    7436  {
    7437  yyfill(); // LCOV_EXCL_LINE;
    7438  }
    7439  yych = *m_cursor;
    7440 basic_json_parser_32:
    7441  if (yybm[0 + yych] & 64)
    7442  {
    7443  goto basic_json_parser_31;
    7444  }
    7445  if (yych <= 0x0F)
    7446  {
    7447  goto basic_json_parser_33;
    7448  }
    7449  if (yych <= '"')
    7450  {
    7451  goto basic_json_parser_35;
    7452  }
    7453  goto basic_json_parser_34;
    7454 basic_json_parser_33:
    7455  m_cursor = m_marker;
    7456  if (yyaccept == 0)
    7457  {
    7458  goto basic_json_parser_7;
    7459  }
    7460  else
    7461  {
    7462  goto basic_json_parser_25;
    7463  }
    7464 basic_json_parser_34:
    7465  ++m_cursor;
    7466  if (m_limit <= m_cursor)
    7467  {
    7468  yyfill(); // LCOV_EXCL_LINE;
    7469  }
    7470  yych = *m_cursor;
    7471  if (yych <= 'e')
    7472  {
    7473  if (yych <= '/')
    7474  {
    7475  if (yych == '"')
    7476  {
    7477  goto basic_json_parser_31;
    7478  }
    7479  if (yych <= '.')
    7480  {
    7481  goto basic_json_parser_33;
    7482  }
    7483  goto basic_json_parser_31;
    7484  }
    7485  else
    7486  {
    7487  if (yych <= '\\')
    7488  {
    7489  if (yych <= '[')
    7490  {
    7491  goto basic_json_parser_33;
    7492  }
    7493  goto basic_json_parser_31;
    7494  }
    7495  else
    7496  {
    7497  if (yych == 'b')
    7498  {
    7499  goto basic_json_parser_31;
    7500  }
    7501  goto basic_json_parser_33;
    7502  }
    7503  }
    7504  }
    7505  else
    7506  {
    7507  if (yych <= 'q')
    7508  {
    7509  if (yych <= 'f')
    7510  {
    7511  goto basic_json_parser_31;
    7512  }
    7513  if (yych == 'n')
    7514  {
    7515  goto basic_json_parser_31;
    7516  }
    7517  goto basic_json_parser_33;
    7518  }
    7519  else
    7520  {
    7521  if (yych <= 's')
    7522  {
    7523  if (yych <= 'r')
    7524  {
    7525  goto basic_json_parser_31;
    7526  }
    7527  goto basic_json_parser_33;
    7528  }
    7529  else
    7530  {
    7531  if (yych <= 't')
    7532  {
    7533  goto basic_json_parser_31;
    7534  }
    7535  if (yych <= 'u')
    7536  {
    7537  goto basic_json_parser_37;
    7538  }
    7539  goto basic_json_parser_33;
    7540  }
    7541  }
    7542  }
    7543 basic_json_parser_35:
    7544  ++m_cursor;
    7545  {
    7546  return token_type::value_string;
    7547  }
    7548 basic_json_parser_37:
    7549  ++m_cursor;
    7550  if (m_limit <= m_cursor)
    7551  {
    7552  yyfill(); // LCOV_EXCL_LINE;
    7553  }
    7554  yych = *m_cursor;
    7555  if (yych <= '@')
    7556  {
    7557  if (yych <= '/')
    7558  {
    7559  goto basic_json_parser_33;
    7560  }
    7561  if (yych >= ':')
    7562  {
    7563  goto basic_json_parser_33;
    7564  }
    7565  }
    7566  else
    7567  {
    7568  if (yych <= 'F')
    7569  {
    7570  goto basic_json_parser_38;
    7571  }
    7572  if (yych <= '`')
    7573  {
    7574  goto basic_json_parser_33;
    7575  }
    7576  if (yych >= 'g')
    7577  {
    7578  goto basic_json_parser_33;
    7579  }
    7580  }
    7581 basic_json_parser_38:
    7582  ++m_cursor;
    7583  if (m_limit <= m_cursor)
    7584  {
    7585  yyfill(); // LCOV_EXCL_LINE;
    7586  }
    7587  yych = *m_cursor;
    7588  if (yych <= '@')
    7589  {
    7590  if (yych <= '/')
    7591  {
    7592  goto basic_json_parser_33;
    7593  }
    7594  if (yych >= ':')
    7595  {
    7596  goto basic_json_parser_33;
    7597  }
    7598  }
    7599  else
    7600  {
    7601  if (yych <= 'F')
    7602  {
    7603  goto basic_json_parser_39;
    7604  }
    7605  if (yych <= '`')
    7606  {
    7607  goto basic_json_parser_33;
    7608  }
    7609  if (yych >= 'g')
    7610  {
    7611  goto basic_json_parser_33;
    7612  }
    7613  }
    7614 basic_json_parser_39:
    7615  ++m_cursor;
    7616  if (m_limit <= m_cursor)
    7617  {
    7618  yyfill(); // LCOV_EXCL_LINE;
    7619  }
    7620  yych = *m_cursor;
    7621  if (yych <= '@')
    7622  {
    7623  if (yych <= '/')
    7624  {
    7625  goto basic_json_parser_33;
    7626  }
    7627  if (yych >= ':')
    7628  {
    7629  goto basic_json_parser_33;
    7630  }
    7631  }
    7632  else
    7633  {
    7634  if (yych <= 'F')
    7635  {
    7636  goto basic_json_parser_40;
    7637  }
    7638  if (yych <= '`')
    7639  {
    7640  goto basic_json_parser_33;
    7641  }
    7642  if (yych >= 'g')
    7643  {
    7644  goto basic_json_parser_33;
    7645  }
    7646  }
    7647 basic_json_parser_40:
    7648  ++m_cursor;
    7649  if (m_limit <= m_cursor)
    7650  {
    7651  yyfill(); // LCOV_EXCL_LINE;
    7652  }
    7653  yych = *m_cursor;
    7654  if (yych <= '@')
    7655  {
    7656  if (yych <= '/')
    7657  {
    7658  goto basic_json_parser_33;
    7659  }
    7660  if (yych <= '9')
    7661  {
    7662  goto basic_json_parser_31;
    7663  }
    7664  goto basic_json_parser_33;
    7665  }
    7666  else
    7667  {
    7668  if (yych <= 'F')
    7669  {
    7670  goto basic_json_parser_31;
    7671  }
    7672  if (yych <= '`')
    7673  {
    7674  goto basic_json_parser_33;
    7675  }
    7676  if (yych <= 'f')
    7677  {
    7678  goto basic_json_parser_31;
    7679  }
    7680  goto basic_json_parser_33;
    7681  }
    7682 basic_json_parser_41:
    7683  yyaccept = 1;
    7684  m_marker = ++m_cursor;
    7685  if ((m_limit - m_cursor) < 3)
    7686  {
    7687  yyfill(); // LCOV_EXCL_LINE;
    7688  }
    7689  yych = *m_cursor;
    7690 basic_json_parser_42:
    7691  if (yybm[0 + yych] & 128)
    7692  {
    7693  goto basic_json_parser_41;
    7694  }
    7695  if (yych <= 'D')
    7696  {
    7697  if (yych != '.')
    7698  {
    7699  goto basic_json_parser_25;
    7700  }
    7701  }
    7702  else
    7703  {
    7704  if (yych <= 'E')
    7705  {
    7706  goto basic_json_parser_44;
    7707  }
    7708  if (yych == 'e')
    7709  {
    7710  goto basic_json_parser_44;
    7711  }
    7712  goto basic_json_parser_25;
    7713  }
    7714 basic_json_parser_43:
    7715  yych = *++m_cursor;
    7716  if (yych <= '/')
    7717  {
    7718  goto basic_json_parser_33;
    7719  }
    7720  if (yych <= '9')
    7721  {
    7722  goto basic_json_parser_48;
    7723  }
    7724  goto basic_json_parser_33;
    7725 basic_json_parser_44:
    7726  yych = *++m_cursor;
    7727  if (yych <= ',')
    7728  {
    7729  if (yych != '+')
    7730  {
    7731  goto basic_json_parser_33;
    7732  }
    7733  }
    7734  else
    7735  {
    7736  if (yych <= '-')
    7737  {
    7738  goto basic_json_parser_45;
    7739  }
    7740  if (yych <= '/')
    7741  {
    7742  goto basic_json_parser_33;
    7743  }
    7744  if (yych <= '9')
    7745  {
    7746  goto basic_json_parser_46;
    7747  }
    7748  goto basic_json_parser_33;
    7749  }
    7750 basic_json_parser_45:
    7751  yych = *++m_cursor;
    7752  if (yych <= '/')
    7753  {
    7754  goto basic_json_parser_33;
    7755  }
    7756  if (yych >= ':')
    7757  {
    7758  goto basic_json_parser_33;
    7759  }
    7760 basic_json_parser_46:
    7761  ++m_cursor;
    7762  if (m_limit <= m_cursor)
    7763  {
    7764  yyfill(); // LCOV_EXCL_LINE;
    7765  }
    7766  yych = *m_cursor;
    7767  if (yych <= '/')
    7768  {
    7769  goto basic_json_parser_25;
    7770  }
    7771  if (yych <= '9')
    7772  {
    7773  goto basic_json_parser_46;
    7774  }
    7775  goto basic_json_parser_25;
    7776 basic_json_parser_48:
    7777  yyaccept = 1;
    7778  m_marker = ++m_cursor;
    7779  if ((m_limit - m_cursor) < 3)
    7780  {
    7781  yyfill(); // LCOV_EXCL_LINE;
    7782  }
    7783  yych = *m_cursor;
    7784  if (yych <= 'D')
    7785  {
    7786  if (yych <= '/')
    7787  {
    7788  goto basic_json_parser_25;
    7789  }
    7790  if (yych <= '9')
    7791  {
    7792  goto basic_json_parser_48;
    7793  }
    7794  goto basic_json_parser_25;
    7795  }
    7796  else
    7797  {
    7798  if (yych <= 'E')
    7799  {
    7800  goto basic_json_parser_44;
    7801  }
    7802  if (yych == 'e')
    7803  {
    7804  goto basic_json_parser_44;
    7805  }
    7806  goto basic_json_parser_25;
    7807  }
    7808 basic_json_parser_50:
    7809  yyaccept = 1;
    7810  yych = *(m_marker = ++m_cursor);
    7811  if (yych <= 'D')
    7812  {
    7813  if (yych == '.')
    7814  {
    7815  goto basic_json_parser_43;
    7816  }
    7817  goto basic_json_parser_25;
    7818  }
    7819  else
    7820  {
    7821  if (yych <= 'E')
    7822  {
    7823  goto basic_json_parser_44;
    7824  }
    7825  if (yych == 'e')
    7826  {
    7827  goto basic_json_parser_44;
    7828  }
    7829  goto basic_json_parser_25;
    7830  }
    7831 basic_json_parser_51:
    7832  yych = *++m_cursor;
    7833  if (yych != 'l')
    7834  {
    7835  goto basic_json_parser_33;
    7836  }
    7837  yych = *++m_cursor;
    7838  if (yych != 's')
    7839  {
    7840  goto basic_json_parser_33;
    7841  }
    7842  yych = *++m_cursor;
    7843  if (yych != 'e')
    7844  {
    7845  goto basic_json_parser_33;
    7846  }
    7847  ++m_cursor;
    7848  {
    7849  return token_type::literal_false;
    7850  }
    7851 basic_json_parser_56:
    7852  yych = *++m_cursor;
    7853  if (yych != 'u')
    7854  {
    7855  goto basic_json_parser_33;
    7856  }
    7857  yych = *++m_cursor;
    7858  if (yych != 'e')
    7859  {
    7860  goto basic_json_parser_33;
    7861  }
    7862  ++m_cursor;
    7863  {
    7864  return token_type::literal_true;
    7865  }
    7866 basic_json_parser_60:
    7867  yych = *++m_cursor;
    7868  if (yych != 'l')
    7869  {
    7870  goto basic_json_parser_33;
    7871  }
    7872  yych = *++m_cursor;
    7873  if (yych != 'l')
    7874  {
    7875  goto basic_json_parser_33;
    7876  }
    7877  ++m_cursor;
    7878  {
    7879  return token_type::literal_null;
    7880  }
    7881 basic_json_parser_64:
    7882  yych = *++m_cursor;
    7883  if (yych != 0xBF)
    7884  {
    7885  goto basic_json_parser_33;
    7886  }
    7887  ++m_cursor;
    7888  {
    7889  return scan();
    7890  }
    7891  }
    7892 
    7893 
    7894  }
    7895 
    7897  void yyfill() noexcept
    7898  {
    7899  if (m_stream == nullptr or not * m_stream)
    7900  {
    7901  return;
    7902  }
    7903 
    7904  const ssize_t offset_start = m_start - m_content;
    7905  const ssize_t offset_marker = m_marker - m_start;
    7906  const ssize_t offset_cursor = m_cursor - m_start;
    7907 
    7908  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7909  std::string line;
    7910  assert(m_stream != nullptr);
    7911  std::getline(*m_stream, line);
    7912  m_buffer += "\n" + line; // add line with newline symbol
    7913 
    7914  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7915  assert(m_content != nullptr);
    7916  m_start = m_content;
    7917  m_marker = m_start + offset_marker;
    7918  m_cursor = m_start + offset_cursor;
    7919  m_limit = m_start + m_buffer.size() - 1;
    7920  }
    7921 
    7923  string_t get_token() const noexcept
    7924  {
    7925  assert(m_start != nullptr);
    7926  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7927  static_cast<size_t>(m_cursor - m_start));
    7928  }
    7929 
    7951  string_t get_string() const
    7952  {
    7953  string_t result;
    7954  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    7955 
    7956  // iterate the result between the quotes
    7957  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    7958  {
    7959  // process escaped characters
    7960  if (*i == '\\')
    7961  {
    7962  // read next character
    7963  ++i;
    7964 
    7965  switch (*i)
    7966  {
    7967  // the default escapes
    7968  case 't':
    7969  {
    7970  result += "\t";
    7971  break;
    7972  }
    7973  case 'b':
    7974  {
    7975  result += "\b";
    7976  break;
    7977  }
    7978  case 'f':
    7979  {
    7980  result += "\f";
    7981  break;
    7982  }
    7983  case 'n':
    7984  {
    7985  result += "\n";
    7986  break;
    7987  }
    7988  case 'r':
    7989  {
    7990  result += "\r";
    7991  break;
    7992  }
    7993  case '\\':
    7994  {
    7995  result += "\\";
    7996  break;
    7997  }
    7998  case '/':
    7999  {
    8000  result += "/";
    8001  break;
    8002  }
    8003  case '"':
    8004  {
    8005  result += "\"";
    8006  break;
    8007  }
    8008 
    8009  // unicode
    8010  case 'u':
    8011  {
    8012  // get code xxxx from uxxxx
    8013  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    8014  4).c_str(), nullptr, 16);
    8015 
    8016  // check if codepoint is a high surrogate
    8017  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    8018  {
    8019  // make sure there is a subsequent unicode
    8020  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    8021  {
    8022  throw std::invalid_argument("missing low surrogate");
    8023  }
    8024 
    8025  // get code yyyy from uxxxx\uyyyy
    8026  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    8027  (i + 7), 4).c_str(), nullptr, 16);
    8028  result += to_unicode(codepoint, codepoint2);
    8029  // skip the next 10 characters (xxxx\uyyyy)
    8030  i += 10;
    8031  }
    8032  else
    8033  {
    8034  // add unicode character(s)
    8035  result += to_unicode(codepoint);
    8036  // skip the next four characters (xxxx)
    8037  i += 4;
    8038  }
    8039  break;
    8040  }
    8041  }
    8042  }
    8043  else
    8044  {
    8045  // all other characters are just copied to the end of the
    8046  // string
    8047  result.append(1, static_cast<typename string_t::value_type>(*i));
    8048  }
    8049  }
    8050 
    8051  return result;
    8052  }
    8053 
    8074  long double str_to_float_t(long double* /* type */, char** endptr) const
    8075  {
    8076  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8077  }
    8078 
    8093  double str_to_float_t(double* /* type */, char** endptr) const
    8094  {
    8095  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8096  }
    8097 
    8112  float str_to_float_t(float* /* type */, char** endptr) const
    8113  {
    8114  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8115  }
    8116 
    8129  template <typename T_A, typename T_B>
    8130  bool attempt_cast(T_A source, T_B& dest) const
    8131  {
    8132  dest = static_cast<T_B>(source);
    8133  return (source == static_cast<T_A>(dest));
    8134  }
    8135 
    8174  void get_number(basic_json& result) const
    8175  {
    8176  typename string_t::value_type* endptr;
    8177  assert(m_start != nullptr);
    8178  errno = 0;
    8179 
    8180  // attempt to parse it as an integer - first checking for a
    8181  // negative number
    8182  if (*reinterpret_cast<typename string_t::const_pointer>(m_start) != '-')
    8183  {
    8184  // positive, parse with strtoull and attempt cast to
    8185  // number_unsigned_t
    8186  if (attempt_cast(std::strtoull(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8187  10), result.m_value.number_unsigned))
    8188  {
    8189  result.m_type = value_t::number_unsigned;
    8190  }
    8191  else
    8192  {
    8193  // cast failed due to overflow - store as float
    8194  result.m_type = value_t::number_float;
    8195  }
    8196  }
    8197  else
    8198  {
    8199  // Negative, parse with strtoll and attempt cast to
    8200  // number_integer_t
    8201  if (attempt_cast(std::strtoll(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8202  10), result.m_value.number_integer))
    8203  {
    8204  result.m_type = value_t::number_integer;
    8205  }
    8206  else
    8207  {
    8208  // cast failed due to overflow - store as float
    8209  result.m_type = value_t::number_float;
    8210  }
    8211  }
    8212 
    8213  // check the end of the number was reached and no range error
    8214  // occurred
    8215  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor || errno == ERANGE)
    8216  {
    8217  result.m_type = value_t::number_float;
    8218  }
    8219 
    8220  if (result.m_type == value_t::number_float)
    8221  {
    8222  // either the number won't fit in an integer (range error from
    8223  // strtoull/strtoll or overflow on cast) or there was something
    8224  // else after the number, which could be an exponent
    8225 
    8226  // parse with strtod
    8227  result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), &endptr);
    8228 
    8229  // anything after the number is an error
    8230  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor)
    8231  {
    8232  throw std::invalid_argument(std::string("parse error - ") + get_token() + " is not a number");
    8233  }
    8234  }
    8235  }
    8236 
    8237  private:
    8239  std::istream* m_stream = nullptr;
    8241  string_t m_buffer;
    8243  const lexer_char_t* m_content = nullptr;
    8245  const lexer_char_t* m_start = nullptr;
    8247  const lexer_char_t* m_marker = nullptr;
    8249  const lexer_char_t* m_cursor = nullptr;
    8251  const lexer_char_t* m_limit = nullptr;
    8252  };
    8253 
    8259  class parser
    8260  {
    8261  public:
    8263  parser(const string_t& s, parser_callback_t cb = nullptr)
    8264  : callback(cb), m_lexer(s)
    8265  {
    8266  // read first token
    8267  get_token();
    8268  }
    8269 
    8271  parser(std::istream& _is, parser_callback_t cb = nullptr)
    8272  : callback(cb), m_lexer(&_is)
    8273  {
    8274  // read first token
    8275  get_token();
    8276  }
    8277 
    8279  basic_json parse()
    8280  {
    8281  basic_json result = parse_internal(true);
    8282 
    8283  expect(lexer::token_type::end_of_input);
    8284 
    8285  // return parser result and replace it with null in case the
    8286  // top-level value was discarded by the callback function
    8287  return result.is_discarded() ? basic_json() : result;
    8288  }
    8289 
    8290  private:
    8292  basic_json parse_internal(bool keep)
    8293  {
    8294  auto result = basic_json(value_t::discarded);
    8295 
    8296  switch (last_token)
    8297  {
    8298  case lexer::token_type::begin_object:
    8299  {
    8300  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    8301  {
    8302  // explicitly set result to object to cope with {}
    8303  result.m_type = value_t::object;
    8304  result.m_value = json_value(value_t::object);
    8305  }
    8306 
    8307  // read next token
    8308  get_token();
    8309 
    8310  // closing } -> we are done
    8311  if (last_token == lexer::token_type::end_object)
    8312  {
    8313  get_token();
    8314  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8315  {
    8316  result = basic_json(value_t::discarded);
    8317  }
    8318  return result;
    8319  }
    8320 
    8321  // no comma is expected here
    8322  unexpect(lexer::token_type::value_separator);
    8323 
    8324  // otherwise: parse key-value pairs
    8325  do
    8326  {
    8327  // ugly, but could be fixed with loop reorganization
    8328  if (last_token == lexer::token_type::value_separator)
    8329  {
    8330  get_token();
    8331  }
    8332 
    8333  // store key
    8334  expect(lexer::token_type::value_string);
    8335  const auto key = m_lexer.get_string();
    8336 
    8337  bool keep_tag = false;
    8338  if (keep)
    8339  {
    8340  if (callback)
    8341  {
    8342  basic_json k(key);
    8343  keep_tag = callback(depth, parse_event_t::key, k);
    8344  }
    8345  else
    8346  {
    8347  keep_tag = true;
    8348  }
    8349  }
    8350 
    8351  // parse separator (:)
    8352  get_token();
    8353  expect(lexer::token_type::name_separator);
    8354 
    8355  // parse and add value
    8356  get_token();
    8357  auto value = parse_internal(keep);
    8358  if (keep and keep_tag and not value.is_discarded())
    8359  {
    8360  result[key] = std::move(value);
    8361  }
    8362  }
    8363  while (last_token == lexer::token_type::value_separator);
    8364 
    8365  // closing }
    8366  expect(lexer::token_type::end_object);
    8367  get_token();
    8368  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8369  {
    8370  result = basic_json(value_t::discarded);
    8371  }
    8372 
    8373  return result;
    8374  }
    8375 
    8376  case lexer::token_type::begin_array:
    8377  {
    8378  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    8379  {
    8380  // explicitly set result to object to cope with []
    8381  result.m_type = value_t::array;
    8382  result.m_value = json_value(value_t::array);
    8383  }
    8384 
    8385  // read next token
    8386  get_token();
    8387 
    8388  // closing ] -> we are done
    8389  if (last_token == lexer::token_type::end_array)
    8390  {
    8391  get_token();
    8392  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8393  {
    8394  result = basic_json(value_t::discarded);
    8395  }
    8396  return result;
    8397  }
    8398 
    8399  // no comma is expected here
    8400  unexpect(lexer::token_type::value_separator);
    8401 
    8402  // otherwise: parse values
    8403  do
    8404  {
    8405  // ugly, but could be fixed with loop reorganization
    8406  if (last_token == lexer::token_type::value_separator)
    8407  {
    8408  get_token();
    8409  }
    8410 
    8411  // parse value
    8412  auto value = parse_internal(keep);
    8413  if (keep and not value.is_discarded())
    8414  {
    8415  result.push_back(std::move(value));
    8416  }
    8417  }
    8418  while (last_token == lexer::token_type::value_separator);
    8419 
    8420  // closing ]
    8421  expect(lexer::token_type::end_array);
    8422  get_token();
    8423  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8424  {
    8425  result = basic_json(value_t::discarded);
    8426  }
    8427 
    8428  return result;
    8429  }
    8430 
    8431  case lexer::token_type::literal_null:
    8432  {
    8433  get_token();
    8434  result.m_type = value_t::null;
    8435  break;
    8436  }
    8437 
    8438  case lexer::token_type::value_string:
    8439  {
    8440  const auto s = m_lexer.get_string();
    8441  get_token();
    8442  result = basic_json(s);
    8443  break;
    8444  }
    8445 
    8446  case lexer::token_type::literal_true:
    8447  {
    8448  get_token();
    8449  result.m_type = value_t::boolean;
    8450  result.m_value = true;
    8451  break;
    8452  }
    8453 
    8454  case lexer::token_type::literal_false:
    8455  {
    8456  get_token();
    8457  result.m_type = value_t::boolean;
    8458  result.m_value = false;
    8459  break;
    8460  }
    8461 
    8462  case lexer::token_type::value_number:
    8463  {
    8464  m_lexer.get_number(result);
    8465  get_token();
    8466  break;
    8467  }
    8468 
    8469  default:
    8470  {
    8471  // the last token was unexpected
    8472  unexpect(last_token);
    8473  }
    8474  }
    8475 
    8476  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8477  {
    8478  result = basic_json(value_t::discarded);
    8479  }
    8480  return result;
    8481  }
    8482 
    8484  typename lexer::token_type get_token()
    8485  {
    8486  last_token = m_lexer.scan();
    8487  return last_token;
    8488  }
    8489 
    8490  void expect(typename lexer::token_type t) const
    8491  {
    8492  if (t != last_token)
    8493  {
    8494  std::string error_msg = "parse error - unexpected ";
    8495  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8496  lexer::token_type_name(last_token));
    8497  error_msg += "; expected " + lexer::token_type_name(t);
    8498  throw std::invalid_argument(error_msg);
    8499  }
    8500  }
    8501 
    8502  void unexpect(typename lexer::token_type t) const
    8503  {
    8504  if (t == last_token)
    8505  {
    8506  std::string error_msg = "parse error - unexpected ";
    8507  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8508  lexer::token_type_name(last_token));
    8509  throw std::invalid_argument(error_msg);
    8510  }
    8511  }
    8512 
    8513  private:
    8515  int depth = 0;
    8517  parser_callback_t callback;
    8519  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8521  lexer m_lexer;
    8522  };
    8523 };
    8524 
    8525 
    8527 // presets //
    8529 
    8539 }
    8540 
    8541 
    8543 // nonmember functions //
    8545 
    8546 // specialization of std::swap, and std::hash
    8547 namespace std
    8548 {
    8554 template <>
    8555 inline void swap(nlohmann::json& j1,
    8556  nlohmann::json& j2) noexcept(
    8557  is_nothrow_move_constructible<nlohmann::json>::value and
    8558  is_nothrow_move_assignable<nlohmann::json>::value
    8559  )
    8560 {
    8561  j1.swap(j2);
    8562 }
    8563 
    8565 template <>
    8566 struct hash<nlohmann::json>
    8567 {
    8573  std::size_t operator()(const nlohmann::json& j) const
    8574  {
    8575  // a naive hashing via the string representation
    8576  const auto& h = hash<nlohmann::json::string_t>();
    8577  return h(j.dump());
    8578  }
    8579 };
    8580 }
    8581 
    8594 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8595 {
    8596  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8597 }
    8598 
    8599 // restore GCC/clang diagnostic settings
    8600 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    8601  #pragma GCC diagnostic pop
    8602 #endif
    8603 
    8604 #endif
    bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:2148
    -
    reference operator*()
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6702
    -
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:4114
    -
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5341
    -
    basic_json(const value_t value_type)
    create an empty value with a given type
    Definition: json.hpp:971
    -
    basic_json(const array_t &val)
    create an array (explicit)
    Definition: json.hpp:1097
    -
    size_type count(typename object_t::key_type key) const
    returns the number of occurrences of a key in a JSON object
    Definition: json.hpp:3962
    -
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:2088
    -
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2220
    -
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:3182
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6785
    -
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6847
    -
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:2167
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4451
    -
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6436
    -
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6841
    -
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3314
    -
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5554
    -
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2194
    -
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6744
    -
    static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an object from an initializer list
    Definition: json.hpp:1676
    -
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6562
    -
    BooleanType boolean_t
    a type for a boolean
    Definition: json.hpp:473
    -
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4637
    -
    bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2308
    -
    basic_json(const typename string_t::value_type *val)
    create a string (explicit)
    Definition: json.hpp:1187
    -
    basic_json(boolean_t val)
    create a boolean (explicit)
    Definition: json.hpp:1236
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6883
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3914
    -
    basic_json(const number_unsigned_t val)
    create an unsigned integer number (explicit)
    Definition: json.hpp:1365
    -
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:5179
    -
    basic_json(const string_t &val)
    create a string (explicit)
    Definition: json.hpp:1163
    -
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4563
    -
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3878
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:8538
    -
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:400
    -
    bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:2129
    -
    reference front()
    access the first element
    Definition: json.hpp:3549
    -
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:4935
    -
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:6869
    -
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6520
    -
    a class to store JSON values
    Definition: json.hpp:194
    -
    basic_json(const number_float_t val)
    create a floating-point number (explicit)
    Definition: json.hpp:1425
    -
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6708
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6896
    -
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:5158
    -
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4176
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:544
    -
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4721
    -
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:3090
    -
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6554
    -
    const_reverse_iterator rbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4122
    -
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6669
    -
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5516
    -
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6362
    -
    bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2327
    -
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:354
    +
    1 /*
    2  __ _____ _____ _____
    3  __| | __| | | | JSON for Modern C++
    4 | | |__ | | | | | | version 2.0.0
    5 |_____|_____|_____|_|___| https://github.com/nlohmann/json
    6 
    7 Copyright (c) 2013-2016 Niels Lohmann <http://nlohmann.me>.
    8 Licensed under the MIT License <http://opensource.org/licenses/MIT>.
    9 */
    10 
    11 #ifndef NLOHMANN_JSON_HPP
    12 #define NLOHMANN_JSON_HPP
    13 
    14 #include <algorithm>
    15 #include <array>
    16 #include <cassert>
    17 #include <ciso646>
    18 #include <cmath>
    19 #include <cstddef>
    20 #include <cstdio>
    21 #include <cstdlib>
    22 #include <functional>
    23 #include <initializer_list>
    24 #include <iomanip>
    25 #include <iostream>
    26 #include <iterator>
    27 #include <limits>
    28 #include <map>
    29 #include <memory>
    30 #include <sstream>
    31 #include <stdexcept>
    32 #include <string>
    33 #include <type_traits>
    34 #include <utility>
    35 #include <vector>
    36 
    37 // enable ssize_t on MinGW
    38 #ifdef __GNUC__
    39  #ifdef __MINGW32__
    40  #include <sys/types.h>
    41  #endif
    42 #endif
    43 
    44 // disable float-equal warnings on GCC/clang
    45 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    46  #pragma GCC diagnostic push
    47  #pragma GCC diagnostic ignored "-Wfloat-equal"
    48 #endif
    49 
    50 // enable ssize_t for MSVC
    51 #ifdef _MSC_VER
    52  #include <basetsd.h>
    53  using ssize_t = SSIZE_T;
    54 #endif
    55 
    61 namespace nlohmann
    62 {
    63 
    64 
    69 namespace
    70 {
    75 template<typename T>
    76 struct has_mapped_type
    77 {
    78  private:
    79  template<typename C> static char test(typename C::mapped_type*);
    80  template<typename C> static char (&test(...))[2];
    81  public:
    82  static constexpr bool value = sizeof(test<T>(0)) == 1;
    83 };
    84 
    85 }
    86 
    158 template <
    159  template<typename U, typename V, typename... Args> class ObjectType = std::map,
    160  template<typename U, typename... Args> class ArrayType = std::vector,
    161  class StringType = std::string,
    162  class BooleanType = bool,
    163  class NumberIntegerType = int64_t,
    164  class NumberUnsignedType = uint64_t,
    165  class NumberFloatType = double,
    166  template<typename U> class AllocatorType = std::allocator
    167  >
    169 {
    170  private:
    172  using basic_json_t = basic_json<ObjectType,
    173  ArrayType,
    174  StringType,
    175  BooleanType,
    176  NumberIntegerType,
    177  NumberUnsignedType,
    178  NumberFloatType,
    179  AllocatorType>;
    180 
    181  public:
    182 
    184  // container types //
    186 
    189 
    192 
    196  using const_reference = const value_type&;
    197 
    199  using difference_type = std::ptrdiff_t;
    201  using size_type = std::size_t;
    202 
    204  using allocator_type = AllocatorType<basic_json>;
    205 
    207  using pointer = typename std::allocator_traits<allocator_type>::pointer;
    209  using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
    210 
    211  // forward declaration
    212  template<typename Base> class json_reverse_iterator;
    213 
    215  class iterator;
    217  class const_iterator;
    222 
    224 
    225 
    230  {
    231  return allocator_type();
    232  }
    233 
    234 
    236  // JSON value data types //
    238 
    241 
    324  using object_t = ObjectType<StringType,
    325  basic_json,
    326  std::less<StringType>,
    327  AllocatorType<std::pair<const StringType,
    328  basic_json>>>;
    329 
    374  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
    375 
    421  using string_t = StringType;
    422 
    447  using boolean_t = BooleanType;
    448 
    518  using number_integer_t = NumberIntegerType;
    519 
    590  using number_unsigned_t = NumberUnsignedType;
    591 
    658  using number_float_t = NumberFloatType;
    659 
    661 
    662 
    664  // JSON type enumeration //
    666 
    677  enum class value_t : uint8_t
    678  {
    679  null,
    680  object,
    681  array,
    682  string,
    683  boolean,
    684  number_integer,
    685  number_unsigned,
    686  number_float,
    687  discarded
    688  };
    689 
    690 
    691  private:
    693  template<typename T, typename... Args>
    694  static T* create(Args&& ... args)
    695  {
    696  AllocatorType<T> alloc;
    697  auto deleter = [&](T * object)
    698  {
    699  alloc.deallocate(object, 1);
    700  };
    701  std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
    702  alloc.construct(object.get(), std::forward<Args>(args)...);
    703  return object.release();
    704  }
    705 
    707  // JSON value storage //
    709 
    717  union json_value
    718  {
    720  object_t* object;
    722  array_t* array;
    724  string_t* string;
    726  boolean_t boolean;
    728  number_integer_t number_integer;
    730  number_unsigned_t number_unsigned;
    732  number_float_t number_float;
    733 
    735  json_value() noexcept = default;
    737  json_value(boolean_t v) noexcept : boolean(v) {}
    739  json_value(number_integer_t v) noexcept : number_integer(v) {}
    741  json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
    743  json_value(number_float_t v) noexcept : number_float(v) {}
    745  json_value(value_t t)
    746  {
    747  switch (t)
    748  {
    749  case value_t::object:
    750  {
    751  object = create<object_t>();
    752  break;
    753  }
    754 
    755  case value_t::array:
    756  {
    757  array = create<array_t>();
    758  break;
    759  }
    760 
    761  case value_t::string:
    762  {
    763  string = create<string_t>("");
    764  break;
    765  }
    766 
    767  case value_t::boolean:
    768  {
    769  boolean = boolean_t(false);
    770  break;
    771  }
    772 
    773  case value_t::number_integer:
    774  {
    775  number_integer = number_integer_t(0);
    776  break;
    777  }
    778 
    779  case value_t::number_unsigned:
    780  {
    781  number_unsigned = number_unsigned_t(0);
    782  break;
    783  }
    784 
    785  case value_t::number_float:
    786  {
    787  number_float = number_float_t(0.0);
    788  break;
    789  }
    790 
    791  default:
    792  {
    793  break;
    794  }
    795  }
    796  }
    797 
    799  json_value(const string_t& value)
    800  {
    801  string = create<string_t>(value);
    802  }
    803 
    805  json_value(const object_t& value)
    806  {
    807  object = create<object_t>(value);
    808  }
    809 
    811  json_value(const array_t& value)
    812  {
    813  array = create<array_t>(value);
    814  }
    815  };
    816 
    817 
    818  public:
    820  // JSON parser callback //
    822 
    831  enum class parse_event_t : uint8_t
    832  {
    834  object_start,
    836  object_end,
    838  array_start,
    840  array_end,
    842  key,
    844  value
    845  };
    846 
    896  using parser_callback_t = std::function<bool(int depth, parse_event_t event, basic_json& parsed)>;
    897 
    898 
    900  // constructors //
    902 
    905 
    946  : m_type(value_type), m_value(value_type)
    947  {}
    948 
    968  basic_json() noexcept = default;
    969 
    989  basic_json(std::nullptr_t) noexcept
    990  : basic_json(value_t::null)
    991  {}
    992 
    1012  basic_json(const object_t& val)
    1013  : m_type(value_t::object), m_value(val)
    1014  {}
    1015 
    1039  template <class CompatibleObjectType, typename
    1040  std::enable_if<
    1041  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    1042  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    1043  = 0>
    1044  basic_json(const CompatibleObjectType& val)
    1045  : m_type(value_t::object)
    1046  {
    1047  using std::begin;
    1048  using std::end;
    1049  m_value.object = create<object_t>(begin(val), end(val));
    1050  }
    1051 
    1071  basic_json(const array_t& val)
    1072  : m_type(value_t::array), m_value(val)
    1073  {}
    1074 
    1098  template <class CompatibleArrayType, typename
    1099  std::enable_if<
    1100  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1101  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1102  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1103  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1104  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1105  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1106  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1107  = 0>
    1108  basic_json(const CompatibleArrayType& val)
    1109  : m_type(value_t::array)
    1110  {
    1111  using std::begin;
    1112  using std::end;
    1113  m_value.array = create<array_t>(begin(val), end(val));
    1114  }
    1115 
    1137  basic_json(const string_t& val)
    1138  : m_type(value_t::string), m_value(val)
    1139  {}
    1140 
    1161  basic_json(const typename string_t::value_type* val)
    1162  : basic_json(string_t(val))
    1163  {}
    1164 
    1188  template <class CompatibleStringType, typename
    1189  std::enable_if<
    1190  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1191  = 0>
    1192  basic_json(const CompatibleStringType& val)
    1193  : basic_json(string_t(val))
    1194  {}
    1195 
    1211  : m_type(value_t::boolean), m_value(val)
    1212  {}
    1213 
    1239  template<typename T,
    1240  typename std::enable_if<
    1241  not (std::is_same<T, int>::value)
    1242  and std::is_same<T, number_integer_t>::value
    1243  , int>::type
    1244  = 0>
    1246  : m_type(value_t::number_integer), m_value(val)
    1247  {}
    1248 
    1274  basic_json(const int val)
    1275  : m_type(value_t::number_integer),
    1276  m_value(static_cast<number_integer_t>(val))
    1277  {}
    1278 
    1304  template<typename CompatibleNumberIntegerType, typename
    1305  std::enable_if<
    1306  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1307  std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
    1308  std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
    1309  CompatibleNumberIntegerType>::type
    1310  = 0>
    1311  basic_json(const CompatibleNumberIntegerType val) noexcept
    1312  : m_type(value_t::number_integer),
    1313  m_value(static_cast<number_integer_t>(val))
    1314  {}
    1315 
    1333  template<typename T,
    1334  typename std::enable_if<
    1335  not (std::is_same<T, int>::value)
    1336  and std::is_same<T, number_unsigned_t>::value
    1337  , int>::type
    1338  = 0>
    1340  : m_type(value_t::number_unsigned), m_value(val)
    1341  {}
    1342 
    1363  template < typename CompatibleNumberUnsignedType, typename
    1364  std::enable_if <
    1365  std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
    1366  std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
    1367  !std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
    1368  CompatibleNumberUnsignedType >::type
    1369  = 0 >
    1370  basic_json(const CompatibleNumberUnsignedType val) noexcept
    1371  : m_type(value_t::number_unsigned),
    1372  m_value(static_cast<number_unsigned_t>(val))
    1373  {}
    1374 
    1400  : m_type(value_t::number_float), m_value(val)
    1401  {
    1402  // replace infinity and NAN by null
    1403  if (not std::isfinite(val))
    1404  {
    1405  m_type = value_t::null;
    1406  m_value = json_value();
    1407  }
    1408  }
    1409 
    1440  template<typename CompatibleNumberFloatType, typename = typename
    1441  std::enable_if<
    1442  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1443  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1444  >
    1445  basic_json(const CompatibleNumberFloatType val) noexcept
    1446  : basic_json(number_float_t(val))
    1447  {}
    1448 
    1518  basic_json(std::initializer_list<basic_json> init,
    1519  bool type_deduction = true,
    1520  value_t manual_type = value_t::array)
    1521  {
    1522  // the initializer list could describe an object
    1523  bool is_an_object = true;
    1524 
    1525  // check if each element is an array with two elements whose first
    1526  // element is a string
    1527  for (const auto& element : init)
    1528  {
    1529  if (not element.is_array() or element.size() != 2
    1530  or not element[0].is_string())
    1531  {
    1532  // we found an element that makes it impossible to use the
    1533  // initializer list as object
    1534  is_an_object = false;
    1535  break;
    1536  }
    1537  }
    1538 
    1539  // adjust type if type deduction is not wanted
    1540  if (not type_deduction)
    1541  {
    1542  // if array is wanted, do not create an object though possible
    1543  if (manual_type == value_t::array)
    1544  {
    1545  is_an_object = false;
    1546  }
    1547 
    1548  // if object is wanted but impossible, throw an exception
    1549  if (manual_type == value_t::object and not is_an_object)
    1550  {
    1551  throw std::domain_error("cannot create object from initializer list");
    1552  }
    1553  }
    1554 
    1555  if (is_an_object)
    1556  {
    1557  // the initializer list is a list of pairs -> create object
    1558  m_type = value_t::object;
    1559  m_value = value_t::object;
    1560 
    1561  assert(m_value.object != nullptr);
    1562 
    1563  for (auto& element : init)
    1564  {
    1565  m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1]));
    1566  }
    1567  }
    1568  else
    1569  {
    1570  // the initializer list describes an array -> create array
    1571  m_type = value_t::array;
    1572  m_value.array = create<array_t>(std::move(init));
    1573  }
    1574  }
    1575 
    1610  static basic_json array(std::initializer_list<basic_json> init =
    1611  std::initializer_list<basic_json>())
    1612  {
    1613  return basic_json(init, false, value_t::array);
    1614  }
    1615 
    1650  static basic_json object(std::initializer_list<basic_json> init =
    1651  std::initializer_list<basic_json>())
    1652  {
    1653  return basic_json(init, false, value_t::object);
    1654  }
    1655 
    1674  basic_json(size_type cnt, const basic_json& val)
    1675  : m_type(value_t::array)
    1676  {
    1677  m_value.array = create<array_t>(cnt, val);
    1678  }
    1679 
    1714  template <class InputIT, typename
    1715  std::enable_if<
    1716  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1717  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1718  , int>::type
    1719  = 0>
    1720  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1721  {
    1722  // make sure iterator fits the current value
    1723  if (first.m_object != last.m_object)
    1724  {
    1725  throw std::domain_error("iterators are not compatible");
    1726  }
    1727 
    1728  // check if iterator range is complete for primitive values
    1729  switch (m_type)
    1730  {
    1731  case value_t::boolean:
    1732  case value_t::number_float:
    1733  case value_t::number_integer:
    1734  case value_t::number_unsigned:
    1735  case value_t::string:
    1736  {
    1737  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1738  {
    1739  throw std::out_of_range("iterators out of range");
    1740  }
    1741  break;
    1742  }
    1743 
    1744  default:
    1745  {
    1746  break;
    1747  }
    1748  }
    1749 
    1750  switch (m_type)
    1751  {
    1752  case value_t::number_integer:
    1753  {
    1754  assert(first.m_object != nullptr);
    1755  m_value.number_integer = first.m_object->m_value.number_integer;
    1756  break;
    1757  }
    1758 
    1759  case value_t::number_unsigned:
    1760  {
    1761  assert(first.m_object != nullptr);
    1762  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
    1763  break;
    1764  }
    1765 
    1766  case value_t::number_float:
    1767  {
    1768  assert(first.m_object != nullptr);
    1769  m_value.number_float = first.m_object->m_value.number_float;
    1770  break;
    1771  }
    1772 
    1773  case value_t::boolean:
    1774  {
    1775  assert(first.m_object != nullptr);
    1776  m_value.boolean = first.m_object->m_value.boolean;
    1777  break;
    1778  }
    1779 
    1780  case value_t::string:
    1781  {
    1782  assert(first.m_object != nullptr);
    1783  m_value = *first.m_object->m_value.string;
    1784  break;
    1785  }
    1786 
    1787  case value_t::object:
    1788  {
    1789  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1790  break;
    1791  }
    1792 
    1793  case value_t::array:
    1794  {
    1795  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1796  break;
    1797  }
    1798 
    1799  default:
    1800  {
    1801  assert(first.m_object != nullptr);
    1802  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1803  }
    1804  }
    1805  }
    1806 
    1808  // other constructors and destructor //
    1810 
    1831  basic_json(const basic_json& other)
    1832  : m_type(other.m_type)
    1833  {
    1834  switch (m_type)
    1835  {
    1836  case value_t::object:
    1837  {
    1838  assert(other.m_value.object != nullptr);
    1839  m_value = *other.m_value.object;
    1840  break;
    1841  }
    1842 
    1843  case value_t::array:
    1844  {
    1845  assert(other.m_value.array != nullptr);
    1846  m_value = *other.m_value.array;
    1847  break;
    1848  }
    1849 
    1850  case value_t::string:
    1851  {
    1852  assert(other.m_value.string != nullptr);
    1853  m_value = *other.m_value.string;
    1854  break;
    1855  }
    1856 
    1857  case value_t::boolean:
    1858  {
    1859  m_value = other.m_value.boolean;
    1860  break;
    1861  }
    1862 
    1863  case value_t::number_integer:
    1864  {
    1865  m_value = other.m_value.number_integer;
    1866  break;
    1867  }
    1868 
    1869  case value_t::number_unsigned:
    1870  {
    1871  m_value = other.m_value.number_unsigned;
    1872  break;
    1873  }
    1874 
    1875  case value_t::number_float:
    1876  {
    1877  m_value = other.m_value.number_float;
    1878  break;
    1879  }
    1880 
    1881  default:
    1882  {
    1883  break;
    1884  }
    1885  }
    1886  }
    1887 
    1906  basic_json(basic_json&& other) noexcept
    1907  : m_type(std::move(other.m_type)),
    1908  m_value(std::move(other.m_value))
    1909  {
    1910  // invalidate payload
    1911  other.m_type = value_t::null;
    1912  other.m_value = {};
    1913  }
    1914 
    1936  reference& operator=(basic_json other) noexcept (
    1937  std::is_nothrow_move_constructible<value_t>::value and
    1938  std::is_nothrow_move_assignable<value_t>::value and
    1939  std::is_nothrow_move_constructible<json_value>::value and
    1940  std::is_nothrow_move_assignable<json_value>::value
    1941  )
    1942  {
    1943  using std::swap;
    1944  swap(m_type, other.m_type);
    1945  swap(m_value, other.m_value);
    1946  return *this;
    1947  }
    1948 
    1963  {
    1964  switch (m_type)
    1965  {
    1966  case value_t::object:
    1967  {
    1968  AllocatorType<object_t> alloc;
    1969  alloc.destroy(m_value.object);
    1970  alloc.deallocate(m_value.object, 1);
    1971  break;
    1972  }
    1973 
    1974  case value_t::array:
    1975  {
    1976  AllocatorType<array_t> alloc;
    1977  alloc.destroy(m_value.array);
    1978  alloc.deallocate(m_value.array, 1);
    1979  break;
    1980  }
    1981 
    1982  case value_t::string:
    1983  {
    1984  AllocatorType<string_t> alloc;
    1985  alloc.destroy(m_value.string);
    1986  alloc.deallocate(m_value.string, 1);
    1987  break;
    1988  }
    1989 
    1990  default:
    1991  {
    1992  // all other types need no specific destructor
    1993  break;
    1994  }
    1995  }
    1996  }
    1997 
    1999 
    2000  public:
    2002  // object inspection //
    2004 
    2007 
    2031  string_t dump(const int indent = -1) const
    2032  {
    2033  std::stringstream ss;
    2034 
    2035  if (indent >= 0)
    2036  {
    2037  dump(ss, true, static_cast<unsigned int>(indent));
    2038  }
    2039  else
    2040  {
    2041  dump(ss, false, 0);
    2042  }
    2043 
    2044  return ss.str();
    2045  }
    2046 
    2062  value_t type() const noexcept
    2063  {
    2064  return m_type;
    2065  }
    2066 
    2083  bool is_primitive() const noexcept
    2084  {
    2085  return is_null() or is_string() or is_boolean() or is_number();
    2086  }
    2087 
    2103  bool is_structured() const noexcept
    2104  {
    2105  return is_array() or is_object();
    2106  }
    2107 
    2122  bool is_null() const noexcept
    2123  {
    2124  return m_type == value_t::null;
    2125  }
    2126 
    2141  bool is_boolean() const noexcept
    2142  {
    2143  return m_type == value_t::boolean;
    2144  }
    2145 
    2168  bool is_number() const noexcept
    2169  {
    2170  return is_number_integer() or is_number_float();
    2171  }
    2172 
    2194  bool is_number_integer() const noexcept
    2195  {
    2196  return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
    2197  }
    2198 
    2219  bool is_number_unsigned() const noexcept
    2220  {
    2221  return m_type == value_t::number_unsigned;
    2222  }
    2223 
    2244  bool is_number_float() const noexcept
    2245  {
    2246  return m_type == value_t::number_float;
    2247  }
    2248 
    2263  bool is_object() const noexcept
    2264  {
    2265  return m_type == value_t::object;
    2266  }
    2267 
    2282  bool is_array() const noexcept
    2283  {
    2284  return m_type == value_t::array;
    2285  }
    2286 
    2301  bool is_string() const noexcept
    2302  {
    2303  return m_type == value_t::string;
    2304  }
    2305 
    2325  bool is_discarded() const noexcept
    2326  {
    2327  return m_type == value_t::discarded;
    2328  }
    2329 
    2345  operator value_t() const noexcept
    2346  {
    2347  return m_type;
    2348  }
    2349 
    2351 
    2352  private:
    2354  // value access //
    2356 
    2358  template <class T, typename
    2359  std::enable_if<
    2360  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2361  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2362  , int>::type = 0>
    2363  T get_impl(T*) const
    2364  {
    2365  if (is_object())
    2366  {
    2367  assert(m_value.object != nullptr);
    2368  return T(m_value.object->begin(), m_value.object->end());
    2369  }
    2370  else
    2371  {
    2372  throw std::domain_error("type must be object, but is " + type_name());
    2373  }
    2374  }
    2375 
    2377  object_t get_impl(object_t*) const
    2378  {
    2379  if (is_object())
    2380  {
    2381  assert(m_value.object != nullptr);
    2382  return *(m_value.object);
    2383  }
    2384  else
    2385  {
    2386  throw std::domain_error("type must be object, but is " + type_name());
    2387  }
    2388  }
    2389 
    2391  template <class T, typename
    2392  std::enable_if<
    2393  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2394  not std::is_same<basic_json_t, typename T::value_type>::value and
    2395  not std::is_arithmetic<T>::value and
    2396  not std::is_convertible<std::string, T>::value and
    2397  not has_mapped_type<T>::value
    2398  , int>::type = 0>
    2399  T get_impl(T*) const
    2400  {
    2401  if (is_array())
    2402  {
    2403  T to_vector;
    2404  assert(m_value.array != nullptr);
    2405  std::transform(m_value.array->begin(), m_value.array->end(),
    2406  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2407  {
    2408  return i.get<typename T::value_type>();
    2409  });
    2410  return to_vector;
    2411  }
    2412  else
    2413  {
    2414  throw std::domain_error("type must be array, but is " + type_name());
    2415  }
    2416  }
    2417 
    2419  template <class T, typename
    2420  std::enable_if<
    2421  std::is_convertible<basic_json_t, T>::value and
    2422  not std::is_same<basic_json_t, T>::value
    2423  , int>::type = 0>
    2424  std::vector<T> get_impl(std::vector<T>*) const
    2425  {
    2426  if (is_array())
    2427  {
    2428  std::vector<T> to_vector;
    2429  assert(m_value.array != nullptr);
    2430  to_vector.reserve(m_value.array->size());
    2431  std::transform(m_value.array->begin(), m_value.array->end(),
    2432  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2433  {
    2434  return i.get<T>();
    2435  });
    2436  return to_vector;
    2437  }
    2438  else
    2439  {
    2440  throw std::domain_error("type must be array, but is " + type_name());
    2441  }
    2442  }
    2443 
    2445  template <class T, typename
    2446  std::enable_if<
    2447  std::is_same<basic_json, typename T::value_type>::value and
    2448  not has_mapped_type<T>::value
    2449  , int>::type = 0>
    2450  T get_impl(T*) const
    2451  {
    2452  if (is_array())
    2453  {
    2454  assert(m_value.array != nullptr);
    2455  return T(m_value.array->begin(), m_value.array->end());
    2456  }
    2457  else
    2458  {
    2459  throw std::domain_error("type must be array, but is " + type_name());
    2460  }
    2461  }
    2462 
    2464  array_t get_impl(array_t*) const
    2465  {
    2466  if (is_array())
    2467  {
    2468  assert(m_value.array != nullptr);
    2469  return *(m_value.array);
    2470  }
    2471  else
    2472  {
    2473  throw std::domain_error("type must be array, but is " + type_name());
    2474  }
    2475  }
    2476 
    2478  template <typename T, typename
    2479  std::enable_if<
    2480  std::is_convertible<string_t, T>::value
    2481  , int>::type = 0>
    2482  T get_impl(T*) const
    2483  {
    2484  if (is_string())
    2485  {
    2486  assert(m_value.string != nullptr);
    2487  return *m_value.string;
    2488  }
    2489  else
    2490  {
    2491  throw std::domain_error("type must be string, but is " + type_name());
    2492  }
    2493  }
    2494 
    2496  template<typename T, typename
    2497  std::enable_if<
    2498  std::is_arithmetic<T>::value
    2499  , int>::type = 0>
    2500  T get_impl(T*) const
    2501  {
    2502  switch (m_type)
    2503  {
    2504  case value_t::number_integer:
    2505  {
    2506  return static_cast<T>(m_value.number_integer);
    2507  }
    2508 
    2509  case value_t::number_unsigned:
    2510  {
    2511  return static_cast<T>(m_value.number_unsigned);
    2512  }
    2513 
    2514  case value_t::number_float:
    2515  {
    2516  return static_cast<T>(m_value.number_float);
    2517  }
    2518 
    2519  default:
    2520  {
    2521  throw std::domain_error("type must be number, but is " + type_name());
    2522  }
    2523  }
    2524  }
    2525 
    2527  boolean_t get_impl(boolean_t*) const
    2528  {
    2529  if (is_boolean())
    2530  {
    2531  return m_value.boolean;
    2532  }
    2533  else
    2534  {
    2535  throw std::domain_error("type must be boolean, but is " + type_name());
    2536  }
    2537  }
    2538 
    2540  object_t* get_impl_ptr(object_t*) noexcept
    2541  {
    2542  return is_object() ? m_value.object : nullptr;
    2543  }
    2544 
    2546  const object_t* get_impl_ptr(const object_t*) const noexcept
    2547  {
    2548  return is_object() ? m_value.object : nullptr;
    2549  }
    2550 
    2552  array_t* get_impl_ptr(array_t*) noexcept
    2553  {
    2554  return is_array() ? m_value.array : nullptr;
    2555  }
    2556 
    2558  const array_t* get_impl_ptr(const array_t*) const noexcept
    2559  {
    2560  return is_array() ? m_value.array : nullptr;
    2561  }
    2562 
    2564  string_t* get_impl_ptr(string_t*) noexcept
    2565  {
    2566  return is_string() ? m_value.string : nullptr;
    2567  }
    2568 
    2570  const string_t* get_impl_ptr(const string_t*) const noexcept
    2571  {
    2572  return is_string() ? m_value.string : nullptr;
    2573  }
    2574 
    2576  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2577  {
    2578  return is_boolean() ? &m_value.boolean : nullptr;
    2579  }
    2580 
    2582  const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2583  {
    2584  return is_boolean() ? &m_value.boolean : nullptr;
    2585  }
    2586 
    2588  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2589  {
    2590  return is_number_integer() ? &m_value.number_integer : nullptr;
    2591  }
    2592 
    2594  const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2595  {
    2596  return is_number_integer() ? &m_value.number_integer : nullptr;
    2597  }
    2598 
    2600  number_unsigned_t* get_impl_ptr(number_unsigned_t*) noexcept
    2601  {
    2602  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2603  }
    2604 
    2606  const number_unsigned_t* get_impl_ptr(const number_unsigned_t*) const noexcept
    2607  {
    2608  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2609  }
    2610 
    2612  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2613  {
    2614  return is_number_float() ? &m_value.number_float : nullptr;
    2615  }
    2616 
    2618  const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2619  {
    2620  return is_number_float() ? &m_value.number_float : nullptr;
    2621  }
    2622 
    2634  template<typename ReferenceType, typename ThisType>
    2635  static ReferenceType get_ref_impl(ThisType& obj)
    2636  {
    2637  // delegate the call to get_ptr<>()
    2638  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2639  auto ptr = obj.template get_ptr<PointerType>();
    2640 
    2641  if (ptr != nullptr)
    2642  {
    2643  return *ptr;
    2644  }
    2645  else
    2646  {
    2647  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2648  obj.type_name());
    2649  }
    2650  }
    2651 
    2652  public:
    2653 
    2656 
    2690  template<typename ValueType, typename
    2691  std::enable_if<
    2692  not std::is_pointer<ValueType>::value
    2693  , int>::type = 0>
    2694  ValueType get() const
    2695  {
    2696  return get_impl(static_cast<ValueType*>(nullptr));
    2697  }
    2698 
    2725  template<typename PointerType, typename
    2726  std::enable_if<
    2727  std::is_pointer<PointerType>::value
    2728  , int>::type = 0>
    2729  PointerType get() noexcept
    2730  {
    2731  // delegate the call to get_ptr
    2732  return get_ptr<PointerType>();
    2733  }
    2734 
    2739  template<typename PointerType, typename
    2740  std::enable_if<
    2741  std::is_pointer<PointerType>::value
    2742  , int>::type = 0>
    2743  const PointerType get() const noexcept
    2744  {
    2745  // delegate the call to get_ptr
    2746  return get_ptr<PointerType>();
    2747  }
    2748 
    2774  template<typename PointerType, typename
    2775  std::enable_if<
    2776  std::is_pointer<PointerType>::value
    2777  , int>::type = 0>
    2778  PointerType get_ptr() noexcept
    2779  {
    2780  // delegate the call to get_impl_ptr<>()
    2781  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2782  }
    2783 
    2788  template<typename PointerType, typename
    2789  std::enable_if<
    2790  std::is_pointer<PointerType>::value
    2791  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2792  , int>::type = 0>
    2793  const PointerType get_ptr() const noexcept
    2794  {
    2795  // delegate the call to get_impl_ptr<>() const
    2796  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2797  }
    2798 
    2825  template<typename ReferenceType, typename
    2826  std::enable_if<
    2827  std::is_reference<ReferenceType>::value
    2828  , int>::type = 0>
    2829  ReferenceType get_ref()
    2830  {
    2831  // delegate call to get_ref_impl
    2832  return get_ref_impl<ReferenceType>(*this);
    2833  }
    2834 
    2839  template<typename ReferenceType, typename
    2840  std::enable_if<
    2841  std::is_reference<ReferenceType>::value
    2842  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2843  , int>::type = 0>
    2844  ReferenceType get_ref() const
    2845  {
    2846  // delegate call to get_ref_impl
    2847  return get_ref_impl<ReferenceType>(*this);
    2848  }
    2849 
    2878  template < typename ValueType, typename
    2879  std::enable_if <
    2880  not std::is_pointer<ValueType>::value
    2881  and not std::is_same<ValueType, typename string_t::value_type>::value
    2882 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2883  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2884 #endif
    2885  , int >::type = 0 >
    2886  operator ValueType() const
    2887  {
    2888  // delegate the call to get<>() const
    2889  return get<ValueType>();
    2890  }
    2891 
    2893 
    2894 
    2896  // element access //
    2898 
    2901 
    2925  {
    2926  // at only works for arrays
    2927  if (is_array())
    2928  {
    2929  try
    2930  {
    2931  assert(m_value.array != nullptr);
    2932  return m_value.array->at(idx);
    2933  }
    2934  catch (std::out_of_range&)
    2935  {
    2936  // create better exception explanation
    2937  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2938  }
    2939  }
    2940  else
    2941  {
    2942  throw std::domain_error("cannot use at() with " + type_name());
    2943  }
    2944  }
    2945 
    2969  {
    2970  // at only works for arrays
    2971  if (is_array())
    2972  {
    2973  try
    2974  {
    2975  assert(m_value.array != nullptr);
    2976  return m_value.array->at(idx);
    2977  }
    2978  catch (std::out_of_range&)
    2979  {
    2980  // create better exception explanation
    2981  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2982  }
    2983  }
    2984  else
    2985  {
    2986  throw std::domain_error("cannot use at() with " + type_name());
    2987  }
    2988  }
    2989 
    3016  reference at(const typename object_t::key_type& key)
    3017  {
    3018  // at only works for objects
    3019  if (is_object())
    3020  {
    3021  try
    3022  {
    3023  assert(m_value.object != nullptr);
    3024  return m_value.object->at(key);
    3025  }
    3026  catch (std::out_of_range&)
    3027  {
    3028  // create better exception explanation
    3029  throw std::out_of_range("key '" + key + "' not found");
    3030  }
    3031  }
    3032  else
    3033  {
    3034  throw std::domain_error("cannot use at() with " + type_name());
    3035  }
    3036  }
    3037 
    3064  const_reference at(const typename object_t::key_type& key) const
    3065  {
    3066  // at only works for objects
    3067  if (is_object())
    3068  {
    3069  try
    3070  {
    3071  assert(m_value.object != nullptr);
    3072  return m_value.object->at(key);
    3073  }
    3074  catch (std::out_of_range&)
    3075  {
    3076  // create better exception explanation
    3077  throw std::out_of_range("key '" + key + "' not found");
    3078  }
    3079  }
    3080  else
    3081  {
    3082  throw std::domain_error("cannot use at() with " + type_name());
    3083  }
    3084  }
    3085 
    3112  {
    3113  // implicitly convert null to object
    3114  if (is_null())
    3115  {
    3116  m_type = value_t::array;
    3117  m_value.array = create<array_t>();
    3118  }
    3119 
    3120  // [] only works for arrays
    3121  if (is_array())
    3122  {
    3123  assert(m_value.array != nullptr);
    3124  for (size_t i = m_value.array->size(); i <= idx; ++i)
    3125  {
    3126  m_value.array->push_back(basic_json());
    3127  }
    3128 
    3129  return m_value.array->operator[](idx);
    3130  }
    3131  else
    3132  {
    3133  throw std::domain_error("cannot use operator[] with " + type_name());
    3134  }
    3135  }
    3136 
    3157  {
    3158  // at only works for arrays
    3159  if (is_array())
    3160  {
    3161  assert(m_value.array != nullptr);
    3162  return m_value.array->operator[](idx);
    3163  }
    3164  else
    3165  {
    3166  throw std::domain_error("cannot use operator[] with " + type_name());
    3167  }
    3168  }
    3169 
    3197  reference operator[](const typename object_t::key_type& key)
    3198  {
    3199  // implicitly convert null to object
    3200  if (is_null())
    3201  {
    3202  m_type = value_t::object;
    3203  m_value.object = create<object_t>();
    3204  }
    3205 
    3206  // [] only works for objects
    3207  if (is_object())
    3208  {
    3209  assert(m_value.object != nullptr);
    3210  return m_value.object->operator[](key);
    3211  }
    3212  else
    3213  {
    3214  throw std::domain_error("cannot use operator[] with " + type_name());
    3215  }
    3216  }
    3217 
    3245  const_reference operator[](const typename object_t::key_type& key) const
    3246  {
    3247  // [] only works for objects
    3248  if (is_object())
    3249  {
    3250  assert(m_value.object != nullptr);
    3251  assert(m_value.object->find(key) != m_value.object->end());
    3252  return m_value.object->find(key)->second;
    3253  }
    3254  else
    3255  {
    3256  throw std::domain_error("cannot use operator[] with " + type_name());
    3257  }
    3258  }
    3259 
    3287  template<typename T, std::size_t n>
    3288  reference operator[](T * (&key)[n])
    3289  {
    3290  return operator[](static_cast<const T>(key));
    3291  }
    3292 
    3322  template<typename T, std::size_t n>
    3323  const_reference operator[](T * (&key)[n]) const
    3324  {
    3325  return operator[](static_cast<const T>(key));
    3326  }
    3327 
    3355  template<typename T>
    3357  {
    3358  // implicitly convert null to object
    3359  if (is_null())
    3360  {
    3361  m_type = value_t::object;
    3362  m_value = value_t::object;
    3363  }
    3364 
    3365  // at only works for objects
    3366  if (is_object())
    3367  {
    3368  assert(m_value.object != nullptr);
    3369  return m_value.object->operator[](key);
    3370  }
    3371  else
    3372  {
    3373  throw std::domain_error("cannot use operator[] with " + type_name());
    3374  }
    3375  }
    3376 
    3404  template<typename T>
    3406  {
    3407  // at only works for objects
    3408  if (is_object())
    3409  {
    3410  assert(m_value.object != nullptr);
    3411  assert(m_value.object->find(key) != m_value.object->end());
    3412  return m_value.object->find(key)->second;
    3413  }
    3414  else
    3415  {
    3416  throw std::domain_error("cannot use operator[] with " + type_name());
    3417  }
    3418  }
    3419 
    3468  template <class ValueType, typename
    3469  std::enable_if<
    3470  std::is_convertible<basic_json_t, ValueType>::value
    3471  , int>::type = 0>
    3472  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3473  {
    3474  // at only works for objects
    3475  if (is_object())
    3476  {
    3477  // if key is found, return value and given default value otherwise
    3478  const auto it = find(key);
    3479  if (it != end())
    3480  {
    3481  return *it;
    3482  }
    3483  else
    3484  {
    3485  return default_value;
    3486  }
    3487  }
    3488  else
    3489  {
    3490  throw std::domain_error("cannot use value() with " + type_name());
    3491  }
    3492  }
    3493 
    3498  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3499  {
    3500  return value(key, string_t(default_value));
    3501  }
    3502 
    3524  {
    3525  return *begin();
    3526  }
    3527 
    3532  {
    3533  return *cbegin();
    3534  }
    3535 
    3558  {
    3559  auto tmp = end();
    3560  --tmp;
    3561  return *tmp;
    3562  }
    3563 
    3568  {
    3569  auto tmp = cend();
    3570  --tmp;
    3571  return *tmp;
    3572  }
    3573 
    3618  template <class InteratorType, typename
    3619  std::enable_if<
    3620  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3621  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3622  , int>::type
    3623  = 0>
    3624  InteratorType erase(InteratorType pos)
    3625  {
    3626  // make sure iterator fits the current value
    3627  if (this != pos.m_object)
    3628  {
    3629  throw std::domain_error("iterator does not fit current value");
    3630  }
    3631 
    3632  InteratorType result = end();
    3633 
    3634  switch (m_type)
    3635  {
    3636  case value_t::boolean:
    3637  case value_t::number_float:
    3638  case value_t::number_integer:
    3639  case value_t::number_unsigned:
    3640  case value_t::string:
    3641  {
    3642  if (not pos.m_it.primitive_iterator.is_begin())
    3643  {
    3644  throw std::out_of_range("iterator out of range");
    3645  }
    3646 
    3647  if (is_string())
    3648  {
    3649  delete m_value.string;
    3650  m_value.string = nullptr;
    3651  }
    3652 
    3653  m_type = value_t::null;
    3654  break;
    3655  }
    3656 
    3657  case value_t::object:
    3658  {
    3659  assert(m_value.object != nullptr);
    3660  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3661  break;
    3662  }
    3663 
    3664  case value_t::array:
    3665  {
    3666  assert(m_value.array != nullptr);
    3667  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3668  break;
    3669  }
    3670 
    3671  default:
    3672  {
    3673  throw std::domain_error("cannot use erase() with " + type_name());
    3674  }
    3675  }
    3676 
    3677  return result;
    3678  }
    3679 
    3724  template <class InteratorType, typename
    3725  std::enable_if<
    3726  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3727  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3728  , int>::type
    3729  = 0>
    3730  InteratorType erase(InteratorType first, InteratorType last)
    3731  {
    3732  // make sure iterator fits the current value
    3733  if (this != first.m_object or this != last.m_object)
    3734  {
    3735  throw std::domain_error("iterators do not fit current value");
    3736  }
    3737 
    3738  InteratorType result = end();
    3739 
    3740  switch (m_type)
    3741  {
    3742  case value_t::boolean:
    3743  case value_t::number_float:
    3744  case value_t::number_integer:
    3745  case value_t::number_unsigned:
    3746  case value_t::string:
    3747  {
    3748  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3749  {
    3750  throw std::out_of_range("iterators out of range");
    3751  }
    3752 
    3753  if (is_string())
    3754  {
    3755  delete m_value.string;
    3756  m_value.string = nullptr;
    3757  }
    3758 
    3759  m_type = value_t::null;
    3760  break;
    3761  }
    3762 
    3763  case value_t::object:
    3764  {
    3765  assert(m_value.object != nullptr);
    3766  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3767  last.m_it.object_iterator);
    3768  break;
    3769  }
    3770 
    3771  case value_t::array:
    3772  {
    3773  assert(m_value.array != nullptr);
    3774  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3775  last.m_it.array_iterator);
    3776  break;
    3777  }
    3778 
    3779  default:
    3780  {
    3781  throw std::domain_error("cannot use erase() with " + type_name());
    3782  }
    3783  }
    3784 
    3785  return result;
    3786  }
    3787 
    3814  size_type erase(const typename object_t::key_type& key)
    3815  {
    3816  // this erase only works for objects
    3817  if (is_object())
    3818  {
    3819  assert(m_value.object != nullptr);
    3820  return m_value.object->erase(key);
    3821  }
    3822  else
    3823  {
    3824  throw std::domain_error("cannot use erase() with " + type_name());
    3825  }
    3826  }
    3827 
    3852  void erase(const size_type idx)
    3853  {
    3854  // this erase only works for arrays
    3855  if (is_array())
    3856  {
    3857  if (idx >= size())
    3858  {
    3859  throw std::out_of_range("index out of range");
    3860  }
    3861 
    3862  assert(m_value.array != nullptr);
    3863  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3864  }
    3865  else
    3866  {
    3867  throw std::domain_error("cannot use erase() with " + type_name());
    3868  }
    3869  }
    3870 
    3888  iterator find(typename object_t::key_type key)
    3889  {
    3890  auto result = end();
    3891 
    3892  if (is_object())
    3893  {
    3894  assert(m_value.object != nullptr);
    3895  result.m_it.object_iterator = m_value.object->find(key);
    3896  }
    3897 
    3898  return result;
    3899  }
    3900 
    3905  const_iterator find(typename object_t::key_type key) const
    3906  {
    3907  auto result = cend();
    3908 
    3909  if (is_object())
    3910  {
    3911  assert(m_value.object != nullptr);
    3912  result.m_it.object_iterator = m_value.object->find(key);
    3913  }
    3914 
    3915  return result;
    3916  }
    3917 
    3936  size_type count(typename object_t::key_type key) const
    3937  {
    3938  // return 0 for all nonobject types
    3939  assert(not is_object() or m_value.object != nullptr);
    3940  return is_object() ? m_value.object->count(key) : 0;
    3941  }
    3942 
    3944 
    3945 
    3947  // iterators //
    3949 
    3952 
    3972  {
    3973  iterator result(this);
    3974  result.set_begin();
    3975  return result;
    3976  }
    3977 
    3982  {
    3983  return cbegin();
    3984  }
    3985 
    4006  {
    4007  const_iterator result(this);
    4008  result.set_begin();
    4009  return result;
    4010  }
    4011 
    4031  {
    4032  iterator result(this);
    4033  result.set_end();
    4034  return result;
    4035  }
    4036 
    4041  {
    4042  return cend();
    4043  }
    4044 
    4065  {
    4066  const_iterator result(this);
    4067  result.set_end();
    4068  return result;
    4069  }
    4070 
    4089  {
    4090  return reverse_iterator(end());
    4091  }
    4092 
    4097  {
    4098  return crbegin();
    4099  }
    4100 
    4120  {
    4121  return reverse_iterator(begin());
    4122  }
    4123 
    4128  {
    4129  return crend();
    4130  }
    4131 
    4151  {
    4152  return const_reverse_iterator(cend());
    4153  }
    4154 
    4174  {
    4175  return const_reverse_iterator(cbegin());
    4176  }
    4177 
    4178  private:
    4179  // forward declaration
    4180  template<typename IteratorType> class iteration_proxy;
    4181 
    4182  public:
    4194  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    4195  {
    4196  return iteration_proxy<iterator>(cont);
    4197  }
    4198 
    4202  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4203  {
    4204  return iteration_proxy<const_iterator>(cont);
    4205  }
    4206 
    4208 
    4209 
    4211  // capacity //
    4213 
    4216 
    4246  bool empty() const noexcept
    4247  {
    4248  switch (m_type)
    4249  {
    4250  case value_t::null:
    4251  {
    4252  // null values are empty
    4253  return true;
    4254  }
    4255 
    4256  case value_t::array:
    4257  {
    4258  assert(m_value.array != nullptr);
    4259  return m_value.array->empty();
    4260  }
    4261 
    4262  case value_t::object:
    4263  {
    4264  assert(m_value.object != nullptr);
    4265  return m_value.object->empty();
    4266  }
    4267 
    4268  default:
    4269  {
    4270  // all other types are nonempty
    4271  return false;
    4272  }
    4273  }
    4274  }
    4275 
    4304  size_type size() const noexcept
    4305  {
    4306  switch (m_type)
    4307  {
    4308  case value_t::null:
    4309  {
    4310  // null values are empty
    4311  return 0;
    4312  }
    4313 
    4314  case value_t::array:
    4315  {
    4316  assert(m_value.array != nullptr);
    4317  return m_value.array->size();
    4318  }
    4319 
    4320  case value_t::object:
    4321  {
    4322  assert(m_value.object != nullptr);
    4323  return m_value.object->size();
    4324  }
    4325 
    4326  default:
    4327  {
    4328  // all other types have size 1
    4329  return 1;
    4330  }
    4331  }
    4332  }
    4333 
    4366  size_type max_size() const noexcept
    4367  {
    4368  switch (m_type)
    4369  {
    4370  case value_t::array:
    4371  {
    4372  assert(m_value.array != nullptr);
    4373  return m_value.array->max_size();
    4374  }
    4375 
    4376  case value_t::object:
    4377  {
    4378  assert(m_value.object != nullptr);
    4379  return m_value.object->max_size();
    4380  }
    4381 
    4382  default:
    4383  {
    4384  // all other types have max_size() == size()
    4385  return size();
    4386  }
    4387  }
    4388  }
    4389 
    4391 
    4392 
    4394  // modifiers //
    4396 
    4399 
    4425  void clear() noexcept
    4426  {
    4427  switch (m_type)
    4428  {
    4429  case value_t::number_integer:
    4430  {
    4431  m_value.number_integer = 0;
    4432  break;
    4433  }
    4434 
    4435  case value_t::number_unsigned:
    4436  {
    4437  m_value.number_unsigned = 0;
    4438  break;
    4439  }
    4440 
    4441  case value_t::number_float:
    4442  {
    4443  m_value.number_float = 0.0;
    4444  break;
    4445  }
    4446 
    4447  case value_t::boolean:
    4448  {
    4449  m_value.boolean = false;
    4450  break;
    4451  }
    4452 
    4453  case value_t::string:
    4454  {
    4455  assert(m_value.string != nullptr);
    4456  m_value.string->clear();
    4457  break;
    4458  }
    4459 
    4460  case value_t::array:
    4461  {
    4462  assert(m_value.array != nullptr);
    4463  m_value.array->clear();
    4464  break;
    4465  }
    4466 
    4467  case value_t::object:
    4468  {
    4469  assert(m_value.object != nullptr);
    4470  m_value.object->clear();
    4471  break;
    4472  }
    4473 
    4474  default:
    4475  {
    4476  break;
    4477  }
    4478  }
    4479  }
    4480 
    4501  void push_back(basic_json&& val)
    4502  {
    4503  // push_back only works for null objects or arrays
    4504  if (not(is_null() or is_array()))
    4505  {
    4506  throw std::domain_error("cannot use push_back() with " + type_name());
    4507  }
    4508 
    4509  // transform null object into an array
    4510  if (is_null())
    4511  {
    4512  m_type = value_t::array;
    4513  m_value = value_t::array;
    4514  }
    4515 
    4516  // add element to array (move semantics)
    4517  assert(m_value.array != nullptr);
    4518  m_value.array->push_back(std::move(val));
    4519  // invalidate object
    4520  val.m_type = value_t::null;
    4521  }
    4522 
    4527  reference operator+=(basic_json&& val)
    4528  {
    4529  push_back(std::move(val));
    4530  return *this;
    4531  }
    4532 
    4537  void push_back(const basic_json& val)
    4538  {
    4539  // push_back only works for null objects or arrays
    4540  if (not(is_null() or is_array()))
    4541  {
    4542  throw std::domain_error("cannot use push_back() with " + type_name());
    4543  }
    4544 
    4545  // transform null object into an array
    4546  if (is_null())
    4547  {
    4548  m_type = value_t::array;
    4549  m_value = value_t::array;
    4550  }
    4551 
    4552  // add element to array
    4553  assert(m_value.array != nullptr);
    4554  m_value.array->push_back(val);
    4555  }
    4556 
    4561  reference operator+=(const basic_json& val)
    4562  {
    4563  push_back(val);
    4564  return *this;
    4565  }
    4566 
    4587  void push_back(const typename object_t::value_type& val)
    4588  {
    4589  // push_back only works for null objects or objects
    4590  if (not(is_null() or is_object()))
    4591  {
    4592  throw std::domain_error("cannot use push_back() with " + type_name());
    4593  }
    4594 
    4595  // transform null object into an object
    4596  if (is_null())
    4597  {
    4598  m_type = value_t::object;
    4599  m_value = value_t::object;
    4600  }
    4601 
    4602  // add element to array
    4603  assert(m_value.object != nullptr);
    4604  m_value.object->insert(val);
    4605  }
    4606 
    4611  reference operator+=(const typename object_t::value_type& val)
    4612  {
    4613  push_back(val);
    4614  return operator[](val.first);
    4615  }
    4616 
    4639  iterator insert(const_iterator pos, const basic_json& val)
    4640  {
    4641  // insert only works for arrays
    4642  if (is_array())
    4643  {
    4644  // check if iterator pos fits to this JSON value
    4645  if (pos.m_object != this)
    4646  {
    4647  throw std::domain_error("iterator does not fit current value");
    4648  }
    4649 
    4650  // insert to array and return iterator
    4651  iterator result(this);
    4652  assert(m_value.array != nullptr);
    4653  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4654  return result;
    4655  }
    4656  else
    4657  {
    4658  throw std::domain_error("cannot use insert() with " + type_name());
    4659  }
    4660  }
    4661 
    4666  iterator insert(const_iterator pos, basic_json&& val)
    4667  {
    4668  return insert(pos, val);
    4669  }
    4670 
    4695  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4696  {
    4697  // insert only works for arrays
    4698  if (is_array())
    4699  {
    4700  // check if iterator pos fits to this JSON value
    4701  if (pos.m_object != this)
    4702  {
    4703  throw std::domain_error("iterator does not fit current value");
    4704  }
    4705 
    4706  // insert to array and return iterator
    4707  iterator result(this);
    4708  assert(m_value.array != nullptr);
    4709  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4710  return result;
    4711  }
    4712  else
    4713  {
    4714  throw std::domain_error("cannot use insert() with " + type_name());
    4715  }
    4716  }
    4717 
    4749  {
    4750  // insert only works for arrays
    4751  if (not is_array())
    4752  {
    4753  throw std::domain_error("cannot use insert() with " + type_name());
    4754  }
    4755 
    4756  // check if iterator pos fits to this JSON value
    4757  if (pos.m_object != this)
    4758  {
    4759  throw std::domain_error("iterator does not fit current value");
    4760  }
    4761 
    4762  if (first.m_object != last.m_object)
    4763  {
    4764  throw std::domain_error("iterators do not fit");
    4765  }
    4766 
    4767  if (first.m_object == this or last.m_object == this)
    4768  {
    4769  throw std::domain_error("passed iterators may not belong to container");
    4770  }
    4771 
    4772  // insert to array and return iterator
    4773  iterator result(this);
    4774  assert(m_value.array != nullptr);
    4775  result.m_it.array_iterator = m_value.array->insert(
    4776  pos.m_it.array_iterator,
    4777  first.m_it.array_iterator,
    4778  last.m_it.array_iterator);
    4779  return result;
    4780  }
    4781 
    4806  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4807  {
    4808  // insert only works for arrays
    4809  if (not is_array())
    4810  {
    4811  throw std::domain_error("cannot use insert() with " + type_name());
    4812  }
    4813 
    4814  // check if iterator pos fits to this JSON value
    4815  if (pos.m_object != this)
    4816  {
    4817  throw std::domain_error("iterator does not fit current value");
    4818  }
    4819 
    4820  // insert to array and return iterator
    4821  iterator result(this);
    4822  assert(m_value.array != nullptr);
    4823  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4824  return result;
    4825  }
    4826 
    4844  void swap(reference other) noexcept (
    4845  std::is_nothrow_move_constructible<value_t>::value and
    4846  std::is_nothrow_move_assignable<value_t>::value and
    4847  std::is_nothrow_move_constructible<json_value>::value and
    4848  std::is_nothrow_move_assignable<json_value>::value
    4849  )
    4850  {
    4851  std::swap(m_type, other.m_type);
    4852  std::swap(m_value, other.m_value);
    4853  }
    4854 
    4875  void swap(array_t& other)
    4876  {
    4877  // swap only works for arrays
    4878  if (is_array())
    4879  {
    4880  assert(m_value.array != nullptr);
    4881  std::swap(*(m_value.array), other);
    4882  }
    4883  else
    4884  {
    4885  throw std::domain_error("cannot use swap() with " + type_name());
    4886  }
    4887  }
    4888 
    4909  void swap(object_t& other)
    4910  {
    4911  // swap only works for objects
    4912  if (is_object())
    4913  {
    4914  assert(m_value.object != nullptr);
    4915  std::swap(*(m_value.object), other);
    4916  }
    4917  else
    4918  {
    4919  throw std::domain_error("cannot use swap() with " + type_name());
    4920  }
    4921  }
    4922 
    4943  void swap(string_t& other)
    4944  {
    4945  // swap only works for strings
    4946  if (is_string())
    4947  {
    4948  assert(m_value.string != nullptr);
    4949  std::swap(*(m_value.string), other);
    4950  }
    4951  else
    4952  {
    4953  throw std::domain_error("cannot use swap() with " + type_name());
    4954  }
    4955  }
    4956 
    4958 
    4959 
    4961  // lexicographical comparison operators //
    4963 
    4966 
    4967  private:
    4977  friend bool operator<(const value_t lhs, const value_t rhs)
    4978  {
    4979  static constexpr std::array<uint8_t, 8> order = {{
    4980  0, // null
    4981  3, // object
    4982  4, // array
    4983  5, // string
    4984  1, // boolean
    4985  2, // integer
    4986  2, // unsigned
    4987  2, // float
    4988  }
    4989  };
    4990 
    4991  // discarded values are not comparable
    4992  if (lhs == value_t::discarded or rhs == value_t::discarded)
    4993  {
    4994  return false;
    4995  }
    4996 
    4997  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    4998  }
    4999 
    5000  public:
    5024  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    5025  {
    5026  const auto lhs_type = lhs.type();
    5027  const auto rhs_type = rhs.type();
    5028 
    5029  if (lhs_type == rhs_type)
    5030  {
    5031  switch (lhs_type)
    5032  {
    5033  case value_t::array:
    5034  {
    5035  assert(lhs.m_value.array != nullptr);
    5036  assert(rhs.m_value.array != nullptr);
    5037  return *lhs.m_value.array == *rhs.m_value.array;
    5038  }
    5039  case value_t::object:
    5040  {
    5041  assert(lhs.m_value.object != nullptr);
    5042  assert(rhs.m_value.object != nullptr);
    5043  return *lhs.m_value.object == *rhs.m_value.object;
    5044  }
    5045  case value_t::null:
    5046  {
    5047  return true;
    5048  }
    5049  case value_t::string:
    5050  {
    5051  assert(lhs.m_value.string != nullptr);
    5052  assert(rhs.m_value.string != nullptr);
    5053  return *lhs.m_value.string == *rhs.m_value.string;
    5054  }
    5055  case value_t::boolean:
    5056  {
    5057  return lhs.m_value.boolean == rhs.m_value.boolean;
    5058  }
    5059  case value_t::number_integer:
    5060  {
    5061  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    5062  }
    5063  case value_t::number_unsigned:
    5064  {
    5065  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
    5066  }
    5067  case value_t::number_float:
    5068  {
    5069  return lhs.m_value.number_float == rhs.m_value.number_float;
    5070  }
    5071  default:
    5072  {
    5073  return false;
    5074  }
    5075  }
    5076  }
    5077  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5078  {
    5079  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    5080  }
    5081  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5082  {
    5083  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    5084  }
    5085  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5086  {
    5087  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
    5088  }
    5089  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5090  {
    5091  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5092  }
    5093  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5094  {
    5095  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
    5096  }
    5097  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5098  {
    5099  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5100  }
    5101 
    5102  return false;
    5103  }
    5104 
    5123  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    5124  {
    5125  return v.is_null();
    5126  }
    5127 
    5132  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    5133  {
    5134  return v.is_null();
    5135  }
    5136 
    5153  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    5154  {
    5155  return not (lhs == rhs);
    5156  }
    5157 
    5176  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    5177  {
    5178  return not v.is_null();
    5179  }
    5180 
    5185  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    5186  {
    5187  return not v.is_null();
    5188  }
    5189 
    5214  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    5215  {
    5216  const auto lhs_type = lhs.type();
    5217  const auto rhs_type = rhs.type();
    5218 
    5219  if (lhs_type == rhs_type)
    5220  {
    5221  switch (lhs_type)
    5222  {
    5223  case value_t::array:
    5224  {
    5225  assert(lhs.m_value.array != nullptr);
    5226  assert(rhs.m_value.array != nullptr);
    5227  return *lhs.m_value.array < *rhs.m_value.array;
    5228  }
    5229  case value_t::object:
    5230  {
    5231  assert(lhs.m_value.object != nullptr);
    5232  assert(rhs.m_value.object != nullptr);
    5233  return *lhs.m_value.object < *rhs.m_value.object;
    5234  }
    5235  case value_t::null:
    5236  {
    5237  return false;
    5238  }
    5239  case value_t::string:
    5240  {
    5241  assert(lhs.m_value.string != nullptr);
    5242  assert(rhs.m_value.string != nullptr);
    5243  return *lhs.m_value.string < *rhs.m_value.string;
    5244  }
    5245  case value_t::boolean:
    5246  {
    5247  return lhs.m_value.boolean < rhs.m_value.boolean;
    5248  }
    5249  case value_t::number_integer:
    5250  {
    5251  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5252  }
    5253  case value_t::number_unsigned:
    5254  {
    5255  return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
    5256  }
    5257  case value_t::number_float:
    5258  {
    5259  return lhs.m_value.number_float < rhs.m_value.number_float;
    5260  }
    5261  default:
    5262  {
    5263  return false;
    5264  }
    5265  }
    5266  }
    5267  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5268  {
    5269  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
    5270  }
    5271  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5272  {
    5273  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
    5274  }
    5275  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5276  {
    5277  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
    5278  }
    5279  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5280  {
    5281  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5282  }
    5283  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5284  {
    5285  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5286  }
    5287  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5288  {
    5289  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
    5290  }
    5291 
    5292  // We only reach this line if we cannot compare values. In that case,
    5293  // we compare types. Note we have to call the operator explicitly,
    5294  // because MSVC has problems otherwise.
    5295  return operator<(lhs_type, rhs_type);
    5296  }
    5297 
    5315  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5316  {
    5317  return not (rhs < lhs);
    5318  }
    5319 
    5337  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5338  {
    5339  return not (lhs <= rhs);
    5340  }
    5341 
    5359  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5360  {
    5361  return not (lhs < rhs);
    5362  }
    5363 
    5365 
    5366 
    5368  // serialization //
    5370 
    5373 
    5396  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5397  {
    5398  // read width member and use it as indentation parameter if nonzero
    5399  const bool pretty_print = (o.width() > 0);
    5400  const auto indentation = (pretty_print ? o.width() : 0);
    5401 
    5402  // reset width to 0 for subsequent calls to this stream
    5403  o.width(0);
    5404 
    5405  // do the actual serialization
    5406  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5407  return o;
    5408  }
    5409 
    5414  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5415  {
    5416  return o << j;
    5417  }
    5418 
    5420 
    5421 
    5423  // deserialization //
    5425 
    5428 
    5453  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5454  {
    5455  return parser(s, cb).parse();
    5456  }
    5457 
    5482  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5483  {
    5484  return parser(i, cb).parse();
    5485  }
    5486 
    5490  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5491  {
    5492  return parser(i, cb).parse();
    5493  }
    5494 
    5518  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5519  {
    5520  j = parser(i).parse();
    5521  return i;
    5522  }
    5523 
    5528  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5529  {
    5530  j = parser(i).parse();
    5531  return i;
    5532  }
    5533 
    5535 
    5536 
    5537  private:
    5539  // convenience functions //
    5541 
    5543  string_t type_name() const
    5544  {
    5545  switch (m_type)
    5546  {
    5547  case value_t::null:
    5548  return "null";
    5549  case value_t::object:
    5550  return "object";
    5551  case value_t::array:
    5552  return "array";
    5553  case value_t::string:
    5554  return "string";
    5555  case value_t::boolean:
    5556  return "boolean";
    5557  case value_t::discarded:
    5558  return "discarded";
    5559  default:
    5560  return "number";
    5561  }
    5562  }
    5563 
    5572  static std::size_t extra_space(const string_t& s) noexcept
    5573  {
    5574  std::size_t result = 0;
    5575 
    5576  for (const auto& c : s)
    5577  {
    5578  switch (c)
    5579  {
    5580  case '"':
    5581  case '\\':
    5582  case '\b':
    5583  case '\f':
    5584  case '\n':
    5585  case '\r':
    5586  case '\t':
    5587  {
    5588  // from c (1 byte) to \x (2 bytes)
    5589  result += 1;
    5590  break;
    5591  }
    5592 
    5593  default:
    5594  {
    5595  if (c >= 0x00 and c <= 0x1f)
    5596  {
    5597  // from c (1 byte) to \uxxxx (6 bytes)
    5598  result += 5;
    5599  }
    5600  break;
    5601  }
    5602  }
    5603  }
    5604 
    5605  return result;
    5606  }
    5607 
    5621  static string_t escape_string(const string_t& s) noexcept
    5622  {
    5623  const auto space = extra_space(s);
    5624  if (space == 0)
    5625  {
    5626  return s;
    5627  }
    5628 
    5629  // create a result string of necessary size
    5630  string_t result(s.size() + space, '\\');
    5631  std::size_t pos = 0;
    5632 
    5633  for (const auto& c : s)
    5634  {
    5635  switch (c)
    5636  {
    5637  // quotation mark (0x22)
    5638  case '"':
    5639  {
    5640  result[pos + 1] = '"';
    5641  pos += 2;
    5642  break;
    5643  }
    5644 
    5645  // reverse solidus (0x5c)
    5646  case '\\':
    5647  {
    5648  // nothing to change
    5649  pos += 2;
    5650  break;
    5651  }
    5652 
    5653  // backspace (0x08)
    5654  case '\b':
    5655  {
    5656  result[pos + 1] = 'b';
    5657  pos += 2;
    5658  break;
    5659  }
    5660 
    5661  // formfeed (0x0c)
    5662  case '\f':
    5663  {
    5664  result[pos + 1] = 'f';
    5665  pos += 2;
    5666  break;
    5667  }
    5668 
    5669  // newline (0x0a)
    5670  case '\n':
    5671  {
    5672  result[pos + 1] = 'n';
    5673  pos += 2;
    5674  break;
    5675  }
    5676 
    5677  // carriage return (0x0d)
    5678  case '\r':
    5679  {
    5680  result[pos + 1] = 'r';
    5681  pos += 2;
    5682  break;
    5683  }
    5684 
    5685  // horizontal tab (0x09)
    5686  case '\t':
    5687  {
    5688  result[pos + 1] = 't';
    5689  pos += 2;
    5690  break;
    5691  }
    5692 
    5693  default:
    5694  {
    5695  if (c >= 0x00 and c <= 0x1f)
    5696  {
    5697  // convert a number 0..15 to its hex representation (0..f)
    5698  auto hexify = [](const char v) -> char
    5699  {
    5700  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5701  };
    5702 
    5703  // print character c as \uxxxx
    5704  for (const char m :
    5705  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5706  })
    5707  {
    5708  result[++pos] = m;
    5709  }
    5710 
    5711  ++pos;
    5712  }
    5713  else
    5714  {
    5715  // all other characters are added as-is
    5716  result[pos++] = c;
    5717  }
    5718  break;
    5719  }
    5720  }
    5721  }
    5722 
    5723  return result;
    5724  }
    5725 
    5743  void dump(std::ostream& o,
    5744  const bool pretty_print,
    5745  const unsigned int indent_step,
    5746  const unsigned int current_indent = 0) const
    5747  {
    5748  // variable to hold indentation for recursive calls
    5749  unsigned int new_indent = current_indent;
    5750 
    5751  switch (m_type)
    5752  {
    5753  case value_t::object:
    5754  {
    5755  assert(m_value.object != nullptr);
    5756 
    5757  if (m_value.object->empty())
    5758  {
    5759  o << "{}";
    5760  return;
    5761  }
    5762 
    5763  o << "{";
    5764 
    5765  // increase indentation
    5766  if (pretty_print)
    5767  {
    5768  new_indent += indent_step;
    5769  o << "\n";
    5770  }
    5771 
    5772  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5773  {
    5774  if (i != m_value.object->cbegin())
    5775  {
    5776  o << (pretty_print ? ",\n" : ",");
    5777  }
    5778  o << string_t(new_indent, ' ') << "\""
    5779  << escape_string(i->first) << "\":"
    5780  << (pretty_print ? " " : "");
    5781  i->second.dump(o, pretty_print, indent_step, new_indent);
    5782  }
    5783 
    5784  // decrease indentation
    5785  if (pretty_print)
    5786  {
    5787  new_indent -= indent_step;
    5788  o << "\n";
    5789  }
    5790 
    5791  o << string_t(new_indent, ' ') + "}";
    5792  return;
    5793  }
    5794 
    5795  case value_t::array:
    5796  {
    5797  assert(m_value.array != nullptr);
    5798 
    5799  if (m_value.array->empty())
    5800  {
    5801  o << "[]";
    5802  return;
    5803  }
    5804 
    5805  o << "[";
    5806 
    5807  // increase indentation
    5808  if (pretty_print)
    5809  {
    5810  new_indent += indent_step;
    5811  o << "\n";
    5812  }
    5813 
    5814  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5815  {
    5816  if (i != m_value.array->cbegin())
    5817  {
    5818  o << (pretty_print ? ",\n" : ",");
    5819  }
    5820  o << string_t(new_indent, ' ');
    5821  i->dump(o, pretty_print, indent_step, new_indent);
    5822  }
    5823 
    5824  // decrease indentation
    5825  if (pretty_print)
    5826  {
    5827  new_indent -= indent_step;
    5828  o << "\n";
    5829  }
    5830 
    5831  o << string_t(new_indent, ' ') << "]";
    5832  return;
    5833  }
    5834 
    5835  case value_t::string:
    5836  {
    5837  assert(m_value.string != nullptr);
    5838  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5839  return;
    5840  }
    5841 
    5842  case value_t::boolean:
    5843  {
    5844  o << (m_value.boolean ? "true" : "false");
    5845  return;
    5846  }
    5847 
    5848  case value_t::number_integer:
    5849  {
    5850  o << m_value.number_integer;
    5851  return;
    5852  }
    5853 
    5854  case value_t::number_unsigned:
    5855  {
    5856  o << m_value.number_unsigned;
    5857  return;
    5858  }
    5859 
    5860  case value_t::number_float:
    5861  {
    5862  // If the number is an integer then output as a fixed with with
    5863  // precision 1 to output "0.0", "1.0" etc as expected for some
    5864  // round trip tests otherwise 15 digits of precision allows
    5865  // round-trip IEEE 754 string->double->string; to be safe, we
    5866  // read this value from
    5867  // std::numeric_limits<number_float_t>::digits10
    5868  if (std::fmod(m_value.number_float, 1) == 0)
    5869  {
    5870  o << std::fixed << std::setprecision(1);
    5871  }
    5872  else
    5873  {
    5874  // std::defaultfloat not supported in gcc version < 5
    5875  o.unsetf(std::ios_base::floatfield);
    5876  o << std::setprecision(std::numeric_limits<double>::digits10);
    5877  }
    5878  o << m_value.number_float;
    5879  return;
    5880  }
    5881 
    5882  case value_t::discarded:
    5883  {
    5884  o << "<discarded>";
    5885  return;
    5886  }
    5887 
    5888  case value_t::null:
    5889  {
    5890  o << "null";
    5891  return;
    5892  }
    5893  }
    5894  }
    5895 
    5896  private:
    5898  // member variables //
    5900 
    5902  value_t m_type = value_t::null;
    5903 
    5905  json_value m_value = {};
    5906 
    5907 
    5908  private:
    5910  // iterators //
    5912 
    5922  class primitive_iterator_t
    5923  {
    5924  public:
    5926  void set_begin()
    5927  {
    5928  m_it = begin_value;
    5929  }
    5930 
    5932  void set_end()
    5933  {
    5934  m_it = end_value;
    5935  }
    5936 
    5938  bool is_begin() const
    5939  {
    5940  return (m_it == begin_value);
    5941  }
    5942 
    5944  bool is_end() const
    5945  {
    5946  return (m_it == end_value);
    5947  }
    5948 
    5950  operator difference_type& ()
    5951  {
    5952  return m_it;
    5953  }
    5954 
    5956  operator difference_type () const
    5957  {
    5958  return m_it;
    5959  }
    5960 
    5961  private:
    5962  static constexpr difference_type begin_value = 0;
    5963  static constexpr difference_type end_value = begin_value + 1;
    5964 
    5966  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    5967  };
    5968 
    5976  struct internal_iterator
    5977  {
    5979  typename object_t::iterator object_iterator;
    5981  typename array_t::iterator array_iterator;
    5983  primitive_iterator_t primitive_iterator;
    5984 
    5986  internal_iterator()
    5987  : object_iterator(), array_iterator(), primitive_iterator()
    5988  {}
    5989  };
    5990 
    5992  template<typename IteratorType>
    5993  class iteration_proxy
    5994  {
    5995  private:
    5997  class iteration_proxy_internal
    5998  {
    5999  private:
    6001  IteratorType anchor;
    6003  size_t array_index = 0;
    6004 
    6005  public:
    6006  iteration_proxy_internal(IteratorType it)
    6007  : anchor(it)
    6008  {}
    6009 
    6011  iteration_proxy_internal& operator*()
    6012  {
    6013  return *this;
    6014  }
    6015 
    6017  iteration_proxy_internal& operator++()
    6018  {
    6019  ++anchor;
    6020  ++array_index;
    6021 
    6022  return *this;
    6023  }
    6024 
    6026  bool operator!= (const iteration_proxy_internal& o) const
    6027  {
    6028  return anchor != o.anchor;
    6029  }
    6030 
    6032  typename basic_json::string_t key() const
    6033  {
    6034  assert(anchor.m_object != nullptr);
    6035 
    6036  switch (anchor.m_object->type())
    6037  {
    6038  // use integer array index as key
    6039  case value_t::array:
    6040  {
    6041  return std::to_string(array_index);
    6042  }
    6043 
    6044  // use key from the object
    6045  case value_t::object:
    6046  {
    6047  return anchor.key();
    6048  }
    6049 
    6050  // use an empty key for all primitive types
    6051  default:
    6052  {
    6053  return "";
    6054  }
    6055  }
    6056  }
    6057 
    6059  typename IteratorType::reference value() const
    6060  {
    6061  return anchor.value();
    6062  }
    6063  };
    6064 
    6066  typename IteratorType::reference container;
    6067 
    6068  public:
    6070  iteration_proxy(typename IteratorType::reference cont)
    6071  : container(cont)
    6072  {}
    6073 
    6075  iteration_proxy_internal begin()
    6076  {
    6077  return iteration_proxy_internal(container.begin());
    6078  }
    6079 
    6081  iteration_proxy_internal end()
    6082  {
    6083  return iteration_proxy_internal(container.end());
    6084  }
    6085  };
    6086 
    6087  public:
    6101  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    6102  {
    6104  friend class basic_json;
    6105 
    6106  public:
    6116  using iterator_category = std::bidirectional_iterator_tag;
    6117 
    6119  const_iterator() = default;
    6120 
    6122  const_iterator(pointer object) : m_object(object)
    6123  {
    6124  assert(m_object != nullptr);
    6125 
    6126  switch (m_object->m_type)
    6127  {
    6129  {
    6130  m_it.object_iterator = typename object_t::iterator();
    6131  break;
    6132  }
    6133 
    6135  {
    6136  m_it.array_iterator = typename array_t::iterator();
    6137  break;
    6138  }
    6139 
    6140  default:
    6141  {
    6142  m_it.primitive_iterator = primitive_iterator_t();
    6143  break;
    6144  }
    6145  }
    6146  }
    6147 
    6149  const_iterator(const iterator& other) : m_object(other.m_object)
    6150  {
    6151  assert(m_object != nullptr);
    6152 
    6153  switch (m_object->m_type)
    6154  {
    6156  {
    6157  m_it.object_iterator = other.m_it.object_iterator;
    6158  break;
    6159  }
    6160 
    6162  {
    6163  m_it.array_iterator = other.m_it.array_iterator;
    6164  break;
    6165  }
    6166 
    6167  default:
    6168  {
    6169  m_it.primitive_iterator = other.m_it.primitive_iterator;
    6170  break;
    6171  }
    6172  }
    6173  }
    6174 
    6176  const_iterator(const const_iterator& other) noexcept
    6177  : m_object(other.m_object), m_it(other.m_it)
    6178  {}
    6179 
    6182  std::is_nothrow_move_constructible<pointer>::value and
    6183  std::is_nothrow_move_assignable<pointer>::value and
    6184  std::is_nothrow_move_constructible<internal_iterator>::value and
    6185  std::is_nothrow_move_assignable<internal_iterator>::value
    6186  )
    6187  {
    6188  std::swap(m_object, other.m_object);
    6189  std::swap(m_it, other.m_it);
    6190  return *this;
    6191  }
    6192 
    6193  private:
    6195  void set_begin()
    6196  {
    6197  assert(m_object != nullptr);
    6198 
    6199  switch (m_object->m_type)
    6200  {
    6202  {
    6203  assert(m_object->m_value.object != nullptr);
    6204  m_it.object_iterator = m_object->m_value.object->begin();
    6205  break;
    6206  }
    6207 
    6209  {
    6210  assert(m_object->m_value.array != nullptr);
    6211  m_it.array_iterator = m_object->m_value.array->begin();
    6212  break;
    6213  }
    6214 
    6216  {
    6217  // set to end so begin()==end() is true: null is empty
    6218  m_it.primitive_iterator.set_end();
    6219  break;
    6220  }
    6221 
    6222  default:
    6223  {
    6224  m_it.primitive_iterator.set_begin();
    6225  break;
    6226  }
    6227  }
    6228  }
    6229 
    6231  void set_end()
    6232  {
    6233  assert(m_object != nullptr);
    6234 
    6235  switch (m_object->m_type)
    6236  {
    6238  {
    6239  assert(m_object->m_value.object != nullptr);
    6240  m_it.object_iterator = m_object->m_value.object->end();
    6241  break;
    6242  }
    6243 
    6245  {
    6246  assert(m_object->m_value.array != nullptr);
    6247  m_it.array_iterator = m_object->m_value.array->end();
    6248  break;
    6249  }
    6250 
    6251  default:
    6252  {
    6253  m_it.primitive_iterator.set_end();
    6254  break;
    6255  }
    6256  }
    6257  }
    6258 
    6259  public:
    6262  {
    6263  assert(m_object != nullptr);
    6264 
    6265  switch (m_object->m_type)
    6266  {
    6268  {
    6269  assert(m_object->m_value.object);
    6270  assert(m_it.object_iterator != m_object->m_value.object->end());
    6271  return m_it.object_iterator->second;
    6272  }
    6273 
    6275  {
    6276  assert(m_object->m_value.array);
    6277  assert(m_it.array_iterator != m_object->m_value.array->end());
    6278  return *m_it.array_iterator;
    6279  }
    6280 
    6282  {
    6283  throw std::out_of_range("cannot get value");
    6284  }
    6285 
    6286  default:
    6287  {
    6288  if (m_it.primitive_iterator.is_begin())
    6289  {
    6290  return *m_object;
    6291  }
    6292  else
    6293  {
    6294  throw std::out_of_range("cannot get value");
    6295  }
    6296  }
    6297  }
    6298  }
    6299 
    6302  {
    6303  assert(m_object != nullptr);
    6304 
    6305  switch (m_object->m_type)
    6306  {
    6308  {
    6309  assert(m_object->m_value.object);
    6310  assert(m_it.object_iterator != m_object->m_value.object->end());
    6311  return &(m_it.object_iterator->second);
    6312  }
    6313 
    6315  {
    6316  assert(m_object->m_value.array);
    6317  assert(m_it.array_iterator != m_object->m_value.array->end());
    6318  return &*m_it.array_iterator;
    6319  }
    6320 
    6321  default:
    6322  {
    6323  if (m_it.primitive_iterator.is_begin())
    6324  {
    6325  return m_object;
    6326  }
    6327  else
    6328  {
    6329  throw std::out_of_range("cannot get value");
    6330  }
    6331  }
    6332  }
    6333  }
    6334 
    6337  {
    6338  auto result = *this;
    6339  ++(*this);
    6340  return result;
    6341  }
    6342 
    6345  {
    6346  assert(m_object != nullptr);
    6347 
    6348  switch (m_object->m_type)
    6349  {
    6351  {
    6352  ++m_it.object_iterator;
    6353  break;
    6354  }
    6355 
    6357  {
    6358  ++m_it.array_iterator;
    6359  break;
    6360  }
    6361 
    6362  default:
    6363  {
    6364  ++m_it.primitive_iterator;
    6365  break;
    6366  }
    6367  }
    6368 
    6369  return *this;
    6370  }
    6371 
    6374  {
    6375  auto result = *this;
    6376  --(*this);
    6377  return result;
    6378  }
    6379 
    6382  {
    6383  assert(m_object != nullptr);
    6384 
    6385  switch (m_object->m_type)
    6386  {
    6388  {
    6389  --m_it.object_iterator;
    6390  break;
    6391  }
    6392 
    6394  {
    6395  --m_it.array_iterator;
    6396  break;
    6397  }
    6398 
    6399  default:
    6400  {
    6401  --m_it.primitive_iterator;
    6402  break;
    6403  }
    6404  }
    6405 
    6406  return *this;
    6407  }
    6408 
    6410  bool operator==(const const_iterator& other) const
    6411  {
    6412  // if objects are not the same, the comparison is undefined
    6413  if (m_object != other.m_object)
    6414  {
    6415  throw std::domain_error("cannot compare iterators of different containers");
    6416  }
    6417 
    6418  assert(m_object != nullptr);
    6419 
    6420  switch (m_object->m_type)
    6421  {
    6423  {
    6424  return (m_it.object_iterator == other.m_it.object_iterator);
    6425  }
    6426 
    6428  {
    6429  return (m_it.array_iterator == other.m_it.array_iterator);
    6430  }
    6431 
    6432  default:
    6433  {
    6434  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6435  }
    6436  }
    6437  }
    6438 
    6440  bool operator!=(const const_iterator& other) const
    6441  {
    6442  return not operator==(other);
    6443  }
    6444 
    6446  bool operator<(const const_iterator& other) const
    6447  {
    6448  // if objects are not the same, the comparison is undefined
    6449  if (m_object != other.m_object)
    6450  {
    6451  throw std::domain_error("cannot compare iterators of different containers");
    6452  }
    6453 
    6454  assert(m_object != nullptr);
    6455 
    6456  switch (m_object->m_type)
    6457  {
    6459  {
    6460  throw std::domain_error("cannot compare order of object iterators");
    6461  }
    6462 
    6464  {
    6465  return (m_it.array_iterator < other.m_it.array_iterator);
    6466  }
    6467 
    6468  default:
    6469  {
    6470  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6471  }
    6472  }
    6473  }
    6474 
    6476  bool operator<=(const const_iterator& other) const
    6477  {
    6478  return not other.operator < (*this);
    6479  }
    6480 
    6482  bool operator>(const const_iterator& other) const
    6483  {
    6484  return not operator<=(other);
    6485  }
    6486 
    6488  bool operator>=(const const_iterator& other) const
    6489  {
    6490  return not operator<(other);
    6491  }
    6492 
    6495  {
    6496  assert(m_object != nullptr);
    6497 
    6498  switch (m_object->m_type)
    6499  {
    6501  {
    6502  throw std::domain_error("cannot use offsets with object iterators");
    6503  }
    6504 
    6506  {
    6507  m_it.array_iterator += i;
    6508  break;
    6509  }
    6510 
    6511  default:
    6512  {
    6513  m_it.primitive_iterator += i;
    6514  break;
    6515  }
    6516  }
    6517 
    6518  return *this;
    6519  }
    6520 
    6523  {
    6524  return operator+=(-i);
    6525  }
    6526 
    6529  {
    6530  auto result = *this;
    6531  result += i;
    6532  return result;
    6533  }
    6534 
    6537  {
    6538  auto result = *this;
    6539  result -= i;
    6540  return result;
    6541  }
    6542 
    6545  {
    6546  assert(m_object != nullptr);
    6547 
    6548  switch (m_object->m_type)
    6549  {
    6551  {
    6552  throw std::domain_error("cannot use offsets with object iterators");
    6553  }
    6554 
    6556  {
    6557  return m_it.array_iterator - other.m_it.array_iterator;
    6558  }
    6559 
    6560  default:
    6561  {
    6562  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6563  }
    6564  }
    6565  }
    6566 
    6569  {
    6570  assert(m_object != nullptr);
    6571 
    6572  switch (m_object->m_type)
    6573  {
    6575  {
    6576  throw std::domain_error("cannot use operator[] for object iterators");
    6577  }
    6578 
    6580  {
    6581  return *(m_it.array_iterator + n);
    6582  }
    6583 
    6585  {
    6586  throw std::out_of_range("cannot get value");
    6587  }
    6588 
    6589  default:
    6590  {
    6591  if (m_it.primitive_iterator == -n)
    6592  {
    6593  return *m_object;
    6594  }
    6595  else
    6596  {
    6597  throw std::out_of_range("cannot get value");
    6598  }
    6599  }
    6600  }
    6601  }
    6602 
    6604  typename object_t::key_type key() const
    6605  {
    6606  assert(m_object != nullptr);
    6607 
    6608  if (m_object->is_object())
    6609  {
    6610  return m_it.object_iterator->first;
    6611  }
    6612  else
    6613  {
    6614  throw std::domain_error("cannot use key() for non-object iterators");
    6615  }
    6616  }
    6617 
    6620  {
    6621  return operator*();
    6622  }
    6623 
    6624  private:
    6626  pointer m_object = nullptr;
    6628  internal_iterator m_it = internal_iterator();
    6629  };
    6630 
    6643  class iterator : public const_iterator
    6644  {
    6645  public:
    6647  using pointer = typename basic_json::pointer;
    6649 
    6651  iterator() = default;
    6652 
    6654  iterator(pointer object) noexcept
    6655  : base_iterator(object)
    6656  {}
    6657 
    6659  iterator(const iterator& other) noexcept
    6660  : base_iterator(other)
    6661  {}
    6662 
    6664  iterator& operator=(iterator other) noexcept(
    6665  std::is_nothrow_move_constructible<pointer>::value and
    6666  std::is_nothrow_move_assignable<pointer>::value and
    6667  std::is_nothrow_move_constructible<internal_iterator>::value and
    6668  std::is_nothrow_move_assignable<internal_iterator>::value
    6669  )
    6670  {
    6671  base_iterator::operator=(other);
    6672  return *this;
    6673  }
    6674 
    6677  {
    6678  return const_cast<reference>(base_iterator::operator*());
    6679  }
    6680 
    6683  {
    6684  return const_cast<pointer>(base_iterator::operator->());
    6685  }
    6686 
    6689  {
    6690  iterator result = *this;
    6691  base_iterator::operator++();
    6692  return result;
    6693  }
    6694 
    6697  {
    6698  base_iterator::operator++();
    6699  return *this;
    6700  }
    6701 
    6704  {
    6705  iterator result = *this;
    6706  base_iterator::operator--();
    6707  return result;
    6708  }
    6709 
    6712  {
    6713  base_iterator::operator--();
    6714  return *this;
    6715  }
    6716 
    6719  {
    6720  base_iterator::operator+=(i);
    6721  return *this;
    6722  }
    6723 
    6726  {
    6727  base_iterator::operator-=(i);
    6728  return *this;
    6729  }
    6730 
    6733  {
    6734  auto result = *this;
    6735  result += i;
    6736  return result;
    6737  }
    6738 
    6741  {
    6742  auto result = *this;
    6743  result -= i;
    6744  return result;
    6745  }
    6746 
    6747  difference_type operator-(const iterator& other) const
    6748  {
    6749  return base_iterator::operator-(other);
    6750  }
    6751 
    6754  {
    6755  return const_cast<reference>(base_iterator::operator[](n));
    6756  }
    6757 
    6760  {
    6761  return const_cast<reference>(base_iterator::value());
    6762  }
    6763  };
    6764 
    6782  template<typename Base>
    6783  class json_reverse_iterator : public std::reverse_iterator<Base>
    6784  {
    6785  public:
    6787  using base_iterator = std::reverse_iterator<Base>;
    6789  using reference = typename Base::reference;
    6790 
    6792  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6793  : base_iterator(it)
    6794  {}
    6795 
    6798  : base_iterator(it)
    6799  {}
    6800 
    6803  {
    6804  return base_iterator::operator++(1);
    6805  }
    6806 
    6809  {
    6810  base_iterator::operator++();
    6811  return *this;
    6812  }
    6813 
    6816  {
    6817  return base_iterator::operator--(1);
    6818  }
    6819 
    6822  {
    6823  base_iterator::operator--();
    6824  return *this;
    6825  }
    6826 
    6829  {
    6830  base_iterator::operator+=(i);
    6831  return *this;
    6832  }
    6833 
    6836  {
    6837  auto result = *this;
    6838  result += i;
    6839  return result;
    6840  }
    6841 
    6844  {
    6845  auto result = *this;
    6846  result -= i;
    6847  return result;
    6848  }
    6849 
    6852  {
    6853  return this->base() - other.base();
    6854  }
    6855 
    6858  {
    6859  return *(this->operator+(n));
    6860  }
    6861 
    6863  typename object_t::key_type key() const
    6864  {
    6865  auto it = --this->base();
    6866  return it.key();
    6867  }
    6868 
    6871  {
    6872  auto it = --this->base();
    6873  return it.operator * ();
    6874  }
    6875  };
    6876 
    6877 
    6878  private:
    6880  // lexer and parser //
    6882 
    6890  class lexer
    6891  {
    6892  public:
    6894  enum class token_type
    6895  {
    6896  uninitialized,
    6897  literal_true,
    6898  literal_false,
    6899  literal_null,
    6900  value_string,
    6901  value_number,
    6902  begin_array,
    6903  begin_object,
    6904  end_array,
    6905  end_object,
    6906  name_separator,
    6907  value_separator,
    6908  parse_error,
    6909  end_of_input
    6910  };
    6911 
    6913  using lexer_char_t = unsigned char;
    6914 
    6916  explicit lexer(const string_t& s) noexcept
    6917  : m_stream(nullptr), m_buffer(s)
    6918  {
    6919  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    6920  assert(m_content != nullptr);
    6921  m_start = m_cursor = m_content;
    6922  m_limit = m_content + s.size();
    6923  }
    6924 
    6926  explicit lexer(std::istream* s) noexcept
    6927  : m_stream(s), m_buffer()
    6928  {
    6929  assert(m_stream != nullptr);
    6930  getline(*m_stream, m_buffer);
    6931  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    6932  assert(m_content != nullptr);
    6933  m_start = m_cursor = m_content;
    6934  m_limit = m_content + m_buffer.size();
    6935  }
    6936 
    6938  lexer() = default;
    6939 
    6940  // switch off unwanted functions
    6941  lexer(const lexer&) = delete;
    6942  lexer operator=(const lexer&) = delete;
    6943 
    6959  static string_t to_unicode(const std::size_t codepoint1,
    6960  const std::size_t codepoint2 = 0)
    6961  {
    6962  string_t result;
    6963 
    6964  // calculate the codepoint from the given code points
    6965  std::size_t codepoint = codepoint1;
    6966 
    6967  // check if codepoint1 is a high surrogate
    6968  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    6969  {
    6970  // check if codepoint2 is a low surrogate
    6971  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    6972  {
    6973  codepoint =
    6974  // high surrogate occupies the most significant 22 bits
    6975  (codepoint1 << 10)
    6976  // low surrogate occupies the least significant 15 bits
    6977  + codepoint2
    6978  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    6979  // in the result so we have to subtract with:
    6980  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    6981  - 0x35FDC00;
    6982  }
    6983  else
    6984  {
    6985  throw std::invalid_argument("missing or wrong low surrogate");
    6986  }
    6987  }
    6988 
    6989  if (codepoint < 0x80)
    6990  {
    6991  // 1-byte characters: 0xxxxxxx (ASCII)
    6992  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    6993  }
    6994  else if (codepoint <= 0x7ff)
    6995  {
    6996  // 2-byte characters: 110xxxxx 10xxxxxx
    6997  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    6998  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6999  }
    7000  else if (codepoint <= 0xffff)
    7001  {
    7002  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    7003  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    7004  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7005  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7006  }
    7007  else if (codepoint <= 0x10ffff)
    7008  {
    7009  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    7010  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    7011  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    7012  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7013  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7014  }
    7015  else
    7016  {
    7017  throw std::out_of_range("code points above 0x10FFFF are invalid");
    7018  }
    7019 
    7020  return result;
    7021  }
    7022 
    7024  static std::string token_type_name(token_type t)
    7025  {
    7026  switch (t)
    7027  {
    7028  case token_type::uninitialized:
    7029  return "<uninitialized>";
    7030  case token_type::literal_true:
    7031  return "true literal";
    7032  case token_type::literal_false:
    7033  return "false literal";
    7034  case token_type::literal_null:
    7035  return "null literal";
    7036  case token_type::value_string:
    7037  return "string literal";
    7038  case token_type::value_number:
    7039  return "number literal";
    7040  case token_type::begin_array:
    7041  return "'['";
    7042  case token_type::begin_object:
    7043  return "'{'";
    7044  case token_type::end_array:
    7045  return "']'";
    7046  case token_type::end_object:
    7047  return "'}'";
    7048  case token_type::name_separator:
    7049  return "':'";
    7050  case token_type::value_separator:
    7051  return "','";
    7052  case token_type::parse_error:
    7053  return "<parse error>";
    7054  case token_type::end_of_input:
    7055  return "end of input";
    7056  default:
    7057  {
    7058  // catch non-enum values
    7059  return "unknown token"; // LCOV_EXCL_LINE
    7060  }
    7061  }
    7062  }
    7063 
    7074  token_type scan() noexcept
    7075  {
    7076  // pointer for backtracking information
    7077  m_marker = nullptr;
    7078 
    7079  // remember the begin of the token
    7080  m_start = m_cursor;
    7081  assert(m_start != nullptr);
    7082 
    7083 
    7084  {
    7085  lexer_char_t yych;
    7086  unsigned int yyaccept = 0;
    7087  static const unsigned char yybm[] =
    7088  {
    7089  0, 0, 0, 0, 0, 0, 0, 0,
    7090  0, 32, 32, 0, 0, 32, 0, 0,
    7091  128, 128, 128, 128, 128, 128, 128, 128,
    7092  128, 128, 128, 128, 128, 128, 128, 128,
    7093  160, 128, 0, 128, 128, 128, 128, 128,
    7094  128, 128, 128, 128, 128, 128, 128, 128,
    7095  192, 192, 192, 192, 192, 192, 192, 192,
    7096  192, 192, 128, 128, 128, 128, 128, 128,
    7097  128, 128, 128, 128, 128, 128, 128, 128,
    7098  128, 128, 128, 128, 128, 128, 128, 128,
    7099  128, 128, 128, 128, 128, 128, 128, 128,
    7100  128, 128, 128, 128, 0, 128, 128, 128,
    7101  128, 128, 128, 128, 128, 128, 128, 128,
    7102  128, 128, 128, 128, 128, 128, 128, 128,
    7103  128, 128, 128, 128, 128, 128, 128, 128,
    7104  128, 128, 128, 128, 128, 128, 128, 128,
    7105  128, 128, 128, 128, 128, 128, 128, 128,
    7106  128, 128, 128, 128, 128, 128, 128, 128,
    7107  128, 128, 128, 128, 128, 128, 128, 128,
    7108  128, 128, 128, 128, 128, 128, 128, 128,
    7109  128, 128, 128, 128, 128, 128, 128, 128,
    7110  128, 128, 128, 128, 128, 128, 128, 128,
    7111  128, 128, 128, 128, 128, 128, 128, 128,
    7112  128, 128, 128, 128, 128, 128, 128, 128,
    7113  128, 128, 128, 128, 128, 128, 128, 128,
    7114  128, 128, 128, 128, 128, 128, 128, 128,
    7115  128, 128, 128, 128, 128, 128, 128, 128,
    7116  128, 128, 128, 128, 128, 128, 128, 128,
    7117  128, 128, 128, 128, 128, 128, 128, 128,
    7118  128, 128, 128, 128, 128, 128, 128, 128,
    7119  128, 128, 128, 128, 128, 128, 128, 128,
    7120  128, 128, 128, 128, 128, 128, 128, 128,
    7121  };
    7122  if ((m_limit - m_cursor) < 5)
    7123  {
    7124  yyfill(); // LCOV_EXCL_LINE;
    7125  }
    7126  yych = *m_cursor;
    7127  if (yybm[0 + yych] & 32)
    7128  {
    7129  goto basic_json_parser_6;
    7130  }
    7131  if (yych <= '\\')
    7132  {
    7133  if (yych <= '-')
    7134  {
    7135  if (yych <= '"')
    7136  {
    7137  if (yych <= 0x00)
    7138  {
    7139  goto basic_json_parser_2;
    7140  }
    7141  if (yych <= '!')
    7142  {
    7143  goto basic_json_parser_4;
    7144  }
    7145  goto basic_json_parser_9;
    7146  }
    7147  else
    7148  {
    7149  if (yych <= '+')
    7150  {
    7151  goto basic_json_parser_4;
    7152  }
    7153  if (yych <= ',')
    7154  {
    7155  goto basic_json_parser_10;
    7156  }
    7157  goto basic_json_parser_12;
    7158  }
    7159  }
    7160  else
    7161  {
    7162  if (yych <= '9')
    7163  {
    7164  if (yych <= '/')
    7165  {
    7166  goto basic_json_parser_4;
    7167  }
    7168  if (yych <= '0')
    7169  {
    7170  goto basic_json_parser_13;
    7171  }
    7172  goto basic_json_parser_15;
    7173  }
    7174  else
    7175  {
    7176  if (yych <= ':')
    7177  {
    7178  goto basic_json_parser_17;
    7179  }
    7180  if (yych == '[')
    7181  {
    7182  goto basic_json_parser_19;
    7183  }
    7184  goto basic_json_parser_4;
    7185  }
    7186  }
    7187  }
    7188  else
    7189  {
    7190  if (yych <= 't')
    7191  {
    7192  if (yych <= 'f')
    7193  {
    7194  if (yych <= ']')
    7195  {
    7196  goto basic_json_parser_21;
    7197  }
    7198  if (yych <= 'e')
    7199  {
    7200  goto basic_json_parser_4;
    7201  }
    7202  goto basic_json_parser_23;
    7203  }
    7204  else
    7205  {
    7206  if (yych == 'n')
    7207  {
    7208  goto basic_json_parser_24;
    7209  }
    7210  if (yych <= 's')
    7211  {
    7212  goto basic_json_parser_4;
    7213  }
    7214  goto basic_json_parser_25;
    7215  }
    7216  }
    7217  else
    7218  {
    7219  if (yych <= '|')
    7220  {
    7221  if (yych == '{')
    7222  {
    7223  goto basic_json_parser_26;
    7224  }
    7225  goto basic_json_parser_4;
    7226  }
    7227  else
    7228  {
    7229  if (yych <= '}')
    7230  {
    7231  goto basic_json_parser_28;
    7232  }
    7233  if (yych == 0xEF)
    7234  {
    7235  goto basic_json_parser_30;
    7236  }
    7237  goto basic_json_parser_4;
    7238  }
    7239  }
    7240  }
    7241 basic_json_parser_2:
    7242  ++m_cursor;
    7243  {
    7244  return token_type::end_of_input;
    7245  }
    7246 basic_json_parser_4:
    7247  ++m_cursor;
    7248 basic_json_parser_5:
    7249  {
    7250  return token_type::parse_error;
    7251  }
    7252 basic_json_parser_6:
    7253  ++m_cursor;
    7254  if (m_limit <= m_cursor)
    7255  {
    7256  yyfill(); // LCOV_EXCL_LINE;
    7257  }
    7258  yych = *m_cursor;
    7259  if (yybm[0 + yych] & 32)
    7260  {
    7261  goto basic_json_parser_6;
    7262  }
    7263  {
    7264  return scan();
    7265  }
    7266 basic_json_parser_9:
    7267  yyaccept = 0;
    7268  yych = *(m_marker = ++m_cursor);
    7269  if (yych <= 0x0F)
    7270  {
    7271  goto basic_json_parser_5;
    7272  }
    7273  goto basic_json_parser_32;
    7274 basic_json_parser_10:
    7275  ++m_cursor;
    7276  {
    7277  return token_type::value_separator;
    7278  }
    7279 basic_json_parser_12:
    7280  yych = *++m_cursor;
    7281  if (yych <= '/')
    7282  {
    7283  goto basic_json_parser_5;
    7284  }
    7285  if (yych <= '0')
    7286  {
    7287  goto basic_json_parser_13;
    7288  }
    7289  if (yych <= '9')
    7290  {
    7291  goto basic_json_parser_15;
    7292  }
    7293  goto basic_json_parser_5;
    7294 basic_json_parser_13:
    7295  yyaccept = 1;
    7296  yych = *(m_marker = ++m_cursor);
    7297  if (yych <= 'D')
    7298  {
    7299  if (yych == '.')
    7300  {
    7301  goto basic_json_parser_37;
    7302  }
    7303  }
    7304  else
    7305  {
    7306  if (yych <= 'E')
    7307  {
    7308  goto basic_json_parser_38;
    7309  }
    7310  if (yych == 'e')
    7311  {
    7312  goto basic_json_parser_38;
    7313  }
    7314  }
    7315 basic_json_parser_14:
    7316  {
    7317  return token_type::value_number;
    7318  }
    7319 basic_json_parser_15:
    7320  yyaccept = 1;
    7321  m_marker = ++m_cursor;
    7322  if ((m_limit - m_cursor) < 3)
    7323  {
    7324  yyfill(); // LCOV_EXCL_LINE;
    7325  }
    7326  yych = *m_cursor;
    7327  if (yybm[0 + yych] & 64)
    7328  {
    7329  goto basic_json_parser_15;
    7330  }
    7331  if (yych <= 'D')
    7332  {
    7333  if (yych == '.')
    7334  {
    7335  goto basic_json_parser_37;
    7336  }
    7337  goto basic_json_parser_14;
    7338  }
    7339  else
    7340  {
    7341  if (yych <= 'E')
    7342  {
    7343  goto basic_json_parser_38;
    7344  }
    7345  if (yych == 'e')
    7346  {
    7347  goto basic_json_parser_38;
    7348  }
    7349  goto basic_json_parser_14;
    7350  }
    7351 basic_json_parser_17:
    7352  ++m_cursor;
    7353  {
    7354  return token_type::name_separator;
    7355  }
    7356 basic_json_parser_19:
    7357  ++m_cursor;
    7358  {
    7359  return token_type::begin_array;
    7360  }
    7361 basic_json_parser_21:
    7362  ++m_cursor;
    7363  {
    7364  return token_type::end_array;
    7365  }
    7366 basic_json_parser_23:
    7367  yyaccept = 0;
    7368  yych = *(m_marker = ++m_cursor);
    7369  if (yych == 'a')
    7370  {
    7371  goto basic_json_parser_39;
    7372  }
    7373  goto basic_json_parser_5;
    7374 basic_json_parser_24:
    7375  yyaccept = 0;
    7376  yych = *(m_marker = ++m_cursor);
    7377  if (yych == 'u')
    7378  {
    7379  goto basic_json_parser_40;
    7380  }
    7381  goto basic_json_parser_5;
    7382 basic_json_parser_25:
    7383  yyaccept = 0;
    7384  yych = *(m_marker = ++m_cursor);
    7385  if (yych == 'r')
    7386  {
    7387  goto basic_json_parser_41;
    7388  }
    7389  goto basic_json_parser_5;
    7390 basic_json_parser_26:
    7391  ++m_cursor;
    7392  {
    7393  return token_type::begin_object;
    7394  }
    7395 basic_json_parser_28:
    7396  ++m_cursor;
    7397  {
    7398  return token_type::end_object;
    7399  }
    7400 basic_json_parser_30:
    7401  yyaccept = 0;
    7402  yych = *(m_marker = ++m_cursor);
    7403  if (yych == 0xBB)
    7404  {
    7405  goto basic_json_parser_42;
    7406  }
    7407  goto basic_json_parser_5;
    7408 basic_json_parser_31:
    7409  ++m_cursor;
    7410  if (m_limit <= m_cursor)
    7411  {
    7412  yyfill(); // LCOV_EXCL_LINE;
    7413  }
    7414  yych = *m_cursor;
    7415 basic_json_parser_32:
    7416  if (yybm[0 + yych] & 128)
    7417  {
    7418  goto basic_json_parser_31;
    7419  }
    7420  if (yych <= 0x0F)
    7421  {
    7422  goto basic_json_parser_33;
    7423  }
    7424  if (yych <= '"')
    7425  {
    7426  goto basic_json_parser_34;
    7427  }
    7428  goto basic_json_parser_36;
    7429 basic_json_parser_33:
    7430  m_cursor = m_marker;
    7431  if (yyaccept == 0)
    7432  {
    7433  goto basic_json_parser_5;
    7434  }
    7435  else
    7436  {
    7437  goto basic_json_parser_14;
    7438  }
    7439 basic_json_parser_34:
    7440  ++m_cursor;
    7441  {
    7442  return token_type::value_string;
    7443  }
    7444 basic_json_parser_36:
    7445  ++m_cursor;
    7446  if (m_limit <= m_cursor)
    7447  {
    7448  yyfill(); // LCOV_EXCL_LINE;
    7449  }
    7450  yych = *m_cursor;
    7451  if (yych <= 'e')
    7452  {
    7453  if (yych <= '/')
    7454  {
    7455  if (yych == '"')
    7456  {
    7457  goto basic_json_parser_31;
    7458  }
    7459  if (yych <= '.')
    7460  {
    7461  goto basic_json_parser_33;
    7462  }
    7463  goto basic_json_parser_31;
    7464  }
    7465  else
    7466  {
    7467  if (yych <= '\\')
    7468  {
    7469  if (yych <= '[')
    7470  {
    7471  goto basic_json_parser_33;
    7472  }
    7473  goto basic_json_parser_31;
    7474  }
    7475  else
    7476  {
    7477  if (yych == 'b')
    7478  {
    7479  goto basic_json_parser_31;
    7480  }
    7481  goto basic_json_parser_33;
    7482  }
    7483  }
    7484  }
    7485  else
    7486  {
    7487  if (yych <= 'q')
    7488  {
    7489  if (yych <= 'f')
    7490  {
    7491  goto basic_json_parser_31;
    7492  }
    7493  if (yych == 'n')
    7494  {
    7495  goto basic_json_parser_31;
    7496  }
    7497  goto basic_json_parser_33;
    7498  }
    7499  else
    7500  {
    7501  if (yych <= 's')
    7502  {
    7503  if (yych <= 'r')
    7504  {
    7505  goto basic_json_parser_31;
    7506  }
    7507  goto basic_json_parser_33;
    7508  }
    7509  else
    7510  {
    7511  if (yych <= 't')
    7512  {
    7513  goto basic_json_parser_31;
    7514  }
    7515  if (yych <= 'u')
    7516  {
    7517  goto basic_json_parser_43;
    7518  }
    7519  goto basic_json_parser_33;
    7520  }
    7521  }
    7522  }
    7523 basic_json_parser_37:
    7524  yych = *++m_cursor;
    7525  if (yych <= '/')
    7526  {
    7527  goto basic_json_parser_33;
    7528  }
    7529  if (yych <= '9')
    7530  {
    7531  goto basic_json_parser_44;
    7532  }
    7533  goto basic_json_parser_33;
    7534 basic_json_parser_38:
    7535  yych = *++m_cursor;
    7536  if (yych <= ',')
    7537  {
    7538  if (yych == '+')
    7539  {
    7540  goto basic_json_parser_46;
    7541  }
    7542  goto basic_json_parser_33;
    7543  }
    7544  else
    7545  {
    7546  if (yych <= '-')
    7547  {
    7548  goto basic_json_parser_46;
    7549  }
    7550  if (yych <= '/')
    7551  {
    7552  goto basic_json_parser_33;
    7553  }
    7554  if (yych <= '9')
    7555  {
    7556  goto basic_json_parser_47;
    7557  }
    7558  goto basic_json_parser_33;
    7559  }
    7560 basic_json_parser_39:
    7561  yych = *++m_cursor;
    7562  if (yych == 'l')
    7563  {
    7564  goto basic_json_parser_49;
    7565  }
    7566  goto basic_json_parser_33;
    7567 basic_json_parser_40:
    7568  yych = *++m_cursor;
    7569  if (yych == 'l')
    7570  {
    7571  goto basic_json_parser_50;
    7572  }
    7573  goto basic_json_parser_33;
    7574 basic_json_parser_41:
    7575  yych = *++m_cursor;
    7576  if (yych == 'u')
    7577  {
    7578  goto basic_json_parser_51;
    7579  }
    7580  goto basic_json_parser_33;
    7581 basic_json_parser_42:
    7582  yych = *++m_cursor;
    7583  if (yych == 0xBF)
    7584  {
    7585  goto basic_json_parser_52;
    7586  }
    7587  goto basic_json_parser_33;
    7588 basic_json_parser_43:
    7589  ++m_cursor;
    7590  if (m_limit <= m_cursor)
    7591  {
    7592  yyfill(); // LCOV_EXCL_LINE;
    7593  }
    7594  yych = *m_cursor;
    7595  if (yych <= '@')
    7596  {
    7597  if (yych <= '/')
    7598  {
    7599  goto basic_json_parser_33;
    7600  }
    7601  if (yych <= '9')
    7602  {
    7603  goto basic_json_parser_54;
    7604  }
    7605  goto basic_json_parser_33;
    7606  }
    7607  else
    7608  {
    7609  if (yych <= 'F')
    7610  {
    7611  goto basic_json_parser_54;
    7612  }
    7613  if (yych <= '`')
    7614  {
    7615  goto basic_json_parser_33;
    7616  }
    7617  if (yych <= 'f')
    7618  {
    7619  goto basic_json_parser_54;
    7620  }
    7621  goto basic_json_parser_33;
    7622  }
    7623 basic_json_parser_44:
    7624  yyaccept = 1;
    7625  m_marker = ++m_cursor;
    7626  if ((m_limit - m_cursor) < 3)
    7627  {
    7628  yyfill(); // LCOV_EXCL_LINE;
    7629  }
    7630  yych = *m_cursor;
    7631  if (yych <= 'D')
    7632  {
    7633  if (yych <= '/')
    7634  {
    7635  goto basic_json_parser_14;
    7636  }
    7637  if (yych <= '9')
    7638  {
    7639  goto basic_json_parser_44;
    7640  }
    7641  goto basic_json_parser_14;
    7642  }
    7643  else
    7644  {
    7645  if (yych <= 'E')
    7646  {
    7647  goto basic_json_parser_38;
    7648  }
    7649  if (yych == 'e')
    7650  {
    7651  goto basic_json_parser_38;
    7652  }
    7653  goto basic_json_parser_14;
    7654  }
    7655 basic_json_parser_46:
    7656  yych = *++m_cursor;
    7657  if (yych <= '/')
    7658  {
    7659  goto basic_json_parser_33;
    7660  }
    7661  if (yych >= ':')
    7662  {
    7663  goto basic_json_parser_33;
    7664  }
    7665 basic_json_parser_47:
    7666  ++m_cursor;
    7667  if (m_limit <= m_cursor)
    7668  {
    7669  yyfill(); // LCOV_EXCL_LINE;
    7670  }
    7671  yych = *m_cursor;
    7672  if (yych <= '/')
    7673  {
    7674  goto basic_json_parser_14;
    7675  }
    7676  if (yych <= '9')
    7677  {
    7678  goto basic_json_parser_47;
    7679  }
    7680  goto basic_json_parser_14;
    7681 basic_json_parser_49:
    7682  yych = *++m_cursor;
    7683  if (yych == 's')
    7684  {
    7685  goto basic_json_parser_55;
    7686  }
    7687  goto basic_json_parser_33;
    7688 basic_json_parser_50:
    7689  yych = *++m_cursor;
    7690  if (yych == 'l')
    7691  {
    7692  goto basic_json_parser_56;
    7693  }
    7694  goto basic_json_parser_33;
    7695 basic_json_parser_51:
    7696  yych = *++m_cursor;
    7697  if (yych == 'e')
    7698  {
    7699  goto basic_json_parser_58;
    7700  }
    7701  goto basic_json_parser_33;
    7702 basic_json_parser_52:
    7703  ++m_cursor;
    7704  {
    7705  return scan();
    7706  }
    7707 basic_json_parser_54:
    7708  ++m_cursor;
    7709  if (m_limit <= m_cursor)
    7710  {
    7711  yyfill(); // LCOV_EXCL_LINE;
    7712  }
    7713  yych = *m_cursor;
    7714  if (yych <= '@')
    7715  {
    7716  if (yych <= '/')
    7717  {
    7718  goto basic_json_parser_33;
    7719  }
    7720  if (yych <= '9')
    7721  {
    7722  goto basic_json_parser_60;
    7723  }
    7724  goto basic_json_parser_33;
    7725  }
    7726  else
    7727  {
    7728  if (yych <= 'F')
    7729  {
    7730  goto basic_json_parser_60;
    7731  }
    7732  if (yych <= '`')
    7733  {
    7734  goto basic_json_parser_33;
    7735  }
    7736  if (yych <= 'f')
    7737  {
    7738  goto basic_json_parser_60;
    7739  }
    7740  goto basic_json_parser_33;
    7741  }
    7742 basic_json_parser_55:
    7743  yych = *++m_cursor;
    7744  if (yych == 'e')
    7745  {
    7746  goto basic_json_parser_61;
    7747  }
    7748  goto basic_json_parser_33;
    7749 basic_json_parser_56:
    7750  ++m_cursor;
    7751  {
    7752  return token_type::literal_null;
    7753  }
    7754 basic_json_parser_58:
    7755  ++m_cursor;
    7756  {
    7757  return token_type::literal_true;
    7758  }
    7759 basic_json_parser_60:
    7760  ++m_cursor;
    7761  if (m_limit <= m_cursor)
    7762  {
    7763  yyfill(); // LCOV_EXCL_LINE;
    7764  }
    7765  yych = *m_cursor;
    7766  if (yych <= '@')
    7767  {
    7768  if (yych <= '/')
    7769  {
    7770  goto basic_json_parser_33;
    7771  }
    7772  if (yych <= '9')
    7773  {
    7774  goto basic_json_parser_63;
    7775  }
    7776  goto basic_json_parser_33;
    7777  }
    7778  else
    7779  {
    7780  if (yych <= 'F')
    7781  {
    7782  goto basic_json_parser_63;
    7783  }
    7784  if (yych <= '`')
    7785  {
    7786  goto basic_json_parser_33;
    7787  }
    7788  if (yych <= 'f')
    7789  {
    7790  goto basic_json_parser_63;
    7791  }
    7792  goto basic_json_parser_33;
    7793  }
    7794 basic_json_parser_61:
    7795  ++m_cursor;
    7796  {
    7797  return token_type::literal_false;
    7798  }
    7799 basic_json_parser_63:
    7800  ++m_cursor;
    7801  if (m_limit <= m_cursor)
    7802  {
    7803  yyfill(); // LCOV_EXCL_LINE;
    7804  }
    7805  yych = *m_cursor;
    7806  if (yych <= '@')
    7807  {
    7808  if (yych <= '/')
    7809  {
    7810  goto basic_json_parser_33;
    7811  }
    7812  if (yych <= '9')
    7813  {
    7814  goto basic_json_parser_31;
    7815  }
    7816  goto basic_json_parser_33;
    7817  }
    7818  else
    7819  {
    7820  if (yych <= 'F')
    7821  {
    7822  goto basic_json_parser_31;
    7823  }
    7824  if (yych <= '`')
    7825  {
    7826  goto basic_json_parser_33;
    7827  }
    7828  if (yych <= 'f')
    7829  {
    7830  goto basic_json_parser_31;
    7831  }
    7832  goto basic_json_parser_33;
    7833  }
    7834  }
    7835 
    7836 
    7837  }
    7838 
    7840  void yyfill() noexcept
    7841  {
    7842  if (m_stream == nullptr or not * m_stream)
    7843  {
    7844  return;
    7845  }
    7846 
    7847  const ssize_t offset_start = m_start - m_content;
    7848  const ssize_t offset_marker = m_marker - m_start;
    7849  const ssize_t offset_cursor = m_cursor - m_start;
    7850 
    7851  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7852  std::string line;
    7853  assert(m_stream != nullptr);
    7854  std::getline(*m_stream, line);
    7855  m_buffer += "\n" + line; // add line with newline symbol
    7856 
    7857  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7858  assert(m_content != nullptr);
    7859  m_start = m_content;
    7860  m_marker = m_start + offset_marker;
    7861  m_cursor = m_start + offset_cursor;
    7862  m_limit = m_start + m_buffer.size() - 1;
    7863  }
    7864 
    7866  string_t get_token() const noexcept
    7867  {
    7868  assert(m_start != nullptr);
    7869  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7870  static_cast<size_t>(m_cursor - m_start));
    7871  }
    7872 
    7894  string_t get_string() const
    7895  {
    7896  string_t result;
    7897  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    7898 
    7899  // iterate the result between the quotes
    7900  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    7901  {
    7902  // process escaped characters
    7903  if (*i == '\\')
    7904  {
    7905  // read next character
    7906  ++i;
    7907 
    7908  switch (*i)
    7909  {
    7910  // the default escapes
    7911  case 't':
    7912  {
    7913  result += "\t";
    7914  break;
    7915  }
    7916  case 'b':
    7917  {
    7918  result += "\b";
    7919  break;
    7920  }
    7921  case 'f':
    7922  {
    7923  result += "\f";
    7924  break;
    7925  }
    7926  case 'n':
    7927  {
    7928  result += "\n";
    7929  break;
    7930  }
    7931  case 'r':
    7932  {
    7933  result += "\r";
    7934  break;
    7935  }
    7936  case '\\':
    7937  {
    7938  result += "\\";
    7939  break;
    7940  }
    7941  case '/':
    7942  {
    7943  result += "/";
    7944  break;
    7945  }
    7946  case '"':
    7947  {
    7948  result += "\"";
    7949  break;
    7950  }
    7951 
    7952  // unicode
    7953  case 'u':
    7954  {
    7955  // get code xxxx from uxxxx
    7956  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    7957  4).c_str(), nullptr, 16);
    7958 
    7959  // check if codepoint is a high surrogate
    7960  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    7961  {
    7962  // make sure there is a subsequent unicode
    7963  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    7964  {
    7965  throw std::invalid_argument("missing low surrogate");
    7966  }
    7967 
    7968  // get code yyyy from uxxxx\uyyyy
    7969  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    7970  (i + 7), 4).c_str(), nullptr, 16);
    7971  result += to_unicode(codepoint, codepoint2);
    7972  // skip the next 10 characters (xxxx\uyyyy)
    7973  i += 10;
    7974  }
    7975  else
    7976  {
    7977  // add unicode character(s)
    7978  result += to_unicode(codepoint);
    7979  // skip the next four characters (xxxx)
    7980  i += 4;
    7981  }
    7982  break;
    7983  }
    7984  }
    7985  }
    7986  else
    7987  {
    7988  // all other characters are just copied to the end of the
    7989  // string
    7990  result.append(1, static_cast<typename string_t::value_type>(*i));
    7991  }
    7992  }
    7993 
    7994  return result;
    7995  }
    7996 
    8017  long double str_to_float_t(long double* /* type */, char** endptr) const
    8018  {
    8019  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8020  }
    8021 
    8036  double str_to_float_t(double* /* type */, char** endptr) const
    8037  {
    8038  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8039  }
    8040 
    8055  float str_to_float_t(float* /* type */, char** endptr) const
    8056  {
    8057  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8058  }
    8059 
    8072  template <typename T_A, typename T_B>
    8073  bool attempt_cast(T_A source, T_B& dest) const
    8074  {
    8075  dest = static_cast<T_B>(source);
    8076  return (source == static_cast<T_A>(dest));
    8077  }
    8078 
    8117  void get_number(basic_json& result) const
    8118  {
    8119  typename string_t::value_type* endptr;
    8120  assert(m_start != nullptr);
    8121  errno = 0;
    8122 
    8123  // attempt to parse it as an integer - first checking for a
    8124  // negative number
    8125  if (*reinterpret_cast<typename string_t::const_pointer>(m_start) != '-')
    8126  {
    8127  // positive, parse with strtoull and attempt cast to
    8128  // number_unsigned_t
    8129  if (attempt_cast(std::strtoull(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8130  10), result.m_value.number_unsigned))
    8131  {
    8132  result.m_type = value_t::number_unsigned;
    8133  }
    8134  else
    8135  {
    8136  // cast failed due to overflow - store as float
    8137  result.m_type = value_t::number_float;
    8138  }
    8139  }
    8140  else
    8141  {
    8142  // Negative, parse with strtoll and attempt cast to
    8143  // number_integer_t
    8144  if (attempt_cast(std::strtoll(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8145  10), result.m_value.number_integer))
    8146  {
    8147  result.m_type = value_t::number_integer;
    8148  }
    8149  else
    8150  {
    8151  // cast failed due to overflow - store as float
    8152  result.m_type = value_t::number_float;
    8153  }
    8154  }
    8155 
    8156  // check the end of the number was reached and no range error
    8157  // occurred
    8158  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor || errno == ERANGE)
    8159  {
    8160  result.m_type = value_t::number_float;
    8161  }
    8162 
    8163  if (result.m_type == value_t::number_float)
    8164  {
    8165  // either the number won't fit in an integer (range error from
    8166  // strtoull/strtoll or overflow on cast) or there was something
    8167  // else after the number, which could be an exponent
    8168 
    8169  // parse with strtod
    8170  result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), &endptr);
    8171 
    8172  // anything after the number is an error
    8173  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor)
    8174  {
    8175  throw std::invalid_argument(std::string("parse error - ") + get_token() + " is not a number");
    8176  }
    8177  }
    8178  }
    8179 
    8180  private:
    8182  std::istream* m_stream = nullptr;
    8184  string_t m_buffer;
    8186  const lexer_char_t* m_content = nullptr;
    8188  const lexer_char_t* m_start = nullptr;
    8190  const lexer_char_t* m_marker = nullptr;
    8192  const lexer_char_t* m_cursor = nullptr;
    8194  const lexer_char_t* m_limit = nullptr;
    8195  };
    8196 
    8202  class parser
    8203  {
    8204  public:
    8206  parser(const string_t& s, parser_callback_t cb = nullptr)
    8207  : callback(cb), m_lexer(s)
    8208  {
    8209  // read first token
    8210  get_token();
    8211  }
    8212 
    8214  parser(std::istream& _is, parser_callback_t cb = nullptr)
    8215  : callback(cb), m_lexer(&_is)
    8216  {
    8217  // read first token
    8218  get_token();
    8219  }
    8220 
    8222  basic_json parse()
    8223  {
    8224  basic_json result = parse_internal(true);
    8225 
    8226  expect(lexer::token_type::end_of_input);
    8227 
    8228  // return parser result and replace it with null in case the
    8229  // top-level value was discarded by the callback function
    8230  return result.is_discarded() ? basic_json() : result;
    8231  }
    8232 
    8233  private:
    8235  basic_json parse_internal(bool keep)
    8236  {
    8237  auto result = basic_json(value_t::discarded);
    8238 
    8239  switch (last_token)
    8240  {
    8241  case lexer::token_type::begin_object:
    8242  {
    8243  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    8244  {
    8245  // explicitly set result to object to cope with {}
    8246  result.m_type = value_t::object;
    8247  result.m_value = json_value(value_t::object);
    8248  }
    8249 
    8250  // read next token
    8251  get_token();
    8252 
    8253  // closing } -> we are done
    8254  if (last_token == lexer::token_type::end_object)
    8255  {
    8256  get_token();
    8257  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8258  {
    8259  result = basic_json(value_t::discarded);
    8260  }
    8261  return result;
    8262  }
    8263 
    8264  // no comma is expected here
    8265  unexpect(lexer::token_type::value_separator);
    8266 
    8267  // otherwise: parse key-value pairs
    8268  do
    8269  {
    8270  // ugly, but could be fixed with loop reorganization
    8271  if (last_token == lexer::token_type::value_separator)
    8272  {
    8273  get_token();
    8274  }
    8275 
    8276  // store key
    8277  expect(lexer::token_type::value_string);
    8278  const auto key = m_lexer.get_string();
    8279 
    8280  bool keep_tag = false;
    8281  if (keep)
    8282  {
    8283  if (callback)
    8284  {
    8285  basic_json k(key);
    8286  keep_tag = callback(depth, parse_event_t::key, k);
    8287  }
    8288  else
    8289  {
    8290  keep_tag = true;
    8291  }
    8292  }
    8293 
    8294  // parse separator (:)
    8295  get_token();
    8296  expect(lexer::token_type::name_separator);
    8297 
    8298  // parse and add value
    8299  get_token();
    8300  auto value = parse_internal(keep);
    8301  if (keep and keep_tag and not value.is_discarded())
    8302  {
    8303  result[key] = std::move(value);
    8304  }
    8305  }
    8306  while (last_token == lexer::token_type::value_separator);
    8307 
    8308  // closing }
    8309  expect(lexer::token_type::end_object);
    8310  get_token();
    8311  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8312  {
    8313  result = basic_json(value_t::discarded);
    8314  }
    8315 
    8316  return result;
    8317  }
    8318 
    8319  case lexer::token_type::begin_array:
    8320  {
    8321  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    8322  {
    8323  // explicitly set result to object to cope with []
    8324  result.m_type = value_t::array;
    8325  result.m_value = json_value(value_t::array);
    8326  }
    8327 
    8328  // read next token
    8329  get_token();
    8330 
    8331  // closing ] -> we are done
    8332  if (last_token == lexer::token_type::end_array)
    8333  {
    8334  get_token();
    8335  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8336  {
    8337  result = basic_json(value_t::discarded);
    8338  }
    8339  return result;
    8340  }
    8341 
    8342  // no comma is expected here
    8343  unexpect(lexer::token_type::value_separator);
    8344 
    8345  // otherwise: parse values
    8346  do
    8347  {
    8348  // ugly, but could be fixed with loop reorganization
    8349  if (last_token == lexer::token_type::value_separator)
    8350  {
    8351  get_token();
    8352  }
    8353 
    8354  // parse value
    8355  auto value = parse_internal(keep);
    8356  if (keep and not value.is_discarded())
    8357  {
    8358  result.push_back(std::move(value));
    8359  }
    8360  }
    8361  while (last_token == lexer::token_type::value_separator);
    8362 
    8363  // closing ]
    8364  expect(lexer::token_type::end_array);
    8365  get_token();
    8366  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8367  {
    8368  result = basic_json(value_t::discarded);
    8369  }
    8370 
    8371  return result;
    8372  }
    8373 
    8374  case lexer::token_type::literal_null:
    8375  {
    8376  get_token();
    8377  result.m_type = value_t::null;
    8378  break;
    8379  }
    8380 
    8381  case lexer::token_type::value_string:
    8382  {
    8383  const auto s = m_lexer.get_string();
    8384  get_token();
    8385  result = basic_json(s);
    8386  break;
    8387  }
    8388 
    8389  case lexer::token_type::literal_true:
    8390  {
    8391  get_token();
    8392  result.m_type = value_t::boolean;
    8393  result.m_value = true;
    8394  break;
    8395  }
    8396 
    8397  case lexer::token_type::literal_false:
    8398  {
    8399  get_token();
    8400  result.m_type = value_t::boolean;
    8401  result.m_value = false;
    8402  break;
    8403  }
    8404 
    8405  case lexer::token_type::value_number:
    8406  {
    8407  m_lexer.get_number(result);
    8408  get_token();
    8409  break;
    8410  }
    8411 
    8412  default:
    8413  {
    8414  // the last token was unexpected
    8415  unexpect(last_token);
    8416  }
    8417  }
    8418 
    8419  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8420  {
    8421  result = basic_json(value_t::discarded);
    8422  }
    8423  return result;
    8424  }
    8425 
    8427  typename lexer::token_type get_token()
    8428  {
    8429  last_token = m_lexer.scan();
    8430  return last_token;
    8431  }
    8432 
    8433  void expect(typename lexer::token_type t) const
    8434  {
    8435  if (t != last_token)
    8436  {
    8437  std::string error_msg = "parse error - unexpected ";
    8438  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8439  lexer::token_type_name(last_token));
    8440  error_msg += "; expected " + lexer::token_type_name(t);
    8441  throw std::invalid_argument(error_msg);
    8442  }
    8443  }
    8444 
    8445  void unexpect(typename lexer::token_type t) const
    8446  {
    8447  if (t == last_token)
    8448  {
    8449  std::string error_msg = "parse error - unexpected ";
    8450  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8451  lexer::token_type_name(last_token));
    8452  throw std::invalid_argument(error_msg);
    8453  }
    8454  }
    8455 
    8456  private:
    8458  int depth = 0;
    8460  parser_callback_t callback;
    8462  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8464  lexer m_lexer;
    8465  };
    8466 };
    8467 
    8468 
    8470 // presets //
    8472 
    8482 }
    8483 
    8484 
    8486 // nonmember functions //
    8488 
    8489 // specialization of std::swap, and std::hash
    8490 namespace std
    8491 {
    8497 template <>
    8498 inline void swap(nlohmann::json& j1,
    8499  nlohmann::json& j2) noexcept(
    8500  is_nothrow_move_constructible<nlohmann::json>::value and
    8501  is_nothrow_move_assignable<nlohmann::json>::value
    8502  )
    8503 {
    8504  j1.swap(j2);
    8505 }
    8506 
    8508 template <>
    8509 struct hash<nlohmann::json>
    8510 {
    8516  std::size_t operator()(const nlohmann::json& j) const
    8517  {
    8518  // a naive hashing via the string representation
    8519  const auto& h = hash<nlohmann::json::string_t>();
    8520  return h(j.dump());
    8521  }
    8522 };
    8523 }
    8524 
    8537 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8538 {
    8539  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8540 }
    8541 
    8542 // restore GCC/clang diagnostic settings
    8543 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    8544  #pragma GCC diagnostic pop
    8545 #endif
    8546 
    8547 #endif
    bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:2122
    +
    reference operator*()
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6676
    +
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:4088
    +
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5315
    +
    basic_json(const value_t value_type)
    create an empty value with a given type
    Definition: json.hpp:945
    +
    basic_json(const array_t &val)
    create an array (explicit)
    Definition: json.hpp:1071
    +
    size_type count(typename object_t::key_type key) const
    returns the number of occurrences of a key in a JSON object
    Definition: json.hpp:3936
    +
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:2062
    +
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2194
    +
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:3156
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6759
    +
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6821
    +
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:2141
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4425
    +
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6410
    +
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6815
    +
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3288
    +
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5528
    +
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2168
    +
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6718
    +
    static basic_json object(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an object from an initializer list
    Definition: json.hpp:1650
    +
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6536
    +
    BooleanType boolean_t
    a type for a boolean
    Definition: json.hpp:447
    +
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4611
    +
    bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2282
    +
    basic_json(const typename string_t::value_type *val)
    create a string (explicit)
    Definition: json.hpp:1161
    +
    basic_json(boolean_t val)
    create a boolean (explicit)
    Definition: json.hpp:1210
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6857
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3888
    +
    basic_json(const number_unsigned_t val)
    create an unsigned integer number (explicit)
    Definition: json.hpp:1339
    +
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:5153
    +
    basic_json(const string_t &val)
    create a string (explicit)
    Definition: json.hpp:1137
    +
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4537
    +
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3852
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:8481
    +
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:374
    +
    bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:2103
    +
    reference front()
    access the first element
    Definition: json.hpp:3523
    +
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:4909
    +
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:6843
    +
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6494
    +
    a class to store JSON values
    Definition: json.hpp:168
    +
    basic_json(const number_float_t val)
    create a floating-point number (explicit)
    Definition: json.hpp:1399
    +
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6682
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6870
    +
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:5132
    +
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4150
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:518
    +
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4695
    +
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:3064
    +
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6528
    +
    const_reverse_iterator rbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4096
    +
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6643
    +
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5490
    +
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6336
    +
    bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2301
    +
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:328
    STL namespace.
    -
    NumberUnsignedType number_unsigned_t
    a type for a number (unsigned)
    Definition: json.hpp:616
    -
    typename std::allocator_traits< allocator_type >::const_pointer const_pointer
    the type of an element const pointer
    Definition: json.hpp:235
    -
    static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an array from an initializer list
    Definition: json.hpp:1636
    -
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4228
    -
    reference & operator=(basic_json other) noexcept( std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value )
    copy assignment
    Definition: json.hpp:1962
    -
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:6134
    -
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2804
    -
    reference back()
    access the last element
    Definition: json.hpp:3583
    -
    const value_type & const_reference
    the type of an element const reference
    Definition: json.hpp:222
    -
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:6138
    -
    bool is_number_unsigned() const noexcept
    return whether value is an unsigned integer number
    Definition: json.hpp:2245
    -
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4613
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:4056
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5479
    -
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3349
    -
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4774
    -
    basic_json(std::nullptr_t) noexcept
    create a null object (explicitly)
    Definition: json.hpp:1015
    -
    basic_json(InputIT first, InputIT last)
    construct a JSON container given an iterator range
    Definition: json.hpp:1746
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6779
    -
    static allocator_type get_allocator()
    returns the allocator associated with the container
    Definition: json.hpp:255
    -
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3271
    -
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3431
    -
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6861
    -
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4272
    -
    std::size_t size_type
    a type to represent container sizes
    Definition: json.hpp:227
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6889
    -
    basic_json(const CompatibleArrayType &val)
    create an array (implicit)
    Definition: json.hpp:1134
    -
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:2994
    -
    basic_json(size_type cnt, const basic_json &val)
    construct an array with count copies of given value
    Definition: json.hpp:1700
    -
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6813
    -
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4832
    -
    const_iterator(const iterator &other)
    copy constructor given a nonconst iterator
    Definition: json.hpp:6175
    -
    typename std::allocator_traits< allocator_type >::pointer pointer
    the type of an element pointer
    Definition: json.hpp:233
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4665
    -
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5385
    -
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:5240
    -
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6722
    -
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6472
    -
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6714
    -
    basic_json(basic_json &&other) noexcept
    move constructor
    Definition: json.hpp:1932
    -
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6399
    -
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2351
    -
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:3042
    -
    iterator & operator=(iterator other) noexcept( std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< internal_iterator >::value and std::is_nothrow_move_assignable< internal_iterator >::value )
    copy assignment
    Definition: json.hpp:6690
    +
    NumberUnsignedType number_unsigned_t
    a type for a number (unsigned)
    Definition: json.hpp:590
    +
    typename std::allocator_traits< allocator_type >::const_pointer const_pointer
    the type of an element const pointer
    Definition: json.hpp:209
    +
    static basic_json array(std::initializer_list< basic_json > init=std::initializer_list< basic_json >())
    explicitly create an array from an initializer list
    Definition: json.hpp:1610
    +
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4202
    +
    reference & operator=(basic_json other) noexcept( std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value )
    copy assignment
    Definition: json.hpp:1936
    +
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:6108
    +
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2778
    +
    reference back()
    access the last element
    Definition: json.hpp:3557
    +
    const value_type & const_reference
    the type of an element const reference
    Definition: json.hpp:196
    +
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:6112
    +
    bool is_number_unsigned() const noexcept
    return whether value is an unsigned integer number
    Definition: json.hpp:2219
    +
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4587
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:4030
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5453
    +
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3323
    +
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4748
    +
    basic_json(std::nullptr_t) noexcept
    create a null object (explicitly)
    Definition: json.hpp:989
    +
    basic_json(InputIT first, InputIT last)
    construct a JSON container given an iterator range
    Definition: json.hpp:1720
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6753
    +
    static allocator_type get_allocator()
    returns the allocator associated with the container
    Definition: json.hpp:229
    +
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3245
    +
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3405
    +
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6835
    +
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4246
    +
    std::size_t size_type
    a type to represent container sizes
    Definition: json.hpp:201
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6863
    +
    basic_json(const CompatibleArrayType &val)
    create an array (implicit)
    Definition: json.hpp:1108
    +
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:2968
    +
    basic_json(size_type cnt, const basic_json &val)
    construct an array with count copies of given value
    Definition: json.hpp:1674
    +
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6787
    +
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4806
    +
    const_iterator(const iterator &other)
    copy constructor given a nonconst iterator
    Definition: json.hpp:6149
    +
    typename std::allocator_traits< allocator_type >::pointer pointer
    the type of an element pointer
    Definition: json.hpp:207
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4639
    +
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5359
    +
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:5214
    +
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6696
    +
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6446
    +
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6688
    +
    basic_json(basic_json &&other) noexcept
    move constructor
    Definition: json.hpp:1906
    +
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6373
    +
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2325
    +
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:3016
    +
    iterator & operator=(iterator other) noexcept( std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< internal_iterator >::value and std::is_nothrow_move_assignable< internal_iterator >::value )
    copy assignment
    Definition: json.hpp:6664
    object (unordered set of name/value pairs)
    -
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4392
    -
    ~basic_json()
    destructor
    Definition: json.hpp:1988
    -
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6729
    -
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6766
    -
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6407
    -
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4090
    -
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:2057
    -
    basic_json value_type
    the type of elements in a basic_json container
    Definition: json.hpp:217
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:922
    -
    AllocatorType< basic_json > allocator_type
    the allocator type
    Definition: json.hpp:230
    -
    StringType string_t
    a type for a string
    Definition: json.hpp:447
    -
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4587
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3997
    -
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6570
    -
    value_type & reference
    the type of an element reference
    Definition: json.hpp:220
    -
    const_iterator begin() const
    returns a const iterator to the first element
    Definition: json.hpp:4007
    -
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5440
    -
    difference_type operator-(const iterator &other) const
    Definition: json.hpp:6773
    -
    basic_json(const int val)
    create an integer number from an enum type (explicit)
    Definition: json.hpp:1300
    -
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6685
    -
    namespace for Niels Lohmann
    Definition: json.hpp:88
    -
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:6136
    -
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:4969
    -
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6823
    -
    basic_json(const number_integer_t val)
    create an integer number (explicit)
    Definition: json.hpp:1271
    -
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:4145
    -
    basic_json(const CompatibleNumberIntegerType val) noexcept
    create an integer number (implicit)
    Definition: json.hpp:1337
    -
    const_reference front() const
    access the first element
    Definition: json.hpp:3557
    -
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6508
    -
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2289
    -
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6327
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:684
    -
    void swap(reference other) noexcept( std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value )
    exchanges the values
    Definition: json.hpp:4870
    -
    value_t
    the JSON type enumeration
    Definition: json.hpp:703
    -
    const_reverse_iterator rend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4153
    -
    std::ptrdiff_t difference_type
    a type to represent differences between iterators
    Definition: json.hpp:225
    -
    bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:2109
    -
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2720
    -
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:4901
    -
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3756
    -
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3498
    -
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6815
    -
    const_reference back() const
    access the last element
    Definition: json.hpp:3593
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4527
    +
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4366
    +
    ~basic_json()
    destructor
    Definition: json.hpp:1962
    +
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6703
    +
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6740
    +
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6381
    +
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4064
    +
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:2031
    +
    basic_json value_type
    the type of elements in a basic_json container
    Definition: json.hpp:191
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:896
    +
    AllocatorType< basic_json > allocator_type
    the allocator type
    Definition: json.hpp:204
    +
    StringType string_t
    a type for a string
    Definition: json.hpp:421
    +
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4561
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3971
    +
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6544
    +
    value_type & reference
    the type of an element reference
    Definition: json.hpp:194
    +
    const_iterator begin() const
    returns a const iterator to the first element
    Definition: json.hpp:3981
    +
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5414
    +
    difference_type operator-(const iterator &other) const
    Definition: json.hpp:6747
    +
    basic_json(const int val)
    create an integer number from an enum type (explicit)
    Definition: json.hpp:1274
    +
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6659
    +
    namespace for Niels Lohmann
    Definition: json.hpp:61
    +
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:6110
    +
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:4943
    +
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6797
    +
    basic_json(const number_integer_t val)
    create an integer number (explicit)
    Definition: json.hpp:1245
    +
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:4119
    +
    basic_json(const CompatibleNumberIntegerType val) noexcept
    create an integer number (implicit)
    Definition: json.hpp:1311
    +
    const_reference front() const
    access the first element
    Definition: json.hpp:3531
    +
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6482
    +
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2263
    +
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6301
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    +
    void swap(reference other) noexcept( std::is_nothrow_move_constructible< value_t >::value and std::is_nothrow_move_assignable< value_t >::value and std::is_nothrow_move_constructible< json_value >::value and std::is_nothrow_move_assignable< json_value >::value )
    exchanges the values
    Definition: json.hpp:4844
    +
    value_t
    the JSON type enumeration
    Definition: json.hpp:677
    +
    const_reverse_iterator rend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4127
    +
    std::ptrdiff_t difference_type
    a type to represent differences between iterators
    Definition: json.hpp:199
    +
    bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:2083
    +
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2694
    +
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:4875
    +
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3730
    +
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3472
    +
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6789
    +
    const_reference back() const
    access the last element
    Definition: json.hpp:3567
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4501
    array (ordered collection of values)
    -
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6834
    -
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5508
    -
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:5050
    -
    string_t value(const typename object_t::key_type &key, const char *default_value) const
    overload for a default value of type const char*
    Definition: json.hpp:3524
    -
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2870
    -
    basic_json(const CompatibleNumberUnsignedType val) noexcept
    create an unsigned number (implicit)
    Definition: json.hpp:1396
    -
    const_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:6148
    -
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6287
    +
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6808
    +
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5482
    +
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:5024
    +
    string_t value(const typename object_t::key_type &key, const char *default_value) const
    overload for a default value of type const char*
    Definition: json.hpp:3498
    +
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2844
    +
    basic_json(const CompatibleNumberUnsignedType val) noexcept
    create an unsigned number (implicit)
    Definition: json.hpp:1370
    +
    const_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:6122
    +
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6261
    -
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:5003
    -
    const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2819
    -
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:5202
    -
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6758
    -
    basic_json(const CompatibleNumberFloatType val) noexcept
    create an floating-point number (implicit)
    Definition: json.hpp:1471
    -
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6502
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3650
    -
    basic_json(std::initializer_list< basic_json > init, bool type_deduction=true, value_t manual_type=value_t::array)
    create a container (array or object) from an initializer list
    Definition: json.hpp:1544
    -
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6680
    -
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:5211
    -
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6818
    -
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6370
    -
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2270
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6645
    -
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:6142
    -
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6877
    -
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:3931
    -
    basic_json(const CompatibleObjectType &val)
    create an object (implicit)
    Definition: json.hpp:1070
    -
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5363
    -
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6514
    -
    const_iterator & operator=(const_iterator other) noexcept( std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< internal_iterator >::value and std::is_nothrow_move_assignable< internal_iterator >::value )
    copy assignment
    Definition: json.hpp:6207
    -
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3840
    -
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3223
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6630
    -
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4066
    -
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4553
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6594
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:6127
    -
    a template for a reverse iterator class
    Definition: json.hpp:238
    -
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:6140
    -
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6828
    -
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:5149
    -
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:3137
    -
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6466
    -
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6854
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2950
    -
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4330
    -
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4220
    -
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:4031
    -
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6751
    -
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4199
    -
    basic_json(const object_t &val)
    create an object (explicit)
    Definition: json.hpp:1038
    -
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5544
    -
    std::size_t operator()(const nlohmann::json &j) const
    return a hash value for a JSON object
    Definition: json.hpp:8573
    -
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5422
    -
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6202
    -
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6737
    -
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4692
    -
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2855
    -
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6548
    -
    basic_json(const CompatibleStringType &val)
    create a string (implicit)
    Definition: json.hpp:1218
    -
    basic_json(const basic_json &other)
    copy constructor
    Definition: json.hpp:1857
    -
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3382
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:857
    +
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:4977
    +
    const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2793
    +
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:5176
    +
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6732
    +
    basic_json(const CompatibleNumberFloatType val) noexcept
    create an floating-point number (implicit)
    Definition: json.hpp:1445
    +
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6476
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3624
    +
    basic_json(std::initializer_list< basic_json > init, bool type_deduction=true, value_t manual_type=value_t::array)
    create a container (array or object) from an initializer list
    Definition: json.hpp:1518
    +
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6654
    +
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:5185
    +
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6792
    +
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6344
    +
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2244
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6619
    +
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:6116
    +
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6851
    +
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:3905
    +
    basic_json(const CompatibleObjectType &val)
    create an object (implicit)
    Definition: json.hpp:1044
    +
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5337
    +
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6488
    +
    const_iterator & operator=(const_iterator other) noexcept( std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< internal_iterator >::value and std::is_nothrow_move_assignable< internal_iterator >::value )
    copy assignment
    Definition: json.hpp:6181
    +
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3814
    +
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3197
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6604
    +
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4040
    +
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4527
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6568
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:6101
    +
    a template for a reverse iterator class
    Definition: json.hpp:212
    +
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:6114
    +
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6802
    +
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:5123
    +
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:3111
    +
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6440
    +
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6828
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2924
    +
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4304
    +
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4194
    +
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:4005
    +
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6725
    +
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4173
    +
    basic_json(const object_t &val)
    create an object (explicit)
    Definition: json.hpp:1012
    +
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5518
    +
    std::size_t operator()(const nlohmann::json &j) const
    return a hash value for a JSON object
    Definition: json.hpp:8516
    +
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5396
    +
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6176
    +
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6711
    +
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4666
    +
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2829
    +
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6522
    +
    basic_json(const CompatibleStringType &val)
    create a string (implicit)
    Definition: json.hpp:1192
    +
    basic_json(const basic_json &other)
    copy constructor
    Definition: json.hpp:1831
    +
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3356
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:831
    diff --git a/namespacemembers.html b/namespacemembers.html index 679ef7278..9802cb446 100644 --- a/namespacemembers.html +++ b/namespacemembers.html @@ -94,7 +94,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    diff --git a/namespacemembers_type.html b/namespacemembers_type.html index 541cfba20..e115d739c 100644 --- a/namespacemembers_type.html +++ b/namespacemembers_type.html @@ -94,7 +94,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/namespacenlohmann.html b/namespacenlohmann.html index 1d78a80a6..5db133507 100644 --- a/namespacenlohmann.html +++ b/namespacenlohmann.html @@ -116,7 +116,7 @@ Typedefs diff --git a/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html b/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html index 0e5816afa..d74f96b37 100644 --- a/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html +++ b/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html @@ -105,7 +105,7 @@ Classes diff --git a/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html b/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html index f8e5753f0..949d72422 100644 --- a/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html +++ b/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

    This type is the default specialization of the basic_json class which uses the standard template types.

    Since
    version 1.0.0
    -

    Definition at line 8538 of file json.hpp.

    +

    Definition at line 8481 of file json.hpp.

    @@ -111,7 +111,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/search/all_9.js b/search/all_9.js index b38d2244f..2dd8f103e 100644 --- a/search/all_9.js +++ b/search/all_9.js @@ -1,5 +1,6 @@ var searchData= [ + ['json_20for_20modern_20c_2b_2b',['JSON for Modern C++',['../index.html',1,'']]], ['json',['json',['../namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html#a2bfd99e845a2e5cd90aeaf1b1431f474',1,'nlohmann']]], ['json_5freverse_5fiterator',['json_reverse_iterator',['../classnlohmann_1_1basic__json_1_1json__reverse__iterator.html',1,'nlohmann::basic_json']]], ['json_5freverse_5fiterator',['json_reverse_iterator',['../classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7c5e0d3bd0e1a2ba9226b7eb539a53d6.html#a7c5e0d3bd0e1a2ba9226b7eb539a53d6',1,'nlohmann::basic_json::json_reverse_iterator::json_reverse_iterator(const typename base_iterator::iterator_type &it)'],['../classnlohmann_1_1basic__json_1_1json__reverse__iterator_a53407187cceeb3ee5390318713dad827.html#a53407187cceeb3ee5390318713dad827',1,'nlohmann::basic_json::json_reverse_iterator::json_reverse_iterator(const base_iterator &it)']]] diff --git a/search/pages_0.html b/search/pages_0.html index 4b85b3464..0db7267ba 100644 --- a/search/pages_0.html +++ b/search/pages_0.html @@ -1,7 +1,7 @@ - + diff --git a/search/pages_0.js b/search/pages_0.js index 441b2dec1..a1254f19a 100644 --- a/search/pages_0.js +++ b/search/pages_0.js @@ -1,4 +1,4 @@ var searchData= [ - ['todo_20list',['Todo List',['../todo.html',1,'']]] + ['json_20for_20modern_20c_2b_2b',['JSON for Modern C++',['../index.html',1,'']]] ]; diff --git a/search/searchdata.js b/search/searchdata.js index 49c49476f..8cc9d453a 100644 --- a/search/searchdata.js +++ b/search/searchdata.js @@ -7,7 +7,8 @@ var indexSectionsWithContent = 4: "abcdijnoprsv", 5: "pv", 6: "abdknosv", - 7: "bo" + 7: "bo", + 8: "j" }; var indexSectionNames = @@ -19,7 +20,8 @@ var indexSectionNames = 4: "typedefs", 5: "enums", 6: "enumvalues", - 7: "related" + 7: "related", + 8: "pages" }; var indexSectionLabels = @@ -31,6 +33,7 @@ var indexSectionLabels = 4: "Typedefs", 5: "Enumerations", 6: "Enumerator", - 7: "Friends" + 7: "Friends", + 8: "Pages" }; diff --git a/structstd_1_1hash_3_01nlohmann_1_1json_01_4-members.html b/structstd_1_1hash_3_01nlohmann_1_1json_01_4-members.html index b1dce35ea..9b1738475 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4-members.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4-members.html @@ -98,7 +98,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html b/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html index d00c82de1..ac4098861 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html @@ -111,11 +111,11 @@ Public Member Functions struct std::hash< nlohmann::json > -

    Definition at line 8566 of file json.hpp.

    +

    Definition at line 8509 of file json.hpp.

    diff --git a/structstd_1_1hash_3_01nlohmann_1_1json_01_4_afd03f6ad53db22868ca4163a8200b2f9.html b/structstd_1_1hash_3_01nlohmann_1_1json_01_4_afd03f6ad53db22868ca4163a8200b2f9.html index 883cbc345..78932ca7c 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4_afd03f6ad53db22868ca4163a8200b2f9.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4_afd03f6ad53db22868ca4163a8200b2f9.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    Since
    version 1.0.0
    -

    Definition at line 8573 of file json.hpp.

    +

    Definition at line 8516 of file json.hpp.

    @@ -122,7 +122,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');