From 64281e798004f48c0db38bca01b3c73bb5380739 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 7 Feb 2016 14:57:42 +0100 Subject: [PATCH] Update --- annotated.html | 2 +- classes.html | 2 +- classnlohmann_1_1basic__json-members.html | 2 +- classnlohmann_1_1basic__json.html | 5 +- ...asic__json_1_1const__iterator-members.html | 2 +- ...ann_1_1basic__json_1_1const__iterator.html | 4 +- ...tor_a0d5820d1dda9dea3bbeb029cacf68522.html | 4 +- ...tor_a18c35a6735d3da96b4fc026421c05dd8.html | 4 +- ...tor_a1da96fc3054d547e7706d3a2f073f389.html | 4 +- ...tor_a49d7c3e9ef3280df03052cce988b792f.html | 4 +- ...tor_a5521515067b6597cb0b55a9c547a7a2b.html | 4 +- ...tor_a5d4320e24fcb7df041ff2c95d976dba0.html | 4 +- ...tor_a5e4d98a8f95e2eccde8cd48c19efa196.html | 4 +- ...tor_a65f491b515e5967e9c0b40289e3c0ff3.html | 4 +- ...tor_a6b682f09787eff62f03493d45aa05902.html | 4 +- ...tor_a6cab1c2ed7e2a014980e2a5717f43a64.html | 4 +- ...tor_a72761de693f95edc195956197f4e5569.html | 4 +- ...tor_a7a80257f2303210b0a5d056fc0b30b40.html | 4 +- ...tor_a7bd530bfbbc58ac77308c087120c21fa.html | 4 +- ...tor_a821560d64f50525162097f19b1392e7f.html | 4 +- ...tor_a8be837e4d902887676dd837abe9098d3.html | 4 +- ...tor_a8dbaec5bf8ccba3225520356629061cb.html | 4 +- ...tor_a8fbb15efd97599209a7def77af8e748e.html | 4 +- ...tor_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html | 4 +- ...tor_a9ea0497199b1e96ce9cadd1f202ec343.html | 4 +- ...tor_ab3029a1a83cf46dc28ad443bbad0c74d.html | 4 +- ...tor_ab4c0b9baaec9ebc4837158e272f6c803.html | 4 +- ...tor_abc4552ba2fe39e7901a83dd6d4dec151.html | 4 +- ...tor_ac6f4562e16e99b60820d100880b4c3c8.html | 4 +- ...tor_ac6fdaff67857f82a623e5cc253917639.html | 2 +- ...tor_ac75e80d30b6169ee2a29ec93fb4d2acd.html | 4 +- ...tor_acb6cd0ff760933afeb7f93e5207f3646.html | 4 +- ...tor_ada3100cdb8700566051828f1355fa745.html | 4 +- ...tor_adeb2ff3fdf3cc301b72db109934c9199.html | 4 +- ...tor_aefac8f3e390ac917f021761f4a8f8e71.html | 4 +- ...tor_aefd248cac6493eed1e6ff53ba6a63eb2.html | 4 +- ...tor_af6941c3711dabb2e64960dd57e00d201.html | 4 +- ...nn_1_1basic__json_1_1iterator-members.html | 2 +- classnlohmann_1_1basic__json_1_1iterator.html | 4 +- ...tor_a050b7fa21051ea57e5b0cc03668b5d4a.html | 4 +- ...tor_a085fe0d8cf459b5b1ae7b518b933ae7d.html | 4 +- ...tor_a1de0975e812c83e74d118b3e1063f335.html | 4 +- ...tor_a2943e49b3d88e6ee5793c5923ab2ede9.html | 4 +- ...tor_a3aae1df93a78b201d98e178c1c7d02a7.html | 4 +- ...tor_a3db892729714c4e7eaf60c00ee96e2e9.html | 4 +- ...tor_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html | 2 +- ...tor_a56952f8d5702541f0d88e6a764d2ae36.html | 4 +- ...tor_a790f550ff168095c83c2e459c575916c.html | 4 +- ...tor_a7e01532727c10f87926dac4eb8e170f4.html | 4 +- ...tor_a8ffbf287736048e683f58306fdb8701f.html | 4 +- ...tor_a97aff5d71246774267a81066460dd1cf.html | 4 +- ...tor_a9f3940ac5fb2c6ff8045ed59b8a0866f.html | 4 +- ...tor_ab07728b4da636eda0a24e0a51b8b46d7.html | 4 +- ...tor_ab3679dc63b3a59edb98b1c2b96d8683c.html | 4 +- ...tor_ab4f238aa5fcf452b1884b748b0395b1f.html | 4 +- ...tor_ac48754e4dc48d65d95294bd170dcd857.html | 4 +- ...tor_ae0c848dbc0af1cde15771d45d775b27c.html | 4 +- ...tor_ae58cd597336ad125d9615cff87fcd87e.html | 4 +- ...tor_afe86d48d3e4e5ebdaaec162b3cf0e95c.html | 4 +- ...on_1_1json__reverse__iterator-members.html | 2 +- ...asic__json_1_1json__reverse__iterator.html | 2 +- ...tor_a115fae3dd8ae02669fedae0545ce1cbc.html | 4 +- ...tor_a4aede52d6ee253a510897518b59e09c0.html | 4 +- ...tor_a53407187cceeb3ee5390318713dad827.html | 4 +- ...tor_a545a8204cfd6836eb85abc3113a0bb28.html | 4 +- ...tor_a563a7bd281e9919798d18396107fb05c.html | 4 +- ...tor_a693439bffe56a9a8cf53bc4a06b911ff.html | 4 +- ...tor_a7265535f39299824f9712a2ca15013c3.html | 4 +- ...tor_a7c5e0d3bd0e1a2ba9226b7eb539a53d6.html | 4 +- ...tor_a99ee137dab7e5c948457f6a5321b54b1.html | 4 +- ...tor_a9accc9dd9f9033f50c0ab6bcf337ffe0.html | 4 +- ...tor_a9ebc4c99e6fc90c965af0f39ad2ca70e.html | 4 +- ...tor_ac2634bee082633671125e909dffad40a.html | 4 +- ...tor_aca5116682e206dac48f8a56716a3280b.html | 4 +- ...tor_acecae6d237fcf14c909fb42b9d2e2955.html | 4 +- ...tor_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html | 4 +- ...son_a01833b332b68d9af1f7cd7a816c39e49.html | 6 +- ...son_a06efb200b69942eacd1ea22d0f6ccebb.html | 2 +- ...son_a08ad7169ceb437efff7b2d4a8c0dafe2.html | 4 +- ...son_a098482190447461f47f80b99bf2519f6.html | 11 +- ...son_a0a2cbbd95862a623e7dc5c37e67dead0.html | 6 +- ...son_a0a60ef55808edb545f4f46e49656d035.html | 6 +- ...son_a0ac9894c9de8dc551cf2e5f1c605537f.html | 2 +- ...son_a112a2d8e76345ea64f71e2985fee4c52.html | 4 +- ...son_a122640e7e2db1814fc7bbb3c122ec76e.html | 6 +- ...son_a13c4d2ab4e7ee2f92be785a7b12948ff.html | 8 +- ...son_a140b8251f82e99ad279dcad5c977e26b.html | 8 +- ...son_a1579a8f72a230358d6cd1a6e8a62859b.html | 2 +- ...son_a1846cc6db1f38f5918c8200d9ce31896.html | 6 +- ...son_a197631f31d9b17285bf9f4c156fe49c2.html | 4 +- ...son_a1a446a48beed4ea564addfd12d235793.html | 2 +- ...son_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html | 6 +- ...son_a1ec2232bcd43091d49f8dfdd6cfe9865.html | 6 +- ...son_a20bfb2ca6d4c421c74bb3e53328cd437.html | 4 +- ...son_a214a8c22d616fd3567b88932c07436c9.html | 4 +- ...son_a231b02148577b69a154b2ce2c87a5522.html | 2 +- ...son_a245b34ee6341bed2e3a611e223c53c48.html | 4 +- ...son_a263a9ecde33a1f2ff63dcd15d5e42cb7.html | 13 +- ...son_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html | 6 +- ...son_a2f1f83aa187a56dc5ec7a7027065ac8a.html | 2 +- ...son_a34d6a60dd99e9f33b8273a1c8db5669b.html | 6 +- ...son_a35303ad045a06c2a79dc28ac29652e86.html | 8 +- ...son_a3654da9a84deaf61899c4eee5b93c2c5.html | 4 +- ...son_a38ee0f09a318d003add75e0787040794.html | 6 +- ...son_a3aaf41d385f0d9a93deb92f9b14ae0cf.html | 4 +- ...son_a3da0951c80c8f4b26497aba38cb3e463.html | 6 +- ...son_a3da254c422ede5495f2815c5e48c00c5.html | 6 +- ...son_a3ec8e17be8732fe436e9d6733f52b7a3.html | 2 +- ...son_a45e789042a23138eba2b69f34df9fc45.html | 17 +- ...son_a486b96adbf4886c38e38c952394a220f.html | 6 +- ...son_a4ab93491f82545342562c7ee7e3166c7.html | 4 +- ...son_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html | 4 +- ...son_a4cf971f099c8114bb96c9d1c93e683f3.html | 6 +- ...son_a4f332e90f3cae562d0c3fa6ba48f74f9.html | 4 +- ...son_a51b0036310d8aa5858fecc0d91127f27.html | 6 +- ...son_a5212588544f6d2266384c3be9bfda0c5.html | 6 +- ...son_a5339f60209573ede87534b282c09fbd5.html | 4 +- ...son_a5685815624b086caa532f41e853d4b0f.html | 4 +- ...son_a579c170c06dc73a97f5e4c54d0942616.html | 4 +- ...son_a59732a1de287a7301cca19a7a7748159.html | 6 +- ...son_a5c8bb5200f5eac10d31e26be46e5b1ac.html | 6 +- ...son_a5d288e4e8828c2ef03a4f9958ce3d175.html | 4 +- ...son_a5e34c5435e557d0bf666bd7311211405.html | 6 +- ...son_a5ffdd3a9d2e02ebcbad13cb90af57523.html | 4 +- ...son_a60a04166c122072ab11eaf9845d9cd1d.html | 2 +- ...son_a60ca396028b8d9714c6e10efbf475af6.html | 6 +- ...son_a620e4d98496f85bd7be080248c0f14e9.html | 2 +- ...son_a624025acfcf64364d98424402b837bc6.html | 6 +- ...son_a626a27f30d6912d7f516eac511fd3362.html | 4 +- ...son_a674de1ee73e6bf4843fc5dc1351fb726.html | 4 +- ...son_a68a5f34b164a07b8ced13fcf2b7ec834.html | 2 +- ...son_a6adb089a5cacff9c7ad80d753b3fdf98.html | 4 +- ...son_a6e2e21da48f5d9471716cd868a068327.html | 6 +- ...son_a6f3dfd3e83a1e907d7946b47fcd7ceba.html | 6 +- ...son_a71b1d38ef402dfee58fba1fe01fa67f5.html | 11 +- ...son_a73619da32d2a1388f5c7b37f2032138f.html | 4 +- ...son_a73e150cbcba5643cb89de8f515eb64e2.html | 4 +- ...son_a74a0013e847fdc574b48f931f0e757e1.html | 2 +- ...son_a74a943800c7f103d0990d7eef82c6453.html | 6 +- ...son_a791afb7d6974c52b134d66aa1f249164.html | 4 +- ...son_a7ab11375ed2e29c2fcb6119386851445.html | 4 +- ...son_a7c3182cfabc0bdd9f3a14216fe0e8154.html | 4 +- ...son_a7ed92d56cb313b243c1917696ffdf074.html | 4 +- ...son_a7f53f3afd83a13c949c6c42e66e9c4b4.html | 6 +- ...son_a7f7bbb3a9efef2e2442f538a24c1c47b.html | 6 +- ...son_a7f97a91ad8f1d5cf0b9213bd24f247c4.html | 6 +- ...son_a8032645ce3109a7a4899badd90fa3480.html | 6 +- ...son_a805e3f3a2f374da0e14942eec7400e40.html | 4 +- ...son_a80c21170db6b5ffd9274b3f351cebadc.html | 6 +- ...son_a81aaaab0f3b326afda2d226daab4f1e1.html | 4 +- ...son_a8209621de6184d9eabe136b7c8f61935.html | 6 +- ...son_a8468efcfcd95db15f46887b29924ed5c.html | 6 +- ...son_a86089c703a2e563b9f760c2f8408efa7.html | 6 +- ...son_a87db51b6b936fb2ea293cdbc8702dcb8.html | 6 +- ...son_a8969119432218155193bb1dac30aa4ff.html | 4 +- ...son_a8f77085bd98c97a983d9ba12efbf6148.html | 4 +- ...son_a90239431815c94b0a334f7f4c55eb859.html | 6 +- ...son_a92fbb711a36b5ce78ee228b26787c034.html | 8 +- ...son_a947b5b2a832e490858dbdddfe7085831.html | 2 +- ...son_a9486a272e034c0548305d7a12f3045e6.html | 6 +- ...son_a9730b9f7bc2150e641fe20198d4477c7.html | 6 +- ...son_a9857835334d38ba04959e348ca6be208.html | 4 +- ...son_a98e05a2c9b8f74bd60442772cddeee52.html | 6 +- ...son_a99f2e765029e51dd0fff018650f92eea.html | 6 +- ...son_a9af5ea68c88f423ddf35216aff7f1813.html | 4 +- ...son_a9c01092601b6229eee4f971aad263133.html | 6 +- ...son_a9d1b58099dc64695fcf2847ab0b2a7c7.html | 2 +- ...son_a9e35475e2027520a78e09f460dbe048a.html | 2 +- ...son_aa36e72ffc3241b960fe9186d19e03bc3.html | 9 +- ...son_aa44ce84b9ac506b905b8fb56c9a0989d.html | 2 +- ...son_aa45753034bea87f9d2c0c42ace9ff75c.html | 6 +- ...son_aa669d997ddc03566de5438781254b32b.html | 4 +- ...son_aa6fd72df1ce9f80e61012784c598456e.html | 6 +- ...son_aaa687595d7627925fbf6d6eb97e2021e.html | 6 +- ...son_aac185a137428a7337aa620de07bfbbd7.html | 4 +- ...son_aacd442b66140c764c594ac8ad7dfd5b3.html | 6 +- ...son_aadb4e5be88221e5e28cdb752332f3d13.html | 6 +- ...son_aaf363408931d76472ded14017e59c9e8.html | 6 +- ...son_ab00b882d39306d663c23dab110f5cae0.html | 2 +- ...son_ab31368c0b67f8e4f291a45e6498018be.html | 4 +- ...son_ab63e618bbb0371042b1bec17f5891f42.html | 2 +- ...son_ab7b7b44891ddbc2df8ba3cbef3609178.html | 4 +- ...son_ab7be2bc58ae0c2c2c30d40f15d6399f8.html | 4 +- ...son_ab7d704826813d13731fbcaf220160826.html | 4 +- ...son_ab81f2801779e6cb9d98770860af2e39a.html | 8 +- ...son_ab856bebfdfbcf45061f1474ea8ba9924.html | 4 +- ...son_ab8b43d92a042dde96c28aeea81dd52de.html | 4 +- ...son_ab936779c70bec68343ef440ed13251e5.html | 4 +- ...son_abb5df282f9edf9cca898c6b8a9911111.html | 4 +- ...son_abc13258393358cb75a32fac86480bc9c.html | 6 +- ...son_ac4b10b2364f26ce47bdb9a413ff04a59.html | 2 +- ...son_ac5693cff1df0775cd3fbe960412cde4b.html | 4 +- ...son_ac7c006e2345a76859c4802db7d130e0e.html | 8 +- ...son_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html | 2 +- ...son_acbc1c415072afe69b5e69b87f496e44b.html | 6 +- ...son_ad09218e192a80ffa8df531941afdab60.html | 4 +- ...son_ad101425649dbc5c2e851fdb52c31741d.html | 6 +- ...son_ad25b2f8c21e241e2d63455537a9294ff.html | 4 +- ...son_ad2eddc2c13ab084f067eaba65d381ad2.html | 4 +- ...son_ad2f716992118a42aa8f8d57950a8d0bb.html | 4 +- ...son_ad534f6d0d48bfd1d85f72d7f1b62a46d.html | 6 +- ...son_ad5514a7435f246fc5335856465022a7a.html | 6 +- ...son_ad6e51670e9c0052856f3fee01df5c44f.html | 6 +- ...son_ad9cd312208273fb3fb2adf1f6d8d34ae.html | 6 +- ...son_ade0e56c8c320d7f342e7a5697e6d6f7e.html | 4 +- ...son_ae129dc8ccd58cc3c64614db7d40a7dc9.html | 6 +- ...son_ae336fff01f4b78e3e16e5008dc8dbc00.html | 2 +- ...son_ae347859ec88176ef76a0cbe5b4514fcf.html | 6 +- ...son_ae799491eda5f5868a38ccdafca9fe0f0.html | 4 +- ...son_ae85d91b0620650bcd9993e09d0e287d9.html | 4 +- ...son_aea1c863b719b4ca5b77188c171bbfafe.html | 2 +- ...son_aeaa0644fd6b99af364e772092268dfd6.html | 6 +- ...son_aec316934a555dd1acdd3600e5d4a4cdf.html | 2 +- ...son_aef496a56163710084e13612ab73e6ed2.html | 4 +- ...son_af071057ebab57744f5767eb369e99d42.html | 6 +- ...son_af12127e6fe8adbe727081f188aa599e2.html | 4 +- ...son_af148cdab12df5bf86119fac735ccaac5.html | 4 +- ...son_af3bc3e83aa162d7ba4df16a949872723.html | 2 +- ...son_af677a29b0e66edc9f66e5167e4667071.html | 2 +- ...son_af77614992e38b355b9213940051cc582.html | 6 +- ...son_af7acf3838a79363356f24538941a559c.html | 4 +- ...son_afeb998aec45296bc2050bd1c41ef41eb.html | 4 +- ...son_afec7d87796b8b538119b3ddc0d6950fb.html | 4 +- ...son_affe7e160e7bb06eed83c8b437af4692f.html | 6 +- dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- functions.html | 2 +- functions_0x7e.html | 2 +- functions_b.html | 2 +- functions_c.html | 2 +- functions_d.html | 2 +- functions_e.html | 2 +- functions_enum.html | 2 +- functions_f.html | 2 +- functions_func.html | 2 +- functions_g.html | 2 +- functions_i.html | 2 +- functions_j.html | 2 +- functions_k.html | 2 +- functions_m.html | 2 +- functions_n.html | 2 +- functions_o.html | 2 +- functions_p.html | 2 +- functions_r.html | 2 +- functions_rela.html | 2 +- functions_s.html | 2 +- functions_t.html | 2 +- functions_type.html | 2 +- functions_v.html | 2 +- graph_legend.html | 2 +- hierarchy.html | 2 +- index.html | 89 ++++-- index_8md_source.html | 4 +- json_8hpp_source.html | 274 +++++++++--------- mylayout.css | 10 +- namespacemembers.html | 2 +- namespacemembers_type.html | 2 +- namespacenlohmann.html | 2 +- ..._1anonymous__namespace_02json_8hpp_03.html | 2 +- ...ann_a2bfd99e845a2e5cd90aeaf1b1431f474.html | 4 +- ...ash_3_01nlohmann_1_1json_01_4-members.html | 2 +- ...std_1_1hash_3_01nlohmann_1_1json_01_4.html | 4 +- ...1_4_afd03f6ad53db22868ca4163a8200b2f9.html | 4 +- 262 files changed, 750 insertions(+), 713 deletions(-) diff --git a/annotated.html b/annotated.html index db3ae1cef..ff0874dd0 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 01a730c8b..634ef939a 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 3e3961e94..d7fdd5633 100644 --- a/classnlohmann_1_1basic__json-members.html +++ b/classnlohmann_1_1basic__json-members.html @@ -245,7 +245,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json.html b/classnlohmann_1_1basic__json.html index 57aedf5b8..d4798ee73 100644 --- a/classnlohmann_1_1basic__json.html +++ b/classnlohmann_1_1basic__json.html @@ -465,6 +465,9 @@ element access void erase (const size_type idx)  remove element from a JSON array given an index More...
  + + @@ -698,7 +701,7 @@ class nlohmann::basic_json diff --git a/classnlohmann_1_1basic__json_1_1const__iterator-members.html b/classnlohmann_1_1basic__json_1_1const__iterator-members.html index 4ef6e1a21..b7623d8d9 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');

+lookup

iterator find (typename object_t::key_type key)
 find an element in a JSON object More...
 
diff --git a/classnlohmann_1_1basic__json_1_1const__iterator.html b/classnlohmann_1_1basic__json_1_1const__iterator.html index b507ebf20..bcb3824a3 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::const_iterator
Since
version 1.0.0
-

Definition at line 6218 of file json.hpp.

+

Definition at line 6239 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 50f7e2845..bcca71b9d 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 6611 of file json.hpp.

+

Definition at line 6632 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 88885a53d..3400b6d25 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 6293 of file json.hpp.

+

Definition at line 6314 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 48dda7275..b351747fc 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 6229 of file json.hpp.

+

Definition at line 6250 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 60d0e6a96..30a05d89a 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 6227 of file json.hpp.

+

Definition at line 6248 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 3c807bf68..bd38b9503 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 6298 of file json.hpp.

+

Definition at line 6319 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 9af637308..c7185bfa4 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 6721 of file json.hpp.

+

Definition at line 6742 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 a9432a581..570d82c97 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 6661 of file json.hpp.

+

Definition at line 6682 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 6dce2b591..add7a9f09 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 6563 of file json.hpp.

+

Definition at line 6584 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 93a9d9fd7..06e95716a 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 6593 of file json.hpp.

+

Definition at line 6614 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 13fd41aed..7dab8da99 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 6490 of file json.hpp.

+

Definition at line 6511 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 d4cffd96d..98c1d19aa 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 6239 of file json.hpp.

+

Definition at line 6260 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 1342ecae5..a7e4477fc 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 6645 of file json.hpp.

+

Definition at line 6666 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 660858e22..b36629295 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 6685 of file json.hpp.

+

Definition at line 6706 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 b207565cb..bcada37cf 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 6233 of file json.hpp.

+

Definition at line 6254 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 fb739d5c9..e0b73d632 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 6418 of file json.hpp.

+

Definition at line 6439 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 23c35ad34..13c871d04 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 6453 of file json.hpp.

+

Definition at line 6474 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 817b20790..de0bd7a2d 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 6461 of file json.hpp.

+

Definition at line 6482 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 03e9a2cad..1d444ecea 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 6557 of file json.hpp.

+

Definition at line 6578 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 4f94295e4..f33ba99e3 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 6225 of file json.hpp.

+

Definition at line 6246 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 4acca2cf0..b931cde92 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 6378 of file json.hpp.

+

Definition at line 6399 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 4ef25f678..f89f8dd8e 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 6527 of file json.hpp.

+

Definition at line 6548 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 b2ac03b16..05458b6a2 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 6653 of file json.hpp.

+

Definition at line 6674 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 dc8c6802e..d3686fcae 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 6266 of file json.hpp.

+

Definition at line 6287 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 e6ea878ee..583c182c5 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 5f4c7b233..7182a16d9 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 6736 of file json.hpp.

+

Definition at line 6757 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 fa638e95f..34c26824b 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 6599 of file json.hpp.

+

Definition at line 6620 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 81b56ddae..4be2c6eb9 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 6221 of file json.hpp.

+

Definition at line 6242 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 084783fa3..2b0a68cc4 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 6498 of file json.hpp.

+

Definition at line 6519 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 f6134db96..949bbebd4 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 6639 of file json.hpp.

+

Definition at line 6660 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 14e244116..3331a1fca 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 6231 of file json.hpp.

+

Definition at line 6252 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 80cc3ddd6..2ca359501 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 6605 of file json.hpp.

+

Definition at line 6626 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 f2243c120..62505d1ee 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 2e9392c6a..1b9eff337 100644 --- a/classnlohmann_1_1basic__json_1_1iterator.html +++ b/classnlohmann_1_1basic__json_1_1iterator.html @@ -267,11 +267,11 @@ class nlohmann::basic_json::iterator
Since
version 1.0.0
-

Definition at line 6760 of file json.hpp.

+

Definition at line 6781 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 c0fe2ad89..a279c5d51 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 6813 of file json.hpp.

+

Definition at line 6834 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 bf658f871..b66f84a23 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 6771 of file json.hpp.

+

Definition at line 6792 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 0a5365f7b..1f38dbfbc 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 6776 of file json.hpp.

+

Definition at line 6797 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 f31db9b8b..902609f16 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 6805 of file json.hpp.

+

Definition at line 6826 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 a2c0c2f14..ea5c8cb8c 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 6764 of file json.hpp.

+

Definition at line 6785 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 0f252a0d1..646ab9526 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 6781 of file json.hpp.

+

Definition at line 6802 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 61725b93e..c2764f7c8 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 5dfd7d180..7da49cd87 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 6849 of file json.hpp.

+

Definition at line 6870 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 8833ce959..3edf7330b 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 6857 of file json.hpp.

+

Definition at line 6878 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 637aa551a..2fb356237 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 6871 of file json.hpp.

+

Definition at line 6892 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 47bddfc7e..96dd7e898 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 6877 of file json.hpp.

+

Definition at line 6898 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 a5c61258e..f1688be73 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 6765 of file json.hpp.

+

Definition at line 6786 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 86c244daa..126e4e5b4 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 6865 of file json.hpp.

+

Definition at line 6886 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 b33f3fa81..47b2cfcd8 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 6793 of file json.hpp.

+

Definition at line 6814 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 b86c48e72..84e545fec 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 6828 of file json.hpp.

+

Definition at line 6849 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 9e8473848..5cb127328 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 6820 of file json.hpp.

+

Definition at line 6841 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 06ab9dc50..8b2f97645 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 6763 of file json.hpp.

+

Definition at line 6784 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 44d10af80..cde6ca997 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 6835 of file json.hpp.

+

Definition at line 6856 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 3320168d3..e99912d5b 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 6799 of file json.hpp.

+

Definition at line 6820 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 c8d17865e..b70db5903 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 6842 of file json.hpp.

+

Definition at line 6863 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 f5d888f1b..c260642d0 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 29c57bf7d..4453897c1 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html @@ -174,7 +174,7 @@ class nlohmann::basic_json::json_reverse_iterator< Base > 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 9e2aa58e6..4dbd417a4 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 6969 of file json.hpp.

+

Definition at line 6990 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 004da32df..9c6488f3f 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 6926 of file json.hpp.

+

Definition at line 6947 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 3fc864868..3695d5011 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 6915 of file json.hpp.

+

Definition at line 6936 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 29fa29fab..032e86d42 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 6920 of file json.hpp.

+

Definition at line 6941 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 d726c7376..82873bada 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 6939 of file json.hpp.

+

Definition at line 6960 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 df011d02c..9f2456d50 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 6933 of file json.hpp.

+

Definition at line 6954 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 7e27cc7ce..666c126be 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 6907 of file json.hpp.

+

Definition at line 6928 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 0a8a35c4c..045238f2f 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 6910 of file json.hpp.

+

Definition at line 6931 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 3861369c7..6effd919f 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 6953 of file json.hpp.

+

Definition at line 6974 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 a32f28dda..f0d07e9e6 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 6946 of file json.hpp.

+

Definition at line 6967 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 1f97ab1c3..75cfc62b0 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 6905 of file json.hpp.

+

Definition at line 6926 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 518c3e773..a8706b467 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 6961 of file json.hpp.

+

Definition at line 6982 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 1f283c9ab..ffb6a7352 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 6988 of file json.hpp.

+

Definition at line 7009 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 1ebd9ff7c..b42df895c 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 6981 of file json.hpp.

+

Definition at line 7002 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 191c918e2..d899fdda2 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 6975 of file json.hpp.

+

Definition at line 6996 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 9075f86ed..bfe39d2a5 100644 --- a/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html +++ b/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html @@ -282,7 +282,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:8601
    +
    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:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    0
    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     max_size() – returns the maximal number of elements
    Since
    version 1.0.0
    -

    Definition at line 4416 of file json.hpp.

    +

    Definition at line 4437 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_a06efb200b69942eacd1ea22d0f6ccebb.html b/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html index a9d4a98b9..98014edca 100644 --- a/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html +++ b/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html @@ -258,7 +258,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 d36fb1b18..e73f57ee9 100644 --- a/classnlohmann_1_1basic__json_a08ad7169ceb437efff7b2d4a8c0dafe2.html +++ b/classnlohmann_1_1basic__json_a08ad7169ceb437efff7b2d4a8c0dafe2.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     true
     false
    @@ -283,7 +283,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html b/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html index 5e611dc7b..470d18c00 100644 --- a/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html +++ b/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html @@ -258,18 +258,17 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Returns a reference to the last element in the container. For a JSON container c, the expression c.back() is equivalent to { auto tmp = c.end(); --tmp; return *tmp; }.

    -
    Returns
    In case of a structured type (array or object), a reference to the last element is returned. In cast of number, string, or boolean values, a reference to the value is returned.
    +

    Returns a reference to the last element in the container. For a JSON container c, the expression c.back() is equivalent to

    auto tmp = c.end();
    --tmp;
    return *tmp;
    Returns
    In case of a structured type (array or object), a reference to the last element is returned. In cast of number, string, or boolean values, a reference to the value is returned.
    Complexity
    Constant.
    Precondition
    The JSON value must not be null (would throw std::out_of_range) or an empty array or object (undefined behavior, guarded by assertions).
    Postcondition
    The JSON value remains unchanged.
    Exceptions
    - +
    std::out_of_rangewhen called on null value.
    std::out_of_rangewhen called on null value.
    -
    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'; // undefined behavior
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // undefined behavior
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    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'; // undefined behavior
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // undefined behavior
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -282,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    front() – access the first element
    Since
    version 1.0.0
    -

    Definition at line 3622 of file json.hpp.

    +

    Definition at line 3627 of file json.hpp.

    @@ -292,7 +291,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 7ac0c8ad8..e61e93007 100644 --- a/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html +++ b/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html @@ -297,7 +297,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:8601
    +
    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:8622
    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
    @@ -305,7 +305,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3519 of file json.hpp.

    +

    Definition at line 3520 of file json.hpp.

    @@ -315,7 +315,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html b/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html index 28fd4052a..2ee669081 100644 --- a/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html +++ b/classnlohmann_1_1basic__json_a0a60ef55808edb545f4f46e49656d035.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    crbegin() – returns a const reverse iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4218 of file json.hpp.

    +

    Definition at line 4239 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html b/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html index f956eae61..303aef0a6 100644 --- a/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html +++ b/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html @@ -290,7 +290,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 b77ef7b14..3e23820f9 100644 --- a/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html +++ b/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html @@ -278,7 +278,7 @@ 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:8601
    +
    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:8622
    Output (play with this example online):
    []
     ["Hello"]
     ["Hello","Hello","Hello","Hello","Hello"]
    @@ -295,7 +295,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 4a9c713f3..6498dbc98 100644 --- a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html +++ b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html @@ -283,7 +283,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:8601
    +
    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:8622
    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
    @@ -291,7 +291,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 5140 of file json.hpp.

    +

    Definition at line 5161 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_a13c4d2ab4e7ee2f92be785a7b12948ff.html b/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html index eb7017edb..21f18737d 100644 --- a/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html +++ b/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html @@ -279,8 +279,8 @@ 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:8601
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5569
    +
    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:8622
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5590
    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:831
    @@ -322,7 +322,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 5598 of file json.hpp.

    +

    Definition at line 5619 of file json.hpp.

    @@ -332,7 +332,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 49c9ebdd9..85ff3996d 100644 --- a/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html +++ b/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html @@ -272,12 +272,12 @@ template<typename T , std::size_t n>
    Returns
    reference to the element at key key
    Exceptions
    - +
    std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with null"
    std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with string"
    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:8601
    +
    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:8622
    Output (play with this example online):
    2
     
     {
    @@ -303,7 +303,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 3335 of file json.hpp.

    +

    Definition at line 3336 of file json.hpp.

    @@ -313,7 +313,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 940c8da71..f6c86e67a 100644 --- a/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html +++ b/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html @@ -258,7 +258,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 a396a1837..7764518c7 100644 --- a/classnlohmann_1_1basic__json_a1846cc6db1f38f5918c8200d9ce31896.html +++ b/classnlohmann_1_1basic__json_a1846cc6db1f38f5918c8200d9ce31896.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    crbegin() – returns a const reverse iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4276 of file json.hpp.

    +

    Definition at line 4297 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html b/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html index 44f056c12..669cbe64f 100644 --- a/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html +++ b/classnlohmann_1_1basic__json_a197631f31d9b17285bf9f4c156fe49c2.html @@ -275,7 +275,7 @@ template<typename T , typename std::enable_if<
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of an 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:8601
    +
    Example
    The example below shows the construction of an 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:8622
    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 
    @@ -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 07731f47a..148bf91b2 100644 --- a/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html +++ b/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html @@ -269,7 +269,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 939507400..a392b01a0 100644 --- a/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html +++ b/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html @@ -273,7 +273,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:8601
    +
    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:8622
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -281,7 +281,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 4643 of file json.hpp.

    +

    Definition at line 4664 of file json.hpp.

    @@ -291,7 +291,7 @@ null diff --git a/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html b/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html index 47d3aa023..ee7ffc669 100644 --- a/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html +++ b/classnlohmann_1_1basic__json_a1ec2232bcd43091d49f8dfdd6cfe9865.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    See also
    cend() – returns a const iterator to the end
    @@ -279,7 +279,7 @@ Illustration from cppreference.com
    cbegin() – returns a const iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4103 of file json.hpp.

    +

    Definition at line 4124 of file json.hpp.

    @@ -289,7 +289,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html b/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html index f2f05be11..d332f805a 100644 --- a/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html +++ b/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html @@ -275,7 +275,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:8601
    +
    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:8622
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -303,7 +303,7 @@ array: [1,2,3,4,5]
     
    diff --git a/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html b/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html index be430d410..71e62cc02 100644 --- a/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html +++ b/classnlohmann_1_1basic__json_a214a8c22d616fd3567b88932c07436c9.html @@ -275,7 +275,7 @@ 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:8601
    +
    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:8622
    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:1616
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2971
    Output (play with this example online):
    "third"
    @@ -294,7 +294,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 dbddc1b1e..154c4af96 100644 --- a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html +++ b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html @@ -297,7 +297,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 1914ba25b..75f4cb127 100644 --- a/classnlohmann_1_1basic__json_a245b34ee6341bed2e3a611e223c53c48.html +++ b/classnlohmann_1_1basic__json_a245b34ee6341bed2e3a611e223c53c48.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     true
    @@ -288,7 +288,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html b/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html index bb8230cd9..eeb431f3d 100644 --- a/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html +++ b/classnlohmann_1_1basic__json_a263a9ecde33a1f2ff63dcd15d5e42cb7.html @@ -271,8 +271,8 @@ template<class InteratorType , typename std::enable_if<
    -

    Removes the element specified by the range [first; last). Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator first does not need to be dereferenceable if first == last: erasing an empty range is a no-op.

    -

    If called on a primitive type other than null, the resulting JSON value will be null.

    +

    Removes the element specified by the range [first; last). The iterator first does not need to be dereferenceable if first == last: erasing an empty range is a no-op.

    +

    If called on a primitive type other than null, the resulting JSON value will be null.

    Parameters
    @@ -280,13 +280,14 @@ template<class InteratorType , typename std::enable_if<
    [in]firstiterator to the beginning of the range to remove
    -
    Returns
    Iterator following the last removed element. If the iterator second refers to the last element, the end() iterator is returned.
    +
    Returns
    Iterator following the last removed element. If the iterator second refers to the last element, the end() iterator is returned.
    Template Parameters
    InteratorTypean iterator or const_iterator
    +
    Postcondition
    Invalidates iterators and references at or after the point of the erase, including the end() iterator.
    Exceptions
  • 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:8601
    +
    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:8622
    Output (play with this example online):
    null
     null
     null
    @@ -318,7 +319,7 @@ null
     erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3785 of file json.hpp.

    +

    Definition at line 3793 of file json.hpp.

    @@ -328,7 +329,7 @@ null diff --git a/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html b/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html index 116474da5..de2fec820 100644 --- a/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html +++ b/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html @@ -276,7 +276,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:8601
    +
    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:8622
    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
    @@ -284,7 +284,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3292 of file json.hpp.

    +

    Definition at line 3293 of file json.hpp.

    @@ -294,7 +294,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html b/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html index 4e6d2d3d9..fa9dd8868 100644 --- a/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html +++ b/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html @@ -258,7 +258,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 c78cac43c..fc331982b 100644 --- a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html +++ b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html @@ -279,7 +279,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:8601
    +
    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:8622
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -300,7 +300,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 5530 of file json.hpp.

    +

    Definition at line 5551 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_a35303ad045a06c2a79dc28ac29652e86.html b/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html index e355cd214..a5d8cc8b0 100644 --- a/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html +++ b/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html @@ -279,8 +279,8 @@ 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:8601
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5569
    +
    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:8622
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5590
    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:831
    @@ -322,7 +322,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 5569 of file json.hpp.

    +

    Definition at line 5590 of file json.hpp.

    @@ -332,7 +332,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 eecf71261..122d1aa34 100644 --- a/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html +++ b/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html @@ -273,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    std::domain_errorif called on a null value; example: "cannot use @@ -303,7 +304,7 @@ erase() with null"
    -
    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:8601
    +
    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:8622
    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
    @@ -291,7 +291,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 aebcb53a2..e6109625f 100644 --- a/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html +++ b/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html @@ -273,14 +273,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how objects can be swapped with swap().
    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:8601
    +
    Example
    The example below shows how objects can be swapped with swap().
    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:8622
    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 5025 of file json.hpp.

    +

    Definition at line 5046 of file json.hpp.

    @@ -290,7 +290,7 @@ object = {"one":"eins","two":"zwei"} diff --git a/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html b/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html index 2edfc796d..4ddf45701 100644 --- a/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html +++ b/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html @@ -273,7 +273,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -290,7 +290,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 758e59a27..3275762fc 100644 --- a/classnlohmann_1_1basic__json_a3da0951c80c8f4b26497aba38cb3e463.html +++ b/classnlohmann_1_1basic__json_a3da0951c80c8f4b26497aba38cb3e463.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    crend() – returns a const reverse iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4247 of file json.hpp.

    +

    Definition at line 4268 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html b/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html index af7c09d7f..c9b66472b 100644 --- a/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html +++ b/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html @@ -275,7 +275,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:8601
    +
    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:8622
    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
    @@ -285,7 +285,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 3907 of file json.hpp.

    +

    Definition at line 3918 of file json.hpp.

    @@ -295,7 +295,7 @@ range" diff --git a/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html b/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html index e067bea03..73f4cba66 100644 --- a/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html +++ b/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html @@ -258,7 +258,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 c1c09fdc6..675535fe1 100644 --- a/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html +++ b/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html @@ -261,28 +261,29 @@ template<class InteratorType , typename std::enable_if<
    -

    Removes the element specified by iterator pos. Invalidates iterators and references at or after the point of the erase, including the end() iterator. The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.

    -

    If called on a primitive type other than null, the resulting JSON value will be null.

    +

    Removes the element specified by iterator pos. The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.

    +

    If called on a primitive type other than null, the resulting JSON value will be null.

    Parameters
    [in]positerator to the element to remove
    -
    Returns
    Iterator following the last removed element. If the iterator pos refers to the last element, the end() iterator is returned.
    +
    Returns
    Iterator following the last removed element. If the iterator pos refers to the last element, the end() iterator is returned.
    Template Parameters
    InteratorTypean iterator or const_iterator
    +
    Postcondition
    Invalidates iterators and references at or after the point of the erase, including the end() iterator.
    Exceptions
    - +
    std::domain_errorif called on a null value; example: "cannot use erase() with null"
    std::domain_errorif called on an iterator which does not belong to the current JSON value; example: "iterator does not fit current value"
    std::out_of_rangeif called on a primitive type with invalid iterator (i.e., any iterator which is not end()); example: "iterator out -of range"
    std::out_of_rangeif called on a primitive type with invalid iterator (i.e., any iterator which is not begin()); example: "iterator +out of range"
    @@ -293,7 +294,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:8601
    +
    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:8622
    Output (play with this example online):
    null
     null
     null
    @@ -308,7 +309,7 @@ null
     erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3679 of file json.hpp.

    +

    Definition at line 3685 of file json.hpp.

    @@ -318,7 +319,7 @@ null diff --git a/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html b/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html index f1d85f494..2be533c97 100644 --- a/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html +++ b/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html @@ -273,7 +273,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:8601
    +
    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:8622
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -281,7 +281,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 4617 of file json.hpp.

    +

    Definition at line 4638 of file json.hpp.

    @@ -291,7 +291,7 @@ null diff --git a/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html b/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html index 089dc2c03..fd513d175 100644 --- a/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html +++ b/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html @@ -278,7 +278,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -294,7 +294,7 @@ true
    diff --git a/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html b/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html index be74143a2..ac99fd025 100644 --- a/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html +++ b/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html @@ -279,7 +279,7 @@ template<typename CompatibleNumberFloatType , typename = typename std::enabl 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 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:8601
    +
    Example
    The example below shows the construction of several 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:8622
    Output (play with this example online):
    42.2299995422363
     null
     23.42
    @@ -297,7 +297,7 @@ null
     
    diff --git a/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html b/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html index 6b5bcba15..b46b638e6 100644 --- a/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html +++ b/classnlohmann_1_1basic__json_a4cf971f099c8114bb96c9d1c93e683f3.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    See also
    cbegin() – returns a const iterator to the beginning
    @@ -279,7 +279,7 @@ Illustration from cppreference.com
    cend() – returns a const iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4032 of file json.hpp.

    +

    Definition at line 4053 of file json.hpp.

    @@ -289,7 +289,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html b/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html index 5e2d018fa..29efb9508 100644 --- a/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html +++ b/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html @@ -276,7 +276,7 @@ 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:8601
    +
    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:8622
    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
    @@ -294,7 +294,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 201c4ed31..2411e3442 100644 --- a/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html +++ b/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html @@ -268,13 +268,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:8601
    +
    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:8622
    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 3991 of file json.hpp.

    +

    Definition at line 4012 of file json.hpp.

    @@ -284,7 +284,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 2ff449c4f..a1ef57e28 100644 --- a/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html +++ b/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html @@ -273,7 +273,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:8601
    +
    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:8622
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -281,7 +281,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 4703 of file json.hpp.

    +

    Definition at line 4724 of file json.hpp.

    @@ -291,7 +291,7 @@ null diff --git a/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html b/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html index ef8f7d87a..1677b1490 100644 --- a/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html +++ b/classnlohmann_1_1basic__json_a5339f60209573ede87534b282c09fbd5.html @@ -268,7 +268,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 an 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:8601
    +
    Example
    The example below shows the construction of an 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:8622
    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)
    @@ -286,7 +286,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 1f2e67934..019cf3914 100644 --- a/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html +++ b/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html @@ -273,7 +273,7 @@ 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:8601
    +
    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:8622
    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:1616
    Output (play with this example online):
    []
     []
    @@ -295,7 +295,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 dfee9581b..32e86b587 100644 --- a/classnlohmann_1_1basic__json_a579c170c06dc73a97f5e4c54d0942616.html +++ b/classnlohmann_1_1basic__json_a579c170c06dc73a97f5e4c54d0942616.html @@ -261,7 +261,7 @@ 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:8601
    +
    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:8622
    object (unordered set of name/value pairs)
    value_t
    the JSON type enumeration
    Definition: json.hpp:677
    @@ -290,7 +290,7 @@ true
    diff --git a/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html b/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html index 54416821e..9289edd32 100644 --- a/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html +++ b/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html @@ -271,12 +271,12 @@ template<template< typename U, typename V, typename...Args > class Obje
    Exceptions
    +use operator[] with string"
    std::domain_errorif JSON is not an array or null; example: "cannot -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:8601
    +
    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:8622
    Output (play with this example online):
    4
     [1,2,3,4,6]
     [1,2,3,4,6,null,null,null,null,null,11]
    @@ -293,7 +293,7 @@ use operator[] with null"
     
    diff --git a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html index c3e3f5ce3..1d4835382 100644 --- a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html +++ b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html @@ -279,7 +279,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:8601
    +
    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:8622
    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
    @@ -287,7 +287,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 5431 of file json.hpp.

    +

    Definition at line 5452 of file json.hpp.

    @@ -297,7 +297,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 aaabceac0..af44e6318 100644 --- a/classnlohmann_1_1basic__json_a5d288e4e8828c2ef03a4f9958ce3d175.html +++ b/classnlohmann_1_1basic__json_a5d288e4e8828c2ef03a4f9958ce3d175.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -288,7 +288,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html index 525804bd2..03392288d 100644 --- a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html +++ b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html @@ -279,7 +279,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:8601
    +
    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:8622
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -300,7 +300,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 5512 of file json.hpp.

    +

    Definition at line 5533 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_a5ffdd3a9d2e02ebcbad13cb90af57523.html b/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html index af9b26f41..a2a9515af 100644 --- a/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html +++ b/classnlohmann_1_1basic__json_a5ffdd3a9d2e02ebcbad13cb90af57523.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    true
     false
     false
    @@ -283,7 +283,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html b/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html index 996754996..b6062708d 100644 --- a/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html +++ b/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html @@ -285,7 +285,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 756baf960..25f27bbfc 100644 --- a/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html +++ b/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html @@ -285,7 +285,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:8601
    +
    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:8622
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -303,7 +303,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 5634 of file json.hpp.

    +

    Definition at line 5655 of file json.hpp.

    @@ -313,7 +313,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 08ab95ca7..fa726324f 100644 --- a/classnlohmann_1_1basic__json_a620e4d98496f85bd7be080248c0f14e9.html +++ b/classnlohmann_1_1basic__json_a620e4d98496f85bd7be080248c0f14e9.html @@ -288,7 +288,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 e16402802..0074b7bb3 100644 --- a/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html +++ b/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html @@ -293,13 +293,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:8601
    +
    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:8622
    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 4811 of file json.hpp.

    +

    Definition at line 4832 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_a626a27f30d6912d7f516eac511fd3362.html b/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html index 40f4b913a..d9fd000ef 100644 --- a/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html +++ b/classnlohmann_1_1basic__json_a626a27f30d6912d7f516eac511fd3362.html @@ -262,7 +262,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -284,7 +284,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html b/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html index 6224f3fb5..6b616ab11 100644 --- a/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html +++ b/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html @@ -275,7 +275,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:8601
    +
    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:8622
    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 
    @@ -294,7 +294,7 @@ out of range
    diff --git a/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html b/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html index 25a074e4e..fbe5bc25e 100644 --- a/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html +++ b/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html @@ -288,7 +288,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 3146e3479..db73582d2 100644 --- a/classnlohmann_1_1basic__json_a6adb089a5cacff9c7ad80d753b3fdf98.html +++ b/classnlohmann_1_1basic__json_a6adb089a5cacff9c7ad80d753b3fdf98.html @@ -271,7 +271,7 @@ template<template< typename U, typename V, typename...Args > class Obje 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:8601
    +
    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:8622
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:658
    Output (play with this example online):
    3.14159265358979
     null
    @@ -290,7 +290,7 @@ null
     
    diff --git a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html index 82aeee267..b47fdfe36 100644 --- a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html +++ b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html @@ -279,7 +279,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:8601
    +
    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:8622
    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
    @@ -287,7 +287,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 5269 of file json.hpp.

    +

    Definition at line 5290 of file json.hpp.

    @@ -297,7 +297,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 f4ca15acf..6da0af6f3 100644 --- a/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html +++ b/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html @@ -273,7 +273,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:8601
    +
    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:8622
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -281,7 +281,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 4653 of file json.hpp.

    +

    Definition at line 4674 of file json.hpp.

    @@ -291,7 +291,7 @@ null diff --git a/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html b/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html index 84e5340bb..028d0efb1 100644 --- a/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html +++ b/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html @@ -258,18 +258,17 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Returns a reference to the last element in the container. For a JSON container c, the expression c.back() is equivalent to { auto tmp = c.end(); --tmp; return *tmp; }.

    -
    Returns
    In case of a structured type (array or object), a reference to the last element is returned. In cast of number, string, or boolean values, a reference to the value is returned.
    +

    Returns a reference to the last element in the container. For a JSON container c, the expression c.back() is equivalent to

    auto tmp = c.end();
    --tmp;
    return *tmp;
    Returns
    In case of a structured type (array or object), a reference to the last element is returned. In cast of number, string, or boolean values, a reference to the value is returned.
    Complexity
    Constant.
    Precondition
    The JSON value must not be null (would throw std::out_of_range) or an empty array or object (undefined behavior, guarded by assertions).
    Postcondition
    The JSON value remains unchanged.
    Exceptions
    - +
    std::out_of_rangewhen called on null value.
    std::out_of_rangewhen called on null value.
    -
    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'; // undefined behavior
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // undefined behavior
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    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'; // undefined behavior
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // undefined behavior
    27  std::cout << j_string.back() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -282,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    front() – access the first element
    Since
    version 1.0.0
    -

    Definition at line 3612 of file json.hpp.

    +

    Definition at line 3617 of file json.hpp.

    @@ -292,7 +291,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 cb21853b3..3bc57be10 100644 --- a/classnlohmann_1_1basic__json_a73619da32d2a1388f5c7b37f2032138f.html +++ b/classnlohmann_1_1basic__json_a73619da32d2a1388f5c7b37f2032138f.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -283,7 +283,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html b/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html index 481575d6a..eaee0ec2d 100644 --- a/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html +++ b/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html @@ -268,7 +268,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -284,7 +284,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 01b738172..6aafc212e 100644 --- a/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html +++ b/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html @@ -281,7 +281,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 5ed82ef9c..1f55e76cd 100644 --- a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html +++ b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html @@ -279,7 +279,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:8601
    +
    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:8622
    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
    @@ -287,7 +287,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 5475 of file json.hpp.

    +

    Definition at line 5496 of file json.hpp.

    @@ -297,7 +297,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 56f519ffc..ce750aaa5 100644 --- a/classnlohmann_1_1basic__json_a791afb7d6974c52b134d66aa1f249164.html +++ b/classnlohmann_1_1basic__json_a791afb7d6974c52b134d66aa1f249164.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     true
    @@ -288,7 +288,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html b/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html index 402d35267..d94e7fb0a 100644 --- a/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html +++ b/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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
    @@ -288,7 +288,7 @@ true
     
    diff --git a/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html b/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html index 1a6af1580..eb82c7191 100644 --- a/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html +++ b/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html @@ -271,7 +271,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -287,7 +287,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 df2cb420b..5d9bc9918 100644 --- a/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html +++ b/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html @@ -275,7 +275,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:8601
    +
    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:8622
    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
    @@ -295,7 +295,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 c7fcb08ce..52d497846 100644 --- a/classnlohmann_1_1basic__json_a7f53f3afd83a13c949c6c42e66e9c4b4.html +++ b/classnlohmann_1_1basic__json_a7f53f3afd83a13c949c6c42e66e9c4b4.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    crend() – returns a const reverse iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4173 of file json.hpp.

    +

    Definition at line 4194 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html b/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html index 89aa1ed9e..7eb5e656e 100644 --- a/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html +++ b/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html @@ -286,13 +286,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:8601
    +
    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:8622
    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 4755 of file json.hpp.

    +

    Definition at line 4776 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_a7f97a91ad8f1d5cf0b9213bd24f247c4.html b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html index 4444bd5cf..353c4b5b7 100644 --- a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html +++ b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html @@ -279,7 +279,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:8601
    +
    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:8622

    Output (play with this example online):

    [1,2,3] != nullptr true
     {"A":"a","B":"b"} != nullptr true
     17 != nullptr true
    @@ -287,7 +287,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 5301 of file json.hpp.

    +

    Definition at line 5322 of file json.hpp.

    @@ -297,7 +297,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html b/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html index 8f9264ed2..8a320449a 100644 --- a/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html +++ b/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html @@ -269,7 +269,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'; // undefined behavior
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // undefined behavior
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    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'; // undefined behavior
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // undefined behavior
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -282,7 +282,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    back() – access the last element
    Since
    version 1.0.0
    -

    Definition at line 3582 of file json.hpp.

    +

    Definition at line 3583 of file json.hpp.

    @@ -292,7 +292,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 22acb2e0b..905507b3c 100644 --- a/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html +++ b/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html @@ -268,7 +268,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:8601
    +
    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:8622
    Output (play with this example online):
    {"one":1,"two":2}
     
     {"one":1,"two":2}
    @@ -317,7 +317,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 a28b07cee..2b26b7b8b 100644 --- a/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html +++ b/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html @@ -273,7 +273,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:8601
    +
    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:8622
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -281,7 +281,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 4677 of file json.hpp.

    +

    Definition at line 4698 of file json.hpp.

    @@ -291,7 +291,7 @@ null diff --git a/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html b/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html index 8bfc0fbc6..98982e097 100644 --- a/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html +++ b/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html @@ -281,7 +281,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:8601
    +
    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:8622
    Output (play with this example online):
    [1,2,3,4]
     [1.2,2.3,3.4,5.6]
     [true,true,false,true]
    @@ -305,7 +305,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 0768c1785..3bdd188f2 100644 --- a/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html +++ b/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html @@ -274,14 +274,14 @@ use swap() with string"
    Complexity
    Constant.
    -
    Example
    The example below shows how arrays can be swapped with swap().
    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:8601
    +
    Example
    The example below shows how arrays can be swapped with swap().
    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:8622
    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 4991 of file json.hpp.

    +

    Definition at line 5012 of file json.hpp.

    @@ -291,7 +291,7 @@ array = [1,2,3,4] diff --git a/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html b/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html index 610658693..c4d8efeeb 100644 --- a/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html +++ b/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html @@ -286,13 +286,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:8601
    +
    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:8622
    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 4782 of file json.hpp.

    +

    Definition at line 4803 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_a86089c703a2e563b9f760c2f8408efa7.html b/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html index 754a3faf8..bec509818 100644 --- a/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html +++ b/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html @@ -274,14 +274,14 @@ use swap() with boolean"
    Complexity
    Constant.
    -
    Example
    The example below shows how strings can be swapped with swap().
    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:8601
    +
    Example
    The example below shows how strings can be swapped with swap().
    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:8622
    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 5059 of file json.hpp.

    +

    Definition at line 5080 of file json.hpp.

    @@ -291,7 +291,7 @@ string = the bad diff --git a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html index 8408cfc9d..f3562ca7d 100644 --- a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html +++ b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html @@ -279,7 +279,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:8601
    +
    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:8622
    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
    @@ -287,7 +287,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 5453 of file json.hpp.

    +

    Definition at line 5474 of file json.hpp.

    @@ -297,7 +297,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 e4b3d7fac..d3e5c5ebd 100644 --- a/classnlohmann_1_1basic__json_a8969119432218155193bb1dac30aa4ff.html +++ b/classnlohmann_1_1basic__json_a8969119432218155193bb1dac30aa4ff.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -283,7 +283,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html b/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html index e026f80f6..861a51544 100644 --- a/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html +++ b/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html @@ -289,7 +289,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:8601
    +
    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:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    @@ -332,7 +332,7 @@ false
    diff --git a/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html b/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html index b2ec27eaf..df11d5b1a 100644 --- a/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html +++ b/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html @@ -282,7 +282,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:8601
    +
    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:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -298,7 +298,7 @@ false
     
    See also
    size() – returns the number of elements
    Since
    version 1.0.0
    -

    Definition at line 4353 of file json.hpp.

    +

    Definition at line 4374 of file json.hpp.

    @@ -308,7 +308,7 @@ false diff --git a/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html b/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html index e07329b6c..05d863bcd 100644 --- a/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html +++ b/classnlohmann_1_1basic__json_a92fbb711a36b5ce78ee228b26787c034.html @@ -270,12 +270,12 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    reference to the element at key key
    Exceptions
    - +
    std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with null"
    std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with string"
    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:8601
    +
    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:8622
    Output (play with this example online):
    2
     
     {
    @@ -301,7 +301,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 3244 of file json.hpp.

    +

    Definition at line 3245 of file json.hpp.

    @@ -311,7 +311,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 b8bc731de..e639d8d88 100644 --- a/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html +++ b/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html @@ -277,7 +277,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 2176289b0..68644fbfd 100644 --- a/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html +++ b/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html @@ -273,7 +273,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:8601
    +
    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:8622
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -281,7 +281,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 4727 of file json.hpp.

    +

    Definition at line 4748 of file json.hpp.

    @@ -291,7 +291,7 @@ null diff --git a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html index 403b0785e..2785b712a 100644 --- a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html +++ b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html @@ -279,7 +279,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:8601
    +
    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:8622

    Output (play with this example online):

    [1,2,3] == nullptr false
     {"A":"a","B":"b"} == nullptr false
     17 == nullptr false
    @@ -287,7 +287,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 5239 of file json.hpp.

    +

    Definition at line 5260 of file json.hpp.

    @@ -297,7 +297,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html b/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html index 4ca2e36dc..bc5987ed9 100644 --- a/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html +++ b/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html @@ -278,7 +278,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. 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 constructing a JSON value from a std::stringstream 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  // create JSON from stream
    30  json j_complete(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  // create JSON from stream (with callback)
    53  json j_filtered(ss, cb);
    54  std::cout << std::setw(4) << j_filtered << '\n';
    55 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    Example
    The example below demonstrates constructing a JSON value from a std::stringstream 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  // create JSON from stream
    30  json j_complete(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  // create JSON from stream (with callback)
    53  json j_filtered(ss, cb);
    54  std::cout << std::setw(4) << j_filtered << '\n';
    55 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    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:831
    @@ -329,7 +329,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html index 356f396e9..82ff4e6f6 100644 --- a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html +++ b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html @@ -279,7 +279,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:8601
    +
    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:8622

    Output (play with this example online):

    [1,2,3] == nullptr false
     {"A":"a","B":"b"} == nullptr false
     17 == nullptr false
    @@ -287,7 +287,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 5248 of file json.hpp.

    +

    Definition at line 5269 of file json.hpp.

    @@ -297,7 +297,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html b/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html index abbcc2810..ff5f4ad86 100644 --- a/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html +++ b/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html @@ -275,12 +275,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:8601
    +
    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:8622
    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 3203 of file json.hpp.

    +

    Definition at line 3204 of file json.hpp.

    @@ -290,7 +290,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html b/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html index fe961637d..dfabbf870 100644 --- a/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html +++ b/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html @@ -273,7 +273,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -290,7 +290,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 6271034bb..6a7afcbad 100644 --- a/classnlohmann_1_1basic__json_a9c01092601b6229eee4f971aad263133.html +++ b/classnlohmann_1_1basic__json_a9c01092601b6229eee4f971aad263133.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    crend() – returns a const reverse iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4181 of file json.hpp.

    +

    Definition at line 4202 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html b/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html index 380660de7..b93b73f22 100644 --- a/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html +++ b/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html @@ -258,7 +258,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 15c8e06ea..436686130 100644 --- a/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html +++ b/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html @@ -292,7 +292,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 e954615ad..d66a85bd6 100644 --- a/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html +++ b/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html @@ -266,7 +266,8 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Returns
    Number of elements removed. If ObjectType is the default std::map type, the return value will always be 0 (key was not found) or 1 (key was found).
    +
    Returns
    Number of elements removed. If ObjectType is the default std::map type, the return value will always be 0 (key was not found) or 1 (key was found).
    +
    Postcondition
    References and iterators to the erased elements are invalidated. Other references and iterators are not affected.
    Exceptions
    @@ -274,7 +275,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:8601
    +
    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:8622
    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 
    @@ -285,7 +286,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 3869 of file json.hpp.

    +

    Definition at line 3880 of file json.hpp.

    @@ -295,7 +296,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 e1c02673d..93bf82ef8 100644 --- a/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html +++ b/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html @@ -258,7 +258,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 5d55e9730..8c57e7cc0 100644 --- a/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html +++ b/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html @@ -269,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    std::domain_errorwhen called on a type other than JSON object; example: "cannot use erase() with null"
    -
    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'; // undefined behavior
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // undefined behavior
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    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'; // undefined behavior
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // undefined behavior
    27  std::cout << j_string.front() << '\n';
    28 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -282,7 +282,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    back() – access the last element
    Since
    version 1.0.0
    -

    Definition at line 3574 of file json.hpp.

    +

    Definition at line 3575 of file json.hpp.

    @@ -292,7 +292,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 335b379b3..875b12aac 100644 --- a/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html +++ b/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html @@ -276,7 +276,7 @@ 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:8601
    +
    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:8622
    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
    @@ -294,7 +294,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 d0f7d5cc1..809a9991c 100644 --- a/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html +++ b/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.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:8601
    +
    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:8622
    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.1.0
    -

    Definition at line 3452 of file json.hpp.

    +

    Definition at line 3453 of file json.hpp.

    @@ -296,7 +296,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html b/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html index e04c16289..b243b74f5 100644 --- a/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html +++ b/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html @@ -268,14 +268,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:8601
    +
    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:8622
    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 3960 of file json.hpp.

    +

    Definition at line 3981 of file json.hpp.

    @@ -285,7 +285,7 @@ value at key "two": 2 diff --git a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html index 2a0c9f960..ef0bcdd92 100644 --- a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html +++ b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html @@ -275,7 +275,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    -

    Definition at line 5093 of file json.hpp.

    +

    Definition at line 5114 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_aacd442b66140c764c594ac8ad7dfd5b3.html b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html index c250d1e40..b378fa810 100644 --- a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html +++ b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html @@ -283,7 +283,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:8601
    +
    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:8622
    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
    @@ -291,7 +291,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 5330 of file json.hpp.

    +

    Definition at line 5351 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_aadb4e5be88221e5e28cdb752332f3d13.html b/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html index 13b5b9780..360af4d48 100644 --- a/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html +++ b/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html @@ -286,13 +286,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:8601
    +
    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:8622
    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 4922 of file json.hpp.

    +

    Definition at line 4943 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_aaf363408931d76472ded14017e59c9e8.html b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html index 7e9cbc261..ea8e0e6c7 100644 --- a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html +++ b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html @@ -285,7 +285,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:8601
    +
    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:8622
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -303,7 +303,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 5644 of file json.hpp.

    +

    Definition at line 5665 of file json.hpp.

    @@ -313,7 +313,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 430e51a2a..b6709d819 100644 --- a/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html +++ b/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html @@ -280,7 +280,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 920f6bd0b..59add7259 100644 --- a/classnlohmann_1_1basic__json_ab31368c0b67f8e4f291a45e6498018be.html +++ b/classnlohmann_1_1basic__json_ab31368c0b67f8e4f291a45e6498018be.html @@ -275,7 +275,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -291,7 +291,7 @@ out of range
    diff --git a/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html b/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html index ebfb57813..c354a5f89 100644 --- a/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html +++ b/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html @@ -278,7 +278,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 365c92f0a..d0fe9c416 100644 --- a/classnlohmann_1_1basic__json_ab7b7b44891ddbc2df8ba3cbef3609178.html +++ b/classnlohmann_1_1basic__json_ab7b7b44891ddbc2df8ba3cbef3609178.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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
    @@ -289,7 +289,7 @@ true
     
    diff --git a/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html b/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html index cecf6da96..81a592eb3 100644 --- a/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html +++ b/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html @@ -281,7 +281,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:8601
    +
    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:8622
    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}
    @@ -300,7 +300,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 b11aa46f5..3600fc131 100644 --- a/classnlohmann_1_1basic__json_ab7d704826813d13731fbcaf220160826.html +++ b/classnlohmann_1_1basic__json_ab7d704826813d13731fbcaf220160826.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -288,7 +288,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html b/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html index 1500f2e5e..b0e91387c 100644 --- a/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html +++ b/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html @@ -279,8 +279,8 @@ 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:8601
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5569
    +
    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:8622
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5590
    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:831
    @@ -322,7 +322,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 5606 of file json.hpp.

    +

    Definition at line 5627 of file json.hpp.

    @@ -332,7 +332,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 aaea39444..5ff970dbd 100644 --- a/classnlohmann_1_1basic__json_ab856bebfdfbcf45061f1474ea8ba9924.html +++ b/classnlohmann_1_1basic__json_ab856bebfdfbcf45061f1474ea8ba9924.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    true
     true
     true
    @@ -292,7 +292,7 @@ true
     
    diff --git a/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html b/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html index d01aa5f6b..1e7986af3 100644 --- a/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html +++ b/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html @@ -273,7 +273,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -292,7 +292,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 397c7fa87..08670dd9b 100644 --- a/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html +++ b/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html @@ -262,7 +262,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 4297 of file json.hpp.

    +

    Definition at line 4318 of file json.hpp.

    @@ -272,7 +272,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 64792d6b7..d3f0adee5 100644 --- a/classnlohmann_1_1basic__json_abb5df282f9edf9cca898c6b8a9911111.html +++ b/classnlohmann_1_1basic__json_abb5df282f9edf9cca898c6b8a9911111.html @@ -265,7 +265,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:8601
    +
    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:8622
    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
    @@ -279,7 +279,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 4c9542f09..e3876d7bb 100644 --- a/classnlohmann_1_1basic__json_abc13258393358cb75a32fac86480bc9c.html +++ b/classnlohmann_1_1basic__json_abc13258393358cb75a32fac86480bc9c.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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 
    See also
    end() – returns an iterator to the end
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    cbegin() – returns a const iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4113 of file json.hpp.

    +

    Definition at line 4134 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html b/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html index 087a36078..6fbf342cb 100644 --- a/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html +++ b/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html @@ -285,7 +285,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 4143c07d0..899382a1e 100644 --- a/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html +++ b/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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
    @@ -289,7 +289,7 @@ true
     
    diff --git a/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html b/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html index d0b20a1f0..03094de3b 100644 --- a/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html +++ b/classnlohmann_1_1basic__json_ac7c006e2345a76859c4802db7d130e0e.html @@ -272,12 +272,12 @@ template<typename T >
    Returns
    reference to the element at key key
    Exceptions
    - +
    std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with null"
    std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with string"
    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:8601
    +
    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:8622
    Output (play with this example online):
    2
     
     {
    @@ -303,7 +303,7 @@ template<typename T > 
    value() for access by value with a default value
    Since
    version 1.1.0
    -

    Definition at line 3403 of file json.hpp.

    +

    Definition at line 3404 of file json.hpp.

    @@ -313,7 +313,7 @@ template<typename T > diff --git a/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html b/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html index 1bd1dfd5f..caeaf36f6 100644 --- a/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html +++ b/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html @@ -258,7 +258,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 bbd94f291..4d3ef7771 100644 --- a/classnlohmann_1_1basic__json_acbc1c415072afe69b5e69b87f496e44b.html +++ b/classnlohmann_1_1basic__json_acbc1c415072afe69b5e69b87f496e44b.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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 
    See also
    begin() – returns an iterator to the beginning
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    cend() – returns a const iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4072 of file json.hpp.

    +

    Definition at line 4093 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html b/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html index 61de7e911..256c760ee 100644 --- a/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html +++ b/classnlohmann_1_1basic__json_ad09218e192a80ffa8df531941afdab60.html @@ -261,7 +261,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:8601
    +
    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:8622
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    @@ -289,7 +289,7 @@ true
    diff --git a/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html b/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html index ed99c7922..e11f8c7fc 100644 --- a/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html +++ b/classnlohmann_1_1basic__json_ad101425649dbc5c2e851fdb52c31741d.html @@ -269,7 +269,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    crbegin() – returns a const reverse iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4210 of file json.hpp.

    +

    Definition at line 4231 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html b/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html index 329701f75..cd0551a99 100644 --- a/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html +++ b/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html @@ -276,7 +276,7 @@ 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:1656
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    Output (play with this example online):
    {}
     {}
     {"one":1,"two":2}
    @@ -296,7 +296,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 a9082f527..80e94b6a5 100644
    --- a/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html
    +++ b/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html
    @@ -275,7 +275,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if<
       
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of several 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:8601
    +
    Example
    The example below shows the construction of several 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:8622
    Output (play with this example online):
    42
     23
     1024
    @@ -297,7 +297,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 de88e49fc..0c7deef65 100644 --- a/classnlohmann_1_1basic__json_ad2f716992118a42aa8f8d57950a8d0bb.html +++ b/classnlohmann_1_1basic__json_ad2f716992118a42aa8f8d57950a8d0bb.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -283,7 +283,7 @@ true
     
    diff --git a/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html b/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html index e8a5d2d8f..4732a3efc 100644 --- a/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html +++ b/classnlohmann_1_1basic__json_ad534f6d0d48bfd1d85f72d7f1b62a46d.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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 
    See also
    begin() – returns an iterator to the beginning
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    cend() – returns a const iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4042 of file json.hpp.

    +

    Definition at line 4063 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html b/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html index ddf58540f..1a94744fc 100644 --- a/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html +++ b/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html @@ -282,7 +282,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:8601
    +
    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:8622
    Output (play with this example online):
    0
     1
     1
    @@ -294,7 +294,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    size() – returns the number of elements
    Since
    version 1.0.0
    -

    Definition at line 4482 of file json.hpp.

    +

    Definition at line 4503 of file json.hpp.

    @@ -304,7 +304,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 211d19beb..5ff8cb6d9 100644 --- a/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html +++ b/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html @@ -277,7 +277,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:8601
    +
    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:8622
    Output (play with this example online):
    null
     false
     0
    @@ -288,7 +288,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 4541 of file json.hpp.

    +

    Definition at line 4562 of file json.hpp.

    @@ -298,7 +298,7 @@ false diff --git a/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html b/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html index 4be1a947a..cc5132bc9 100644 --- a/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html +++ b/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html @@ -279,7 +279,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:8601
    +
    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:8622
    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
    @@ -287,7 +287,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3370 of file json.hpp.

    +

    Definition at line 3371 of file json.hpp.

    @@ -297,7 +297,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html b/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html index 82d41c1b5..e086353f9 100644 --- a/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html +++ b/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html @@ -261,7 +261,7 @@ 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:8601
    +
    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:8622
    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)
    @@ -277,7 +277,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 2e8abe427..c06d12430 100644 --- a/classnlohmann_1_1basic__json_ae129dc8ccd58cc3c64614db7d40a7dc9.html +++ b/classnlohmann_1_1basic__json_ae129dc8ccd58cc3c64614db7d40a7dc9.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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 
    See also
    end() – returns an iterator to the end
    @@ -280,7 +280,7 @@ Illustration from cppreference.com
    cbegin() – returns a const iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4143 of file json.hpp.

    +

    Definition at line 4164 of file json.hpp.

    @@ -290,7 +290,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html b/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html index d943e6a29..52f54c553 100644 --- a/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html +++ b/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html @@ -258,7 +258,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 f656ed444..e271ce9fd 100644 --- a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html +++ b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html @@ -279,7 +279,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:8601
    +
    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:8622

    Output (play with this example online):

    [1,2,3] != nullptr true
     {"A":"a","B":"b"} != nullptr true
     17 != nullptr true
    @@ -287,7 +287,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 5292 of file json.hpp.

    +

    Definition at line 5313 of file json.hpp.

    @@ -297,7 +297,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html b/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html index bb8466abd..348705b71 100644 --- a/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html +++ b/classnlohmann_1_1basic__json_ae799491eda5f5868a38ccdafca9fe0f0.html @@ -267,7 +267,7 @@ 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:8601
    +
    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:8622
    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 
    @@ -283,7 +283,7 @@ false
    diff --git a/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html b/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html index 296a2e87e..12a7435b5 100644 --- a/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html +++ b/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html @@ -281,7 +281,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:8601
    +
    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:8622
    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
    @@ -299,7 +299,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 2a69b3bb4..b6ff96481 100644 --- a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html +++ b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html @@ -288,7 +288,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 8b3b793ad..2a5fbf352 100644 --- a/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html +++ b/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html @@ -296,13 +296,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:8601
    +
    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:8622
    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 4864 of file json.hpp.

    +

    Definition at line 4885 of file json.hpp.

    @@ -312,7 +312,7 @@ belong to container" diff --git a/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html b/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html index 05448f3e7..c75fcdfd4 100644 --- a/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html +++ b/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html @@ -258,7 +258,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 9b13595bf..22ef2811d 100644 --- a/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html +++ b/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html @@ -275,7 +275,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:8601
    +
    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:8622
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -300,7 +300,7 @@ array: [1,2,3,4,5]
     
    diff --git a/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html b/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html index 45ddf18a2..6e808086b 100644 --- a/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html +++ b/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html @@ -295,7 +295,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:8601
    +
    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:8622
    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
    @@ -303,7 +303,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3545 of file json.hpp.

    +

    Definition at line 3546 of file json.hpp.

    @@ -313,7 +313,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html b/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html index 39e467b2a..c846aa123 100644 --- a/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html +++ b/classnlohmann_1_1basic__json_af12127e6fe8adbe727081f188aa599e2.html @@ -270,7 +270,7 @@ 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:8601
    +
    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:8622
    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
    @@ -288,7 +288,7 @@ true
     
    diff --git a/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html b/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html index a78b3a857..a1853d461 100644 --- a/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html +++ b/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html @@ -262,7 +262,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 4305 of file json.hpp.

    +

    Definition at line 4326 of file json.hpp.

    @@ -272,7 +272,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 f3c417c92..f960f2434 100644 --- a/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html +++ b/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html @@ -265,7 +265,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 a29ab65cd..3cebec6e3 100644 --- a/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html +++ b/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html @@ -258,7 +258,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 6a542a6a5..d81564b44 100644 --- a/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html +++ b/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html @@ -267,13 +267,13 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped with swap().
    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:8601
    +
    Example
    The example below shows how JSON values can be swapped with swap().
    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:8622
    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 4960 of file json.hpp.

    +

    Definition at line 4981 of file json.hpp.

    @@ -283,7 +283,7 @@ j2 = [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html b/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html index d1732ee5a..5f1317dee 100644 --- a/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html +++ b/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html @@ -300,7 +300,7 @@ 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:8601
    +
    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:8622
    Output (play with this example online):
    ["bravo","charly"]
     42
     {"one":"eins"}
    @@ -317,7 +317,7 @@ construct with iterators from null"
     
    diff --git a/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html b/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html index 9c34e5148..ca565b029 100644 --- a/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html +++ b/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html @@ -309,7 +309,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:8601
    +
    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:8622
    Output (play with this example online):
    {}
     {"one":1,"two":2}
     [1,2,3,4]
    @@ -331,7 +331,7 @@ initializer list"
     
    diff --git a/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html b/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html index e71fdac5a..7c6872254 100644 --- a/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html +++ b/classnlohmann_1_1basic__json_afec7d87796b8b538119b3ddc0d6950fb.html @@ -261,7 +261,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:8601
    +
    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:8622
    Output (play with this example online):
    false
     false
     false
    @@ -288,7 +288,7 @@ false
     
    diff --git a/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html b/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html index 6b0016b08..1e742a00e 100644 --- a/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html +++ b/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html @@ -268,14 +268,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:8601
    +
    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:8622
    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 3943 of file json.hpp.

    +

    Definition at line 3964 of file json.hpp.

    @@ -285,7 +285,7 @@ value at key "two": 2 diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 93dd318d2..49cd01eb3 100644 --- a/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -92,7 +92,7 @@ Files diff --git a/functions.html b/functions.html index 991857357..861bba783 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 1f0ac6246..272b082dc 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 105f01f23..c08b64352 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 d05d0648d..06de6c500 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 c5f3b3cd4..2a6f84350 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 ed1a74cc7..cfbf32d4b 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 a656e10bf..b47be8afc 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 cf86f2f1a..dd311fd07 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 c33497dd9..df4e6ead7 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 f108793c6..c251e8a54 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 d55b2e5cd..0e47cbebc 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 1497e1903..3c1a666d3 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 29e30d214..9016e3637 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 0ffe8977d..1a4a299b4 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 d4ecbb0c1..463542f84 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 4a184f5ad..0e18a061e 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 e8b9eea44..1a10c097a 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 1a255fc76..731dc425c 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 f70cf13dc..d07b10c78 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 a4ae69d36..b1a7f2987 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 458dc88bd..d0821b350 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 d922916ec..a0ba866c5 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 587fee0af..470d0ea60 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 9d6dc980f..03a50f3b3 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 f6715204d..eb69d458e 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 07b5448fe..5ffe0b825 100644 --- a/index.html +++ b/index.html @@ -80,6 +80,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

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

    +

    Contents

    • basic_json class
    • Functions
        @@ -97,37 +98,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
      • operator ValueType – get a value (implicit conversion)
    • -
    • element access
        -
      • at – access array element with bounds checking
      • -
      • at – access object element with bounds checking
      • -
      • operator[] – access array element
      • -
      • operator[] – access object element
      • -
      • value – access object element with default value
      • -
      • front – access the first element
      • -
      • back – access the last element
      • -
      -
    • -
    • iterators
        -
      • begin, cbegin
      • -
      • end, cend
      • -
      • rbegin, crbegin
      • -
      • rend, crend
      • -
      -
    • -
    • capacity
        -
      • empty – checks whether the container is empty
      • -
      • size – returns the number of elements
      • -
      • max_size – returns the maximum possible number of elements
      • -
      -
    • -
    • modifiers -
    • lexicographical comparison operators
    • serialization
    • deserialization
    • @@ -147,6 +117,61 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    +

    Container function overview

    +

    The container functions known from STL have been extended to support the different value types from JSON. However, not all functions can be applied to all value types. Note that the signature of some functions differ between the types; for instance, at may be called with either a string to address a key in an object or with an integer to address a value in an array.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    group function JSON value type
    object array string number boolean null
    iterators begin begin begin begin begin begin begin (returns end())
    cbegin cbegin cbegin cbegin cbegin cbegin cbegin (returns cend())
    end end end end end end end
    cend cend cend cend cend cend cend
    rbegin rbegin rbegin rbegin rbegin rbegin rbegin
    crbegin crbegin crbegin crbegin crbegin crbegin crbegin
    rend rend rend rend rend rend rend
    crend crend crend crend crend crend crend
    element
    +access
    at at at throws std::domain_error throws std::domain_error throws std::domain_error throws std::domain_error
    operator[] operator[] operator[] throws std::domain_error throws std::domain_error throws std::domain_error operator[] (creates object)
    +operator[] (creates array)
    front front front front front front throws std::out_of_range
    back back back back back back throws std::out_of_range
    capacity empty empty empty empty (returns false) empty (returns false) empty (returns false) empty (returns true)
    size size size size (returns 1) size (returns 1) size (returns 1) size (returns 0)
    max_size_ max_size max_size max_size (returns 1) max_size (returns 1) max_size (returns 1) max_size (returns 0)
    modifiers clear clear clear clear clear clear clear
    insert throws std::domain_error insert throws std::domain_error throws std::domain_error throws std::domain_error throws std::domain_error
    erase erase erase erase (converts to null) erase (converts to null) erase (converts to null) throws
    push_back push_back push_back throws std::domain_error throws std::domain_error throws std::domain_error push_back (creates object)
    +push_back (creates array)
    swap swap swap swap swap swap swap
    lookup find find (returns end()) find find (returns end()) find (returns end()) find (returns end()) find (returns end())
    count count (returns 0) count count (returns 0) count (returns 0) count (returns 0) count (returns 0)
    Author
    Niels Lohmann
    See also
    https://github.com/nlohmann/json to download the source code
    @@ -154,7 +179,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    diff --git a/index_8md_source.html b/index_8md_source.html index cd6b1c611..e51c04735 100644 --- a/index_8md_source.html +++ b/index_8md_source.html @@ -79,10 +79,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    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 - [Functions](functions_func.html)
    7  - object inspection
    8  - @link nlohmann::basic_json::dump dump @endlink -- value serialization
    9  - @link nlohmann::basic_json::type type @endlink -- type of the value
    10  - @link nlohmann::basic_json::is_primitive is_primitive @endlink,
    11  @link nlohmann::basic_json::is_structured is_structured @endlink,
    12  @link nlohmann::basic_json::is_null is_null @endlink,
    13  @link nlohmann::basic_json::is_boolean is_boolean @endlink,
    14  @link nlohmann::basic_json::is_number is_number @endlink,
    15  @link nlohmann::basic_json::is_number_integer is_number_integer @endlink,
    16  @link nlohmann::basic_json::is_number_unsigned is_number_unsigned @endlink,
    17  @link nlohmann::basic_json::is_number_float is_number_float @endlink,
    18  @link nlohmann::basic_json::is_object is_object @endlink,
    19  @link nlohmann::basic_json::is_array is_array @endlink,
    20  @link nlohmann::basic_json::is_string is_string @endlink,
    21  @link nlohmann::basic_json::is_discarded is_discarded @endlink -- check for value type
    22  - @link nlohmann::basic_json::operator value_t() const operator value_t @endlink -- type of the value (implicit conversion)
    23  - value access
    24  - @link nlohmann::basic_json::get get @endlink -- get a value
    25  - @link nlohmann::basic_json::get_ptr get_ptr @endlink -- get a value pointer
    26  - @link nlohmann::basic_json::get_ref get_ref @endlink -- get a value reference
    27  - @link nlohmann::basic_json::operator ValueType() const operator ValueType @endlink -- get a value (implicit conversion)
    28  - element access
    29  - @link nlohmann::basic_json::at(size_type) at @endlink -- access array element with bounds checking
    30  - @link nlohmann::basic_json::at(const typename object_t::key_type & key) at @endlink -- access object element with bounds checking
    31  - @link nlohmann::basic_json::operator[](size_type) operator[] @endlink -- access array element
    32  - @link nlohmann::basic_json::operator[](const typename object_t::key_type & key) operator[] @endlink -- access object element
    33  - @link nlohmann::basic_json::value value @endlink -- access object element with default value
    34  - @link nlohmann::basic_json::front front @endlink -- access the first element
    35  - @link nlohmann::basic_json::back back @endlink -- access the last element
    36  - iterators
    37  - begin, cbegin
    38  - end, cend
    39  - rbegin, crbegin
    40  - rend, crend
    41  - capacity
    42  - @link nlohmann::basic_json::empty empty @endlink -- checks whether the container is empty
    43  - @link nlohmann::basic_json::size size @endlink -- returns the number of elements
    44  - @link nlohmann::basic_json::max_size max_size @endlink -- returns the maximum possible number of elements
    45  - modifiers
    46  - @link nlohmann::basic_json::clear clear @endlink -- clears the contents
    47  - @link nlohmann::basic_json::push_back(const nlohmann::basic_json &) push_back @endlink -- add an object to an array
    48  - @link nlohmann::basic_json::operator+=(const nlohmann::basic_json &) operator+= @endlink -- add an object to an array
    49  - @link nlohmann::basic_json::insert insert @endlink -- inserts elements
    50  - @link nlohmann::basic_json::swap swap @endlink -- exchanges the values
    51  - lexicographical comparison operators
    52  - serialization
    53  - deserialization
    54 - Types
    55  - @link nlohmann::basic_json::array_t arrays @endlink
    56  - @link nlohmann::basic_json::object_t objects @endlink
    57  - @link nlohmann::basic_json::string_t strings @endlink
    58  - @link nlohmann::basic_json::boolean_t booleans @endlink
    59  - numbers
    60  - @link nlohmann::basic_json::number_integer_t signed integers @endlink
    61  - @link nlohmann::basic_json::number_unsigned_t unsigned integers @endlink
    62  - @link nlohmann::basic_json::number_float_t floating-point @endlink
    63 
    64 @copyright Copyright &copy; 2013-2016 Niels Lohmann. The code is licensed under the [MIT License](http://opensource.org/licenses/MIT).
    65 
    66 @author [Niels Lohmann](http://nlohmann.me)
    67 @see https://github.com/nlohmann/json to download the source code
    68 
    69 @version 2.0.0
    +
    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 # Contents
    6 
    7 - @link nlohmann::basic_json `basic_json` class @endlink
    8 - [Functions](functions_func.html)
    9  - object inspection
    10  - @link nlohmann::basic_json::dump dump @endlink -- value serialization
    11  - @link nlohmann::basic_json::type type @endlink -- type of the value
    12  - @link nlohmann::basic_json::is_primitive is_primitive @endlink,
    13  @link nlohmann::basic_json::is_structured is_structured @endlink,
    14  @link nlohmann::basic_json::is_null is_null @endlink,
    15  @link nlohmann::basic_json::is_boolean is_boolean @endlink,
    16  @link nlohmann::basic_json::is_number is_number @endlink,
    17  @link nlohmann::basic_json::is_number_integer is_number_integer @endlink,
    18  @link nlohmann::basic_json::is_number_unsigned is_number_unsigned @endlink,
    19  @link nlohmann::basic_json::is_number_float is_number_float @endlink,
    20  @link nlohmann::basic_json::is_object is_object @endlink,
    21  @link nlohmann::basic_json::is_array is_array @endlink,
    22  @link nlohmann::basic_json::is_string is_string @endlink,
    23  @link nlohmann::basic_json::is_discarded is_discarded @endlink -- check for value type
    24  - @link nlohmann::basic_json::operator value_t() const operator value_t @endlink -- type of the value (implicit conversion)
    25  - value access
    26  - @link nlohmann::basic_json::get get @endlink -- get a value
    27  - @link nlohmann::basic_json::get_ptr get_ptr @endlink -- get a value pointer
    28  - @link nlohmann::basic_json::get_ref get_ref @endlink -- get a value reference
    29  - @link nlohmann::basic_json::operator ValueType() const operator ValueType @endlink -- get a value (implicit conversion)
    30  - lexicographical comparison operators
    31  - serialization
    32  - deserialization
    33 - Types
    34  - @link nlohmann::basic_json::array_t arrays @endlink
    35  - @link nlohmann::basic_json::object_t objects @endlink
    36  - @link nlohmann::basic_json::string_t strings @endlink
    37  - @link nlohmann::basic_json::boolean_t booleans @endlink
    38  - numbers
    39  - @link nlohmann::basic_json::number_integer_t signed integers @endlink
    40  - @link nlohmann::basic_json::number_unsigned_t unsigned integers @endlink
    41  - @link nlohmann::basic_json::number_float_t floating-point @endlink
    42 
    43 # Container function overview
    44 
    45 The container functions known from STL have been extended to support the different value types from JSON. However, not all functions can be applied to all value types. Note that the signature of some functions differ between the types; for instance, `at` may be called with either a string to address a key in an object or with an integer to address a value in an array.
    46 
    47 <table>
    48  <tr>
    49  <th rowspan="2">group</td>
    50  <th rowspan="2">function</td>
    51  <th colspan="6">JSON value type</th>
    52  </tr>
    53  <tr>
    54  <th>object</th>
    55  <th>array</th>
    56  <th>string</th>
    57  <th>number</th>
    58  <th>boolean</th>
    59  <th>null</th>
    60  </tr>
    61  <tr>
    62  <td rowspan="8">iterators</td>
    63  <td>`begin`</td>
    64  <td class="ok_green">@link nlohmann::basic_json::begin `begin` @endlink</td>
    65  <td class="ok_green">@link nlohmann::basic_json::begin `begin` @endlink</td>
    66  <td class="ok_green">@link nlohmann::basic_json::begin `begin` @endlink</td>
    67  <td class="ok_green">@link nlohmann::basic_json::begin `begin` @endlink</td>
    68  <td class="ok_green">@link nlohmann::basic_json::begin `begin` @endlink</td>
    69  <td class="ok_green">@link nlohmann::basic_json::begin `begin` @endlink (returns `end()`)</td>
    70  </tr>
    71  <tr>
    72  <td>`cbegin`</td>
    73  <td class="ok_green">@link nlohmann::basic_json::cbegin `cbegin` @endlink</td>
    74  <td class="ok_green">@link nlohmann::basic_json::cbegin `cbegin` @endlink</td>
    75  <td class="ok_green">@link nlohmann::basic_json::cbegin `cbegin` @endlink</td>
    76  <td class="ok_green">@link nlohmann::basic_json::cbegin `cbegin` @endlink</td>
    77  <td class="ok_green">@link nlohmann::basic_json::cbegin `cbegin` @endlink</td>
    78  <td class="ok_green">@link nlohmann::basic_json::cbegin `cbegin` @endlink (returns `cend()`)</td>
    79  </tr>
    80  <tr>
    81  <td>`end`</td>
    82  <td class="ok_green">@link nlohmann::basic_json::end `end` @endlink</td>
    83  <td class="ok_green">@link nlohmann::basic_json::end `end` @endlink</td>
    84  <td class="ok_green">@link nlohmann::basic_json::end `end` @endlink</td>
    85  <td class="ok_green">@link nlohmann::basic_json::end `end` @endlink</td>
    86  <td class="ok_green">@link nlohmann::basic_json::end `end` @endlink</td>
    87  <td class="ok_green">@link nlohmann::basic_json::end `end` @endlink</td>
    88  </tr>
    89  <tr>
    90  <td>`cend`</td>
    91  <td class="ok_green">@link nlohmann::basic_json::cend `cend` @endlink</td>
    92  <td class="ok_green">@link nlohmann::basic_json::cend `cend` @endlink</td>
    93  <td class="ok_green">@link nlohmann::basic_json::cend `cend` @endlink</td>
    94  <td class="ok_green">@link nlohmann::basic_json::cend `cend` @endlink</td>
    95  <td class="ok_green">@link nlohmann::basic_json::cend `cend` @endlink</td>
    96  <td class="ok_green">@link nlohmann::basic_json::cend `cend` @endlink</td>
    97  </tr>
    98  <tr>
    99  <td>`rbegin`</td>
    100  <td class="ok_green">@link nlohmann::basic_json::rbegin `rbegin` @endlink</td>
    101  <td class="ok_green">@link nlohmann::basic_json::rbegin `rbegin` @endlink</td>
    102  <td class="ok_green">@link nlohmann::basic_json::rbegin `rbegin` @endlink</td>
    103  <td class="ok_green">@link nlohmann::basic_json::rbegin `rbegin` @endlink</td>
    104  <td class="ok_green">@link nlohmann::basic_json::rbegin `rbegin` @endlink</td>
    105  <td class="ok_green">@link nlohmann::basic_json::rbegin `rbegin` @endlink</td>
    106  </tr>
    107  <tr>
    108  <td>`crbegin`</td>
    109  <td class="ok_green">@link nlohmann::basic_json::crbegin `crbegin` @endlink</td>
    110  <td class="ok_green">@link nlohmann::basic_json::crbegin `crbegin` @endlink</td>
    111  <td class="ok_green">@link nlohmann::basic_json::crbegin `crbegin` @endlink</td>
    112  <td class="ok_green">@link nlohmann::basic_json::crbegin `crbegin` @endlink</td>
    113  <td class="ok_green">@link nlohmann::basic_json::crbegin `crbegin` @endlink</td>
    114  <td class="ok_green">@link nlohmann::basic_json::crbegin `crbegin` @endlink</td>
    115  </tr>
    116  <tr>
    117  <td>`rend`</td>
    118  <td class="ok_green">@link nlohmann::basic_json::rend `rend` @endlink</td>
    119  <td class="ok_green">@link nlohmann::basic_json::rend `rend` @endlink</td>
    120  <td class="ok_green">@link nlohmann::basic_json::rend `rend` @endlink</td>
    121  <td class="ok_green">@link nlohmann::basic_json::rend `rend` @endlink</td>
    122  <td class="ok_green">@link nlohmann::basic_json::rend `rend` @endlink</td>
    123  <td class="ok_green">@link nlohmann::basic_json::rend `rend` @endlink</td>
    124  </tr>
    125  <tr>
    126  <td>`crend`</td>
    127  <td class="ok_green">@link nlohmann::basic_json::crend `crend` @endlink</td>
    128  <td class="ok_green">@link nlohmann::basic_json::crend `crend` @endlink</td>
    129  <td class="ok_green">@link nlohmann::basic_json::crend `crend` @endlink</td>
    130  <td class="ok_green">@link nlohmann::basic_json::crend `crend` @endlink</td>
    131  <td class="ok_green">@link nlohmann::basic_json::crend `crend` @endlink</td>
    132  <td class="ok_green">@link nlohmann::basic_json::crend `crend` @endlink</td>
    133  </tr>
    134  <tr>
    135  <td rowspan="4">element<br>access</td>
    136  <td>`at`</td>
    137  <td class="ok_green">@link nlohmann::basic_json::at(const typename object_t::key_type & key) `at` @endlink</td>
    138  <td class="ok_green">@link nlohmann::basic_json::at(size_type) `at` @endlink</td>
    139  <td class="nok_throws">throws `std::domain_error`</td>
    140  <td class="nok_throws">throws `std::domain_error`</td>
    141  <td class="nok_throws">throws `std::domain_error`</td>
    142  <td class="nok_throws">throws `std::domain_error`</td>
    143  </tr>
    144  <tr>
    145  <td>`operator[]`</td>
    146  <td class="ok_green">@link nlohmann::basic_json::operator[](const typename object_t::key_type &key) `operator[]` @endlink</td>
    147  <td class="ok_green">@link nlohmann::basic_json::operator[](size_type) `operator[]` @endlink</td>
    148  <td class="nok_throws">throws `std::domain_error`</td>
    149  <td class="nok_throws">throws `std::domain_error`</td>
    150  <td class="nok_throws">throws `std::domain_error`</td>
    151  <td class="ok_green">@link nlohmann::basic_json::operator[](const typename object_t::key_type & key) `operator[]` @endlink (creates object)<br>@link nlohmann::basic_json::operator[](size_type) `operator[]` @endlink (creates array)</td>
    152  </tr>
    153  <tr>
    154  <td>`front`</td>
    155  <td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
    156  <td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
    157  <td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
    158  <td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
    159  <td class="ok_green">@link nlohmann::basic_json::front `front` @endlink</td>
    160  <td class="nok_throws">throws `std::out_of_range`</td>
    161  </tr>
    162  <tr>
    163  <td>`back`</td>
    164  <td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
    165  <td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
    166  <td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
    167  <td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
    168  <td class="ok_green">@link nlohmann::basic_json::back `back` @endlink</td>
    169  <td class="nok_throws">throws `std::out_of_range`</td>
    170  </tr>
    171  <tr>
    172  <td rowspan="3">capacity</td>
    173  <td>`empty`</td>
    174  <td class="ok_green">@link nlohmann::basic_json::empty `empty` @endlink</td>
    175  <td class="ok_green">@link nlohmann::basic_json::empty `empty` @endlink</td>
    176  <td class="ok_green">@link nlohmann::basic_json::empty `empty` @endlink (returns `false`)</td>
    177  <td class="ok_green">@link nlohmann::basic_json::empty `empty` @endlink (returns `false`)</td>
    178  <td class="ok_green">@link nlohmann::basic_json::empty `empty` @endlink (returns `false`)</td>
    179  <td class="ok_green">@link nlohmann::basic_json::empty `empty` @endlink (returns `true`)</td>
    180  </tr>
    181  <tr>
    182  <td>`size`</td>
    183  <td class="ok_green">@link nlohmann::basic_json::size `size` @endlink</td>
    184  <td class="ok_green">@link nlohmann::basic_json::size `size` @endlink</td>
    185  <td class="ok_green">@link nlohmann::basic_json::size `size` @endlink (returns `1`)</td>
    186  <td class="ok_green">@link nlohmann::basic_json::size `size` @endlink (returns `1`)</td>
    187  <td class="ok_green">@link nlohmann::basic_json::size `size` @endlink (returns `1`)</td>
    188  <td class="ok_green">@link nlohmann::basic_json::size `size` @endlink (returns `0`)</td>
    189  </tr>
    190  <tr>
    191  <td>`max_size_`</td>
    192  <td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink</td>
    193  <td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink</td>
    194  <td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink (returns `1`)</td>
    195  <td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink (returns `1`)</td>
    196  <td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink (returns `1`)</td>
    197  <td class="ok_green">@link nlohmann::basic_json::max_size `max_size` @endlink (returns `0`)</td>
    198  </tr>
    199  <tr>
    200  <td rowspan="5">modifiers</td>
    201  <td>`clear`</td>
    202  <td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
    203  <td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
    204  <td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
    205  <td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
    206  <td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
    207  <td class="ok_green">@link nlohmann::basic_json::clear `clear` @endlink</td>
    208  </tr>
    209  <tr>
    210  <td>`insert`</td>
    211  <td class="nok_throws">throws `std::domain_error`</td>
    212  <td class="ok_green">@link nlohmann::basic_json::insert `insert` @endlink</td>
    213  <td class="nok_throws">throws `std::domain_error`</td>
    214  <td class="nok_throws">throws `std::domain_error`</td>
    215  <td class="nok_throws">throws `std::domain_error`</td>
    216  <td class="nok_throws">throws `std::domain_error`</td>
    217  </tr>
    218  <tr>
    219  <td>`erase`</td>
    220  <td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink</td>
    221  <td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink</td>
    222  <td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink (converts to null)</td>
    223  <td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink (converts to null)</td>
    224  <td class="ok_green">@link nlohmann::basic_json::erase `erase` @endlink (converts to null)</td>
    225  <td class="nok_throws">throws</td>
    226  </tr>
    227  <tr>
    228  <td>`push_back`</td>
    229  <td class="ok_green">@link nlohmann::basic_json::push_back(const typename object_t::value_type & val) `push_back` @endlink</td>
    230  <td class="ok_green">@link nlohmann::basic_json::push_back(const nlohmann::basic_json &) `push_back` @endlink</td>
    231  <td class="nok_throws">throws `std::domain_error`</td>
    232  <td class="nok_throws">throws `std::domain_error`</td>
    233  <td class="nok_throws">throws `std::domain_error`</td>
    234  <td class="ok_green">@link nlohmann::basic_json::push_back(const typename object_t::value_type & val) `push_back` @endlink (creates object)<br>@link nlohmann::basic_json::push_back(const nlohmann::basic_json &) `push_back` @endlink (creates array)</td>
    235  </tr>
    236  <tr>
    237  <td>`swap`</td>
    238  <td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
    239  <td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
    240  <td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
    241  <td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
    242  <td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
    243  <td class="ok_green">@link nlohmann::basic_json::swap `swap` @endlink</td>
    244  </tr>
    245  <tr>
    246  <td rowspan="2">lookup</td>
    247  <td>`find`</td>
    248  <td class="ok_green">@link nlohmann::basic_json::find `find` @endlink (returns `end()`)</td>
    249  <td class="ok_green">@link nlohmann::basic_json::find `find` @endlink</td>
    250  <td class="ok_green">@link nlohmann::basic_json::find `find` @endlink (returns `end()`)</td>
    251  <td class="ok_green">@link nlohmann::basic_json::find `find` @endlink (returns `end()`)</td>
    252  <td class="ok_green">@link nlohmann::basic_json::find `find` @endlink (returns `end()`)</td>
    253  <td class="ok_green">@link nlohmann::basic_json::find `find` @endlink (returns `end()`)</td>
    254  </tr>
    255  <tr>
    256  <td>`count`</td>
    257  <td class="ok_green">@link nlohmann::basic_json::count `count` @endlink (returns `0`)</td>
    258  <td class="ok_green">@link nlohmann::basic_json::count `count` @endlink</td>
    259  <td class="ok_green">@link nlohmann::basic_json::count `count` @endlink (returns `0`)</td>
    260  <td class="ok_green">@link nlohmann::basic_json::count `count` @endlink (returns `0`)</td>
    261  <td class="ok_green">@link nlohmann::basic_json::count `count` @endlink (returns `0`)</td>
    262  <td class="ok_green">@link nlohmann::basic_json::count `count` @endlink (returns `0`)</td>
    263  </tr>
    264 </table>
    265 
    266 @copyright Copyright &copy; 2013-2016 Niels Lohmann. The code is licensed under the [MIT License](http://opensource.org/licenses/MIT).
    267 
    268 @author [Niels Lohmann](http://nlohmann.me)
    269 @see https://github.com/nlohmann/json to download the source code
    270 
    271 @version 2.0.0
    diff --git a/json_8hpp_source.html b/json_8hpp_source.html index 73b4632c8..dd6fd02c2 100644 --- a/json_8hpp_source.html +++ b/json_8hpp_source.html @@ -83,222 +83,222 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    json.hpp
    -
    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 
    970  basic_json() noexcept = default;
    971 
    991  basic_json(std::nullptr_t) noexcept
    992  : basic_json(value_t::null)
    993  {}
    994 
    1014  basic_json(const object_t& val)
    1015  : m_type(value_t::object), m_value(val)
    1016  {}
    1017 
    1044  template <class CompatibleObjectType, typename
    1045  std::enable_if<
    1046  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    1047  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    1048  = 0>
    1049  basic_json(const CompatibleObjectType& val)
    1050  : m_type(value_t::object)
    1051  {
    1052  using std::begin;
    1053  using std::end;
    1054  m_value.object = create<object_t>(begin(val), end(val));
    1055  }
    1056 
    1076  basic_json(const array_t& val)
    1077  : m_type(value_t::array), m_value(val)
    1078  {}
    1079 
    1106  template <class CompatibleArrayType, typename
    1107  std::enable_if<
    1108  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1109  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1110  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1111  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1112  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1113  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1114  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1115  = 0>
    1116  basic_json(const CompatibleArrayType& val)
    1117  : m_type(value_t::array)
    1118  {
    1119  using std::begin;
    1120  using std::end;
    1121  m_value.array = create<array_t>(begin(val), end(val));
    1122  }
    1123 
    1145  basic_json(const string_t& val)
    1146  : m_type(value_t::string), m_value(val)
    1147  {}
    1148 
    1169  basic_json(const typename string_t::value_type* val)
    1170  : basic_json(string_t(val))
    1171  {}
    1172 
    1196  template <class CompatibleStringType, typename
    1197  std::enable_if<
    1198  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1199  = 0>
    1200  basic_json(const CompatibleStringType& val)
    1201  : basic_json(string_t(val))
    1202  {}
    1203 
    1219  : m_type(value_t::boolean), m_value(val)
    1220  {}
    1221 
    1245  template<typename T,
    1246  typename std::enable_if<
    1247  not (std::is_same<T, int>::value)
    1248  and std::is_same<T, number_integer_t>::value
    1249  , int>::type
    1250  = 0>
    1252  : m_type(value_t::number_integer), m_value(val)
    1253  {}
    1254 
    1280  basic_json(const int val)
    1281  : m_type(value_t::number_integer),
    1282  m_value(static_cast<number_integer_t>(val))
    1283  {}
    1284 
    1310  template<typename CompatibleNumberIntegerType, typename
    1311  std::enable_if<
    1312  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1313  std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
    1314  std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
    1315  CompatibleNumberIntegerType>::type
    1316  = 0>
    1317  basic_json(const CompatibleNumberIntegerType val) noexcept
    1318  : m_type(value_t::number_integer),
    1319  m_value(static_cast<number_integer_t>(val))
    1320  {}
    1321 
    1339  template<typename T,
    1340  typename std::enable_if<
    1341  not (std::is_same<T, int>::value)
    1342  and std::is_same<T, number_unsigned_t>::value
    1343  , int>::type
    1344  = 0>
    1346  : m_type(value_t::number_unsigned), m_value(val)
    1347  {}
    1348 
    1369  template < typename CompatibleNumberUnsignedType, typename
    1370  std::enable_if <
    1371  std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
    1372  std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
    1373  !std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
    1374  CompatibleNumberUnsignedType >::type
    1375  = 0 >
    1376  basic_json(const CompatibleNumberUnsignedType val) noexcept
    1377  : m_type(value_t::number_unsigned),
    1378  m_value(static_cast<number_unsigned_t>(val))
    1379  {}
    1380 
    1406  : m_type(value_t::number_float), m_value(val)
    1407  {
    1408  // replace infinity and NAN by null
    1409  if (not std::isfinite(val))
    1410  {
    1411  m_type = value_t::null;
    1412  m_value = json_value();
    1413  }
    1414  }
    1415 
    1446  template<typename CompatibleNumberFloatType, typename = typename
    1447  std::enable_if<
    1448  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1449  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1450  >
    1451  basic_json(const CompatibleNumberFloatType val) noexcept
    1452  : basic_json(number_float_t(val))
    1453  {}
    1454 
    1524  basic_json(std::initializer_list<basic_json> init,
    1525  bool type_deduction = true,
    1526  value_t manual_type = value_t::array)
    1527  {
    1528  // the initializer list could describe an object
    1529  bool is_an_object = true;
    1530 
    1531  // check if each element is an array with two elements whose first
    1532  // element is a string
    1533  for (const auto& element : init)
    1534  {
    1535  if (not element.is_array() or element.size() != 2
    1536  or not element[0].is_string())
    1537  {
    1538  // we found an element that makes it impossible to use the
    1539  // initializer list as object
    1540  is_an_object = false;
    1541  break;
    1542  }
    1543  }
    1544 
    1545  // adjust type if type deduction is not wanted
    1546  if (not type_deduction)
    1547  {
    1548  // if array is wanted, do not create an object though possible
    1549  if (manual_type == value_t::array)
    1550  {
    1551  is_an_object = false;
    1552  }
    1553 
    1554  // if object is wanted but impossible, throw an exception
    1555  if (manual_type == value_t::object and not is_an_object)
    1556  {
    1557  throw std::domain_error("cannot create object from initializer list");
    1558  }
    1559  }
    1560 
    1561  if (is_an_object)
    1562  {
    1563  // the initializer list is a list of pairs -> create object
    1564  m_type = value_t::object;
    1565  m_value = value_t::object;
    1566 
    1567  assert(m_value.object != nullptr);
    1568 
    1569  for (auto& element : init)
    1570  {
    1571  m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1]));
    1572  }
    1573  }
    1574  else
    1575  {
    1576  // the initializer list describes an array -> create array
    1577  m_type = value_t::array;
    1578  m_value.array = create<array_t>(std::move(init));
    1579  }
    1580  }
    1581 
    1616  static basic_json array(std::initializer_list<basic_json> init =
    1617  std::initializer_list<basic_json>())
    1618  {
    1619  return basic_json(init, false, value_t::array);
    1620  }
    1621 
    1656  static basic_json object(std::initializer_list<basic_json> init =
    1657  std::initializer_list<basic_json>())
    1658  {
    1659  return basic_json(init, false, value_t::object);
    1660  }
    1661 
    1680  basic_json(size_type cnt, const basic_json& val)
    1681  : m_type(value_t::array)
    1682  {
    1683  m_value.array = create<array_t>(cnt, val);
    1684  }
    1685 
    1720  template <class InputIT, typename
    1721  std::enable_if<
    1722  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1723  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1724  , int>::type
    1725  = 0>
    1726  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1727  {
    1728  // make sure iterator fits the current value
    1729  if (first.m_object != last.m_object)
    1730  {
    1731  throw std::domain_error("iterators are not compatible");
    1732  }
    1733 
    1734  // check if iterator range is complete for primitive values
    1735  switch (m_type)
    1736  {
    1737  case value_t::boolean:
    1738  case value_t::number_float:
    1739  case value_t::number_integer:
    1740  case value_t::number_unsigned:
    1741  case value_t::string:
    1742  {
    1743  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1744  {
    1745  throw std::out_of_range("iterators out of range");
    1746  }
    1747  break;
    1748  }
    1749 
    1750  default:
    1751  {
    1752  break;
    1753  }
    1754  }
    1755 
    1756  switch (m_type)
    1757  {
    1758  case value_t::number_integer:
    1759  {
    1760  assert(first.m_object != nullptr);
    1761  m_value.number_integer = first.m_object->m_value.number_integer;
    1762  break;
    1763  }
    1764 
    1765  case value_t::number_unsigned:
    1766  {
    1767  assert(first.m_object != nullptr);
    1768  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
    1769  break;
    1770  }
    1771 
    1772  case value_t::number_float:
    1773  {
    1774  assert(first.m_object != nullptr);
    1775  m_value.number_float = first.m_object->m_value.number_float;
    1776  break;
    1777  }
    1778 
    1779  case value_t::boolean:
    1780  {
    1781  assert(first.m_object != nullptr);
    1782  m_value.boolean = first.m_object->m_value.boolean;
    1783  break;
    1784  }
    1785 
    1786  case value_t::string:
    1787  {
    1788  assert(first.m_object != nullptr);
    1789  m_value = *first.m_object->m_value.string;
    1790  break;
    1791  }
    1792 
    1793  case value_t::object:
    1794  {
    1795  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1796  break;
    1797  }
    1798 
    1799  case value_t::array:
    1800  {
    1801  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1802  break;
    1803  }
    1804 
    1805  default:
    1806  {
    1807  assert(first.m_object != nullptr);
    1808  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1809  }
    1810  }
    1811  }
    1812 
    1833  explicit basic_json(std::istream& i, parser_callback_t cb = nullptr)
    1834  {
    1835  *this = parser(i, cb).parse();
    1836  }
    1837 
    1839  // other constructors and destructor //
    1841 
    1864  basic_json(const basic_json& other)
    1865  : m_type(other.m_type)
    1866  {
    1867  switch (m_type)
    1868  {
    1869  case value_t::object:
    1870  {
    1871  assert(other.m_value.object != nullptr);
    1872  m_value = *other.m_value.object;
    1873  break;
    1874  }
    1875 
    1876  case value_t::array:
    1877  {
    1878  assert(other.m_value.array != nullptr);
    1879  m_value = *other.m_value.array;
    1880  break;
    1881  }
    1882 
    1883  case value_t::string:
    1884  {
    1885  assert(other.m_value.string != nullptr);
    1886  m_value = *other.m_value.string;
    1887  break;
    1888  }
    1889 
    1890  case value_t::boolean:
    1891  {
    1892  m_value = other.m_value.boolean;
    1893  break;
    1894  }
    1895 
    1896  case value_t::number_integer:
    1897  {
    1898  m_value = other.m_value.number_integer;
    1899  break;
    1900  }
    1901 
    1902  case value_t::number_unsigned:
    1903  {
    1904  m_value = other.m_value.number_unsigned;
    1905  break;
    1906  }
    1907 
    1908  case value_t::number_float:
    1909  {
    1910  m_value = other.m_value.number_float;
    1911  break;
    1912  }
    1913 
    1914  default:
    1915  {
    1916  break;
    1917  }
    1918  }
    1919  }
    1920 
    1939  basic_json(basic_json&& other) noexcept
    1940  : m_type(std::move(other.m_type)),
    1941  m_value(std::move(other.m_value))
    1942  {
    1943  // invalidate payload
    1944  other.m_type = value_t::null;
    1945  other.m_value = {};
    1946  }
    1947 
    1971  reference& operator=(basic_json other) noexcept (
    1972  std::is_nothrow_move_constructible<value_t>::value and
    1973  std::is_nothrow_move_assignable<value_t>::value and
    1974  std::is_nothrow_move_constructible<json_value>::value and
    1975  std::is_nothrow_move_assignable<json_value>::value
    1976  )
    1977  {
    1978  using std::swap;
    1979  swap(m_type, other.m_type);
    1980  swap(m_value, other.m_value);
    1981  return *this;
    1982  }
    1983 
    2000  {
    2001  switch (m_type)
    2002  {
    2003  case value_t::object:
    2004  {
    2005  AllocatorType<object_t> alloc;
    2006  alloc.destroy(m_value.object);
    2007  alloc.deallocate(m_value.object, 1);
    2008  break;
    2009  }
    2010 
    2011  case value_t::array:
    2012  {
    2013  AllocatorType<array_t> alloc;
    2014  alloc.destroy(m_value.array);
    2015  alloc.deallocate(m_value.array, 1);
    2016  break;
    2017  }
    2018 
    2019  case value_t::string:
    2020  {
    2021  AllocatorType<string_t> alloc;
    2022  alloc.destroy(m_value.string);
    2023  alloc.deallocate(m_value.string, 1);
    2024  break;
    2025  }
    2026 
    2027  default:
    2028  {
    2029  // all other types need no specific destructor
    2030  break;
    2031  }
    2032  }
    2033  }
    2034 
    2036 
    2037  public:
    2039  // object inspection //
    2041 
    2044 
    2068  string_t dump(const int indent = -1) const
    2069  {
    2070  std::stringstream ss;
    2071 
    2072  if (indent >= 0)
    2073  {
    2074  dump(ss, true, static_cast<unsigned int>(indent));
    2075  }
    2076  else
    2077  {
    2078  dump(ss, false, 0);
    2079  }
    2080 
    2081  return ss.str();
    2082  }
    2083 
    2099  value_t type() const noexcept
    2100  {
    2101  return m_type;
    2102  }
    2103 
    2126  bool is_primitive() const noexcept
    2127  {
    2128  return is_null() or is_string() or is_boolean() or is_number();
    2129  }
    2130 
    2150  bool is_structured() const noexcept
    2151  {
    2152  return is_array() or is_object();
    2153  }
    2154 
    2169  bool is_null() const noexcept
    2170  {
    2171  return m_type == value_t::null;
    2172  }
    2173 
    2188  bool is_boolean() const noexcept
    2189  {
    2190  return m_type == value_t::boolean;
    2191  }
    2192 
    2215  bool is_number() const noexcept
    2216  {
    2217  return is_number_integer() or is_number_float();
    2218  }
    2219 
    2241  bool is_number_integer() const noexcept
    2242  {
    2243  return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
    2244  }
    2245 
    2266  bool is_number_unsigned() const noexcept
    2267  {
    2268  return m_type == value_t::number_unsigned;
    2269  }
    2270 
    2291  bool is_number_float() const noexcept
    2292  {
    2293  return m_type == value_t::number_float;
    2294  }
    2295 
    2310  bool is_object() const noexcept
    2311  {
    2312  return m_type == value_t::object;
    2313  }
    2314 
    2329  bool is_array() const noexcept
    2330  {
    2331  return m_type == value_t::array;
    2332  }
    2333 
    2348  bool is_string() const noexcept
    2349  {
    2350  return m_type == value_t::string;
    2351  }
    2352 
    2372  bool is_discarded() const noexcept
    2373  {
    2374  return m_type == value_t::discarded;
    2375  }
    2376 
    2392  operator value_t() const noexcept
    2393  {
    2394  return m_type;
    2395  }
    2396 
    2398 
    2399  private:
    2401  // value access //
    2403 
    2405  template <class T, typename
    2406  std::enable_if<
    2407  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2408  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2409  , int>::type = 0>
    2410  T get_impl(T*) const
    2411  {
    2412  if (is_object())
    2413  {
    2414  assert(m_value.object != nullptr);
    2415  return T(m_value.object->begin(), m_value.object->end());
    2416  }
    2417  else
    2418  {
    2419  throw std::domain_error("type must be object, but is " + type_name());
    2420  }
    2421  }
    2422 
    2424  object_t get_impl(object_t*) const
    2425  {
    2426  if (is_object())
    2427  {
    2428  assert(m_value.object != nullptr);
    2429  return *(m_value.object);
    2430  }
    2431  else
    2432  {
    2433  throw std::domain_error("type must be object, but is " + type_name());
    2434  }
    2435  }
    2436 
    2438  template <class T, typename
    2439  std::enable_if<
    2440  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2441  not std::is_same<basic_json_t, typename T::value_type>::value and
    2442  not std::is_arithmetic<T>::value and
    2443  not std::is_convertible<std::string, T>::value and
    2444  not has_mapped_type<T>::value
    2445  , int>::type = 0>
    2446  T get_impl(T*) const
    2447  {
    2448  if (is_array())
    2449  {
    2450  T to_vector;
    2451  assert(m_value.array != nullptr);
    2452  std::transform(m_value.array->begin(), m_value.array->end(),
    2453  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2454  {
    2455  return i.get<typename T::value_type>();
    2456  });
    2457  return to_vector;
    2458  }
    2459  else
    2460  {
    2461  throw std::domain_error("type must be array, but is " + type_name());
    2462  }
    2463  }
    2464 
    2466  template <class T, typename
    2467  std::enable_if<
    2468  std::is_convertible<basic_json_t, T>::value and
    2469  not std::is_same<basic_json_t, T>::value
    2470  , int>::type = 0>
    2471  std::vector<T> get_impl(std::vector<T>*) const
    2472  {
    2473  if (is_array())
    2474  {
    2475  std::vector<T> to_vector;
    2476  assert(m_value.array != nullptr);
    2477  to_vector.reserve(m_value.array->size());
    2478  std::transform(m_value.array->begin(), m_value.array->end(),
    2479  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2480  {
    2481  return i.get<T>();
    2482  });
    2483  return to_vector;
    2484  }
    2485  else
    2486  {
    2487  throw std::domain_error("type must be array, but is " + type_name());
    2488  }
    2489  }
    2490 
    2492  template <class T, typename
    2493  std::enable_if<
    2494  std::is_same<basic_json, typename T::value_type>::value and
    2495  not has_mapped_type<T>::value
    2496  , int>::type = 0>
    2497  T get_impl(T*) const
    2498  {
    2499  if (is_array())
    2500  {
    2501  assert(m_value.array != nullptr);
    2502  return T(m_value.array->begin(), m_value.array->end());
    2503  }
    2504  else
    2505  {
    2506  throw std::domain_error("type must be array, but is " + type_name());
    2507  }
    2508  }
    2509 
    2511  array_t get_impl(array_t*) const
    2512  {
    2513  if (is_array())
    2514  {
    2515  assert(m_value.array != nullptr);
    2516  return *(m_value.array);
    2517  }
    2518  else
    2519  {
    2520  throw std::domain_error("type must be array, but is " + type_name());
    2521  }
    2522  }
    2523 
    2525  template <typename T, typename
    2526  std::enable_if<
    2527  std::is_convertible<string_t, T>::value
    2528  , int>::type = 0>
    2529  T get_impl(T*) const
    2530  {
    2531  if (is_string())
    2532  {
    2533  assert(m_value.string != nullptr);
    2534  return *m_value.string;
    2535  }
    2536  else
    2537  {
    2538  throw std::domain_error("type must be string, but is " + type_name());
    2539  }
    2540  }
    2541 
    2543  template<typename T, typename
    2544  std::enable_if<
    2545  std::is_arithmetic<T>::value
    2546  , int>::type = 0>
    2547  T get_impl(T*) const
    2548  {
    2549  switch (m_type)
    2550  {
    2551  case value_t::number_integer:
    2552  {
    2553  return static_cast<T>(m_value.number_integer);
    2554  }
    2555 
    2556  case value_t::number_unsigned:
    2557  {
    2558  return static_cast<T>(m_value.number_unsigned);
    2559  }
    2560 
    2561  case value_t::number_float:
    2562  {
    2563  return static_cast<T>(m_value.number_float);
    2564  }
    2565 
    2566  default:
    2567  {
    2568  throw std::domain_error("type must be number, but is " + type_name());
    2569  }
    2570  }
    2571  }
    2572 
    2574  boolean_t get_impl(boolean_t*) const
    2575  {
    2576  if (is_boolean())
    2577  {
    2578  return m_value.boolean;
    2579  }
    2580  else
    2581  {
    2582  throw std::domain_error("type must be boolean, but is " + type_name());
    2583  }
    2584  }
    2585 
    2587  object_t* get_impl_ptr(object_t*) noexcept
    2588  {
    2589  return is_object() ? m_value.object : nullptr;
    2590  }
    2591 
    2593  const object_t* get_impl_ptr(const object_t*) const noexcept
    2594  {
    2595  return is_object() ? m_value.object : nullptr;
    2596  }
    2597 
    2599  array_t* get_impl_ptr(array_t*) noexcept
    2600  {
    2601  return is_array() ? m_value.array : nullptr;
    2602  }
    2603 
    2605  const array_t* get_impl_ptr(const array_t*) const noexcept
    2606  {
    2607  return is_array() ? m_value.array : nullptr;
    2608  }
    2609 
    2611  string_t* get_impl_ptr(string_t*) noexcept
    2612  {
    2613  return is_string() ? m_value.string : nullptr;
    2614  }
    2615 
    2617  const string_t* get_impl_ptr(const string_t*) const noexcept
    2618  {
    2619  return is_string() ? m_value.string : nullptr;
    2620  }
    2621 
    2623  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2624  {
    2625  return is_boolean() ? &m_value.boolean : nullptr;
    2626  }
    2627 
    2629  const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2630  {
    2631  return is_boolean() ? &m_value.boolean : nullptr;
    2632  }
    2633 
    2635  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2636  {
    2637  return is_number_integer() ? &m_value.number_integer : nullptr;
    2638  }
    2639 
    2641  const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2642  {
    2643  return is_number_integer() ? &m_value.number_integer : nullptr;
    2644  }
    2645 
    2647  number_unsigned_t* get_impl_ptr(number_unsigned_t*) noexcept
    2648  {
    2649  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2650  }
    2651 
    2653  const number_unsigned_t* get_impl_ptr(const number_unsigned_t*) const noexcept
    2654  {
    2655  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2656  }
    2657 
    2659  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2660  {
    2661  return is_number_float() ? &m_value.number_float : nullptr;
    2662  }
    2663 
    2665  const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2666  {
    2667  return is_number_float() ? &m_value.number_float : nullptr;
    2668  }
    2669 
    2681  template<typename ReferenceType, typename ThisType>
    2682  static ReferenceType get_ref_impl(ThisType& obj)
    2683  {
    2684  // delegate the call to get_ptr<>()
    2685  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2686  auto ptr = obj.template get_ptr<PointerType>();
    2687 
    2688  if (ptr != nullptr)
    2689  {
    2690  return *ptr;
    2691  }
    2692  else
    2693  {
    2694  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2695  obj.type_name());
    2696  }
    2697  }
    2698 
    2699  public:
    2700 
    2703 
    2737  template<typename ValueType, typename
    2738  std::enable_if<
    2739  not std::is_pointer<ValueType>::value
    2740  , int>::type = 0>
    2741  ValueType get() const
    2742  {
    2743  return get_impl(static_cast<ValueType*>(nullptr));
    2744  }
    2745 
    2772  template<typename PointerType, typename
    2773  std::enable_if<
    2774  std::is_pointer<PointerType>::value
    2775  , int>::type = 0>
    2776  PointerType get() noexcept
    2777  {
    2778  // delegate the call to get_ptr
    2779  return get_ptr<PointerType>();
    2780  }
    2781 
    2786  template<typename PointerType, typename
    2787  std::enable_if<
    2788  std::is_pointer<PointerType>::value
    2789  , int>::type = 0>
    2790  const PointerType get() const noexcept
    2791  {
    2792  // delegate the call to get_ptr
    2793  return get_ptr<PointerType>();
    2794  }
    2795 
    2821  template<typename PointerType, typename
    2822  std::enable_if<
    2823  std::is_pointer<PointerType>::value
    2824  , int>::type = 0>
    2825  PointerType get_ptr() noexcept
    2826  {
    2827  // delegate the call to get_impl_ptr<>()
    2828  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2829  }
    2830 
    2835  template<typename PointerType, typename
    2836  std::enable_if<
    2837  std::is_pointer<PointerType>::value
    2838  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2839  , int>::type = 0>
    2840  const PointerType get_ptr() const noexcept
    2841  {
    2842  // delegate the call to get_impl_ptr<>() const
    2843  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2844  }
    2845 
    2872  template<typename ReferenceType, typename
    2873  std::enable_if<
    2874  std::is_reference<ReferenceType>::value
    2875  , int>::type = 0>
    2876  ReferenceType get_ref()
    2877  {
    2878  // delegate call to get_ref_impl
    2879  return get_ref_impl<ReferenceType>(*this);
    2880  }
    2881 
    2886  template<typename ReferenceType, typename
    2887  std::enable_if<
    2888  std::is_reference<ReferenceType>::value
    2889  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2890  , int>::type = 0>
    2891  ReferenceType get_ref() const
    2892  {
    2893  // delegate call to get_ref_impl
    2894  return get_ref_impl<ReferenceType>(*this);
    2895  }
    2896 
    2925  template < typename ValueType, typename
    2926  std::enable_if <
    2927  not std::is_pointer<ValueType>::value
    2928  and not std::is_same<ValueType, typename string_t::value_type>::value
    2929 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2930  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2931 #endif
    2932  , int >::type = 0 >
    2933  operator ValueType() const
    2934  {
    2935  // delegate the call to get<>() const
    2936  return get<ValueType>();
    2937  }
    2938 
    2940 
    2941 
    2943  // element access //
    2945 
    2948 
    2972  {
    2973  // at only works for arrays
    2974  if (is_array())
    2975  {
    2976  try
    2977  {
    2978  assert(m_value.array != nullptr);
    2979  return m_value.array->at(idx);
    2980  }
    2981  catch (std::out_of_range&)
    2982  {
    2983  // create better exception explanation
    2984  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2985  }
    2986  }
    2987  else
    2988  {
    2989  throw std::domain_error("cannot use at() with " + type_name());
    2990  }
    2991  }
    2992 
    3016  {
    3017  // at only works for arrays
    3018  if (is_array())
    3019  {
    3020  try
    3021  {
    3022  assert(m_value.array != nullptr);
    3023  return m_value.array->at(idx);
    3024  }
    3025  catch (std::out_of_range&)
    3026  {
    3027  // create better exception explanation
    3028  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3029  }
    3030  }
    3031  else
    3032  {
    3033  throw std::domain_error("cannot use at() with " + type_name());
    3034  }
    3035  }
    3036 
    3063  reference at(const typename object_t::key_type& key)
    3064  {
    3065  // at only works for objects
    3066  if (is_object())
    3067  {
    3068  try
    3069  {
    3070  assert(m_value.object != nullptr);
    3071  return m_value.object->at(key);
    3072  }
    3073  catch (std::out_of_range&)
    3074  {
    3075  // create better exception explanation
    3076  throw std::out_of_range("key '" + key + "' not found");
    3077  }
    3078  }
    3079  else
    3080  {
    3081  throw std::domain_error("cannot use at() with " + type_name());
    3082  }
    3083  }
    3084 
    3111  const_reference at(const typename object_t::key_type& key) const
    3112  {
    3113  // at only works for objects
    3114  if (is_object())
    3115  {
    3116  try
    3117  {
    3118  assert(m_value.object != nullptr);
    3119  return m_value.object->at(key);
    3120  }
    3121  catch (std::out_of_range&)
    3122  {
    3123  // create better exception explanation
    3124  throw std::out_of_range("key '" + key + "' not found");
    3125  }
    3126  }
    3127  else
    3128  {
    3129  throw std::domain_error("cannot use at() with " + type_name());
    3130  }
    3131  }
    3132 
    3159  {
    3160  // implicitly convert null to object
    3161  if (is_null())
    3162  {
    3163  m_type = value_t::array;
    3164  m_value.array = create<array_t>();
    3165  }
    3166 
    3167  // [] only works for arrays
    3168  if (is_array())
    3169  {
    3170  assert(m_value.array != nullptr);
    3171  for (size_t i = m_value.array->size(); i <= idx; ++i)
    3172  {
    3173  m_value.array->push_back(basic_json());
    3174  }
    3175 
    3176  return m_value.array->operator[](idx);
    3177  }
    3178  else
    3179  {
    3180  throw std::domain_error("cannot use operator[] with " + type_name());
    3181  }
    3182  }
    3183 
    3204  {
    3205  // at only works for arrays
    3206  if (is_array())
    3207  {
    3208  assert(m_value.array != nullptr);
    3209  return m_value.array->operator[](idx);
    3210  }
    3211  else
    3212  {
    3213  throw std::domain_error("cannot use operator[] with " + type_name());
    3214  }
    3215  }
    3216 
    3244  reference operator[](const typename object_t::key_type& key)
    3245  {
    3246  // implicitly convert null to object
    3247  if (is_null())
    3248  {
    3249  m_type = value_t::object;
    3250  m_value.object = create<object_t>();
    3251  }
    3252 
    3253  // [] only works for objects
    3254  if (is_object())
    3255  {
    3256  assert(m_value.object != nullptr);
    3257  return m_value.object->operator[](key);
    3258  }
    3259  else
    3260  {
    3261  throw std::domain_error("cannot use operator[] with " + type_name());
    3262  }
    3263  }
    3264 
    3292  const_reference operator[](const typename object_t::key_type& key) const
    3293  {
    3294  // [] only works for objects
    3295  if (is_object())
    3296  {
    3297  assert(m_value.object != nullptr);
    3298  assert(m_value.object->find(key) != m_value.object->end());
    3299  return m_value.object->find(key)->second;
    3300  }
    3301  else
    3302  {
    3303  throw std::domain_error("cannot use operator[] with " + type_name());
    3304  }
    3305  }
    3306 
    3334  template<typename T, std::size_t n>
    3335  reference operator[](T * (&key)[n])
    3336  {
    3337  return operator[](static_cast<const T>(key));
    3338  }
    3339 
    3369  template<typename T, std::size_t n>
    3370  const_reference operator[](T * (&key)[n]) const
    3371  {
    3372  return operator[](static_cast<const T>(key));
    3373  }
    3374 
    3402  template<typename T>
    3404  {
    3405  // implicitly convert null to object
    3406  if (is_null())
    3407  {
    3408  m_type = value_t::object;
    3409  m_value = value_t::object;
    3410  }
    3411 
    3412  // at only works for objects
    3413  if (is_object())
    3414  {
    3415  assert(m_value.object != nullptr);
    3416  return m_value.object->operator[](key);
    3417  }
    3418  else
    3419  {
    3420  throw std::domain_error("cannot use operator[] with " + type_name());
    3421  }
    3422  }
    3423 
    3451  template<typename T>
    3453  {
    3454  // at only works for objects
    3455  if (is_object())
    3456  {
    3457  assert(m_value.object != nullptr);
    3458  assert(m_value.object->find(key) != m_value.object->end());
    3459  return m_value.object->find(key)->second;
    3460  }
    3461  else
    3462  {
    3463  throw std::domain_error("cannot use operator[] with " + type_name());
    3464  }
    3465  }
    3466 
    3515  template <class ValueType, typename
    3516  std::enable_if<
    3517  std::is_convertible<basic_json_t, ValueType>::value
    3518  , int>::type = 0>
    3519  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3520  {
    3521  // at only works for objects
    3522  if (is_object())
    3523  {
    3524  // if key is found, return value and given default value otherwise
    3525  const auto it = find(key);
    3526  if (it != end())
    3527  {
    3528  return *it;
    3529  }
    3530  else
    3531  {
    3532  return default_value;
    3533  }
    3534  }
    3535  else
    3536  {
    3537  throw std::domain_error("cannot use value() with " + type_name());
    3538  }
    3539  }
    3540 
    3545  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3546  {
    3547  return value(key, string_t(default_value));
    3548  }
    3549 
    3575  {
    3576  return *begin();
    3577  }
    3578 
    3583  {
    3584  return *cbegin();
    3585  }
    3586 
    3613  {
    3614  auto tmp = end();
    3615  --tmp;
    3616  return *tmp;
    3617  }
    3618 
    3623  {
    3624  auto tmp = cend();
    3625  --tmp;
    3626  return *tmp;
    3627  }
    3628 
    3673  template <class InteratorType, typename
    3674  std::enable_if<
    3675  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3676  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3677  , int>::type
    3678  = 0>
    3679  InteratorType erase(InteratorType pos)
    3680  {
    3681  // make sure iterator fits the current value
    3682  if (this != pos.m_object)
    3683  {
    3684  throw std::domain_error("iterator does not fit current value");
    3685  }
    3686 
    3687  InteratorType result = end();
    3688 
    3689  switch (m_type)
    3690  {
    3691  case value_t::boolean:
    3692  case value_t::number_float:
    3693  case value_t::number_integer:
    3694  case value_t::number_unsigned:
    3695  case value_t::string:
    3696  {
    3697  if (not pos.m_it.primitive_iterator.is_begin())
    3698  {
    3699  throw std::out_of_range("iterator out of range");
    3700  }
    3701 
    3702  if (is_string())
    3703  {
    3704  delete m_value.string;
    3705  m_value.string = nullptr;
    3706  }
    3707 
    3708  m_type = value_t::null;
    3709  break;
    3710  }
    3711 
    3712  case value_t::object:
    3713  {
    3714  assert(m_value.object != nullptr);
    3715  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3716  break;
    3717  }
    3718 
    3719  case value_t::array:
    3720  {
    3721  assert(m_value.array != nullptr);
    3722  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3723  break;
    3724  }
    3725 
    3726  default:
    3727  {
    3728  throw std::domain_error("cannot use erase() with " + type_name());
    3729  }
    3730  }
    3731 
    3732  return result;
    3733  }
    3734 
    3779  template <class InteratorType, typename
    3780  std::enable_if<
    3781  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3782  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3783  , int>::type
    3784  = 0>
    3785  InteratorType erase(InteratorType first, InteratorType last)
    3786  {
    3787  // make sure iterator fits the current value
    3788  if (this != first.m_object or this != last.m_object)
    3789  {
    3790  throw std::domain_error("iterators do not fit current value");
    3791  }
    3792 
    3793  InteratorType result = end();
    3794 
    3795  switch (m_type)
    3796  {
    3797  case value_t::boolean:
    3798  case value_t::number_float:
    3799  case value_t::number_integer:
    3800  case value_t::number_unsigned:
    3801  case value_t::string:
    3802  {
    3803  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3804  {
    3805  throw std::out_of_range("iterators out of range");
    3806  }
    3807 
    3808  if (is_string())
    3809  {
    3810  delete m_value.string;
    3811  m_value.string = nullptr;
    3812  }
    3813 
    3814  m_type = value_t::null;
    3815  break;
    3816  }
    3817 
    3818  case value_t::object:
    3819  {
    3820  assert(m_value.object != nullptr);
    3821  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3822  last.m_it.object_iterator);
    3823  break;
    3824  }
    3825 
    3826  case value_t::array:
    3827  {
    3828  assert(m_value.array != nullptr);
    3829  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3830  last.m_it.array_iterator);
    3831  break;
    3832  }
    3833 
    3834  default:
    3835  {
    3836  throw std::domain_error("cannot use erase() with " + type_name());
    3837  }
    3838  }
    3839 
    3840  return result;
    3841  }
    3842 
    3869  size_type erase(const typename object_t::key_type& key)
    3870  {
    3871  // this erase only works for objects
    3872  if (is_object())
    3873  {
    3874  assert(m_value.object != nullptr);
    3875  return m_value.object->erase(key);
    3876  }
    3877  else
    3878  {
    3879  throw std::domain_error("cannot use erase() with " + type_name());
    3880  }
    3881  }
    3882 
    3907  void erase(const size_type idx)
    3908  {
    3909  // this erase only works for arrays
    3910  if (is_array())
    3911  {
    3912  if (idx >= size())
    3913  {
    3914  throw std::out_of_range("index out of range");
    3915  }
    3916 
    3917  assert(m_value.array != nullptr);
    3918  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3919  }
    3920  else
    3921  {
    3922  throw std::domain_error("cannot use erase() with " + type_name());
    3923  }
    3924  }
    3925 
    3943  iterator find(typename object_t::key_type key)
    3944  {
    3945  auto result = end();
    3946 
    3947  if (is_object())
    3948  {
    3949  assert(m_value.object != nullptr);
    3950  result.m_it.object_iterator = m_value.object->find(key);
    3951  }
    3952 
    3953  return result;
    3954  }
    3955 
    3960  const_iterator find(typename object_t::key_type key) const
    3961  {
    3962  auto result = cend();
    3963 
    3964  if (is_object())
    3965  {
    3966  assert(m_value.object != nullptr);
    3967  result.m_it.object_iterator = m_value.object->find(key);
    3968  }
    3969 
    3970  return result;
    3971  }
    3972 
    3991  size_type count(typename object_t::key_type key) const
    3992  {
    3993  // return 0 for all nonobject types
    3994  assert(not is_object() or m_value.object != nullptr);
    3995  return is_object() ? m_value.object->count(key) : 0;
    3996  }
    3997 
    3999 
    4000 
    4002  // iterators //
    4004 
    4007 
    4033  {
    4034  iterator result(this);
    4035  result.set_begin();
    4036  return result;
    4037  }
    4038 
    4043  {
    4044  return cbegin();
    4045  }
    4046 
    4073  {
    4074  const_iterator result(this);
    4075  result.set_begin();
    4076  return result;
    4077  }
    4078 
    4104  {
    4105  iterator result(this);
    4106  result.set_end();
    4107  return result;
    4108  }
    4109 
    4114  {
    4115  return cend();
    4116  }
    4117 
    4144  {
    4145  const_iterator result(this);
    4146  result.set_end();
    4147  return result;
    4148  }
    4149 
    4174  {
    4175  return reverse_iterator(end());
    4176  }
    4177 
    4182  {
    4183  return crbegin();
    4184  }
    4185 
    4211  {
    4212  return reverse_iterator(begin());
    4213  }
    4214 
    4219  {
    4220  return crend();
    4221  }
    4222 
    4248  {
    4249  return const_reverse_iterator(cend());
    4250  }
    4251 
    4277  {
    4278  return const_reverse_iterator(cbegin());
    4279  }
    4280 
    4281  private:
    4282  // forward declaration
    4283  template<typename IteratorType> class iteration_proxy;
    4284 
    4285  public:
    4297  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    4298  {
    4299  return iteration_proxy<iterator>(cont);
    4300  }
    4301 
    4305  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4306  {
    4307  return iteration_proxy<const_iterator>(cont);
    4308  }
    4309 
    4311 
    4312 
    4314  // capacity //
    4316 
    4319 
    4353  bool empty() const noexcept
    4354  {
    4355  switch (m_type)
    4356  {
    4357  case value_t::null:
    4358  {
    4359  // null values are empty
    4360  return true;
    4361  }
    4362 
    4363  case value_t::array:
    4364  {
    4365  assert(m_value.array != nullptr);
    4366  return m_value.array->empty();
    4367  }
    4368 
    4369  case value_t::object:
    4370  {
    4371  assert(m_value.object != nullptr);
    4372  return m_value.object->empty();
    4373  }
    4374 
    4375  default:
    4376  {
    4377  // all other types are nonempty
    4378  return false;
    4379  }
    4380  }
    4381  }
    4382 
    4416  size_type size() const noexcept
    4417  {
    4418  switch (m_type)
    4419  {
    4420  case value_t::null:
    4421  {
    4422  // null values are empty
    4423  return 0;
    4424  }
    4425 
    4426  case value_t::array:
    4427  {
    4428  assert(m_value.array != nullptr);
    4429  return m_value.array->size();
    4430  }
    4431 
    4432  case value_t::object:
    4433  {
    4434  assert(m_value.object != nullptr);
    4435  return m_value.object->size();
    4436  }
    4437 
    4438  default:
    4439  {
    4440  // all other types have size 1
    4441  return 1;
    4442  }
    4443  }
    4444  }
    4445 
    4482  size_type max_size() const noexcept
    4483  {
    4484  switch (m_type)
    4485  {
    4486  case value_t::array:
    4487  {
    4488  assert(m_value.array != nullptr);
    4489  return m_value.array->max_size();
    4490  }
    4491 
    4492  case value_t::object:
    4493  {
    4494  assert(m_value.object != nullptr);
    4495  return m_value.object->max_size();
    4496  }
    4497 
    4498  default:
    4499  {
    4500  // all other types have max_size() == size()
    4501  return size();
    4502  }
    4503  }
    4504  }
    4505 
    4507 
    4508 
    4510  // modifiers //
    4512 
    4515 
    4541  void clear() noexcept
    4542  {
    4543  switch (m_type)
    4544  {
    4545  case value_t::number_integer:
    4546  {
    4547  m_value.number_integer = 0;
    4548  break;
    4549  }
    4550 
    4551  case value_t::number_unsigned:
    4552  {
    4553  m_value.number_unsigned = 0;
    4554  break;
    4555  }
    4556 
    4557  case value_t::number_float:
    4558  {
    4559  m_value.number_float = 0.0;
    4560  break;
    4561  }
    4562 
    4563  case value_t::boolean:
    4564  {
    4565  m_value.boolean = false;
    4566  break;
    4567  }
    4568 
    4569  case value_t::string:
    4570  {
    4571  assert(m_value.string != nullptr);
    4572  m_value.string->clear();
    4573  break;
    4574  }
    4575 
    4576  case value_t::array:
    4577  {
    4578  assert(m_value.array != nullptr);
    4579  m_value.array->clear();
    4580  break;
    4581  }
    4582 
    4583  case value_t::object:
    4584  {
    4585  assert(m_value.object != nullptr);
    4586  m_value.object->clear();
    4587  break;
    4588  }
    4589 
    4590  default:
    4591  {
    4592  break;
    4593  }
    4594  }
    4595  }
    4596 
    4617  void push_back(basic_json&& val)
    4618  {
    4619  // push_back only works for null objects or arrays
    4620  if (not(is_null() or is_array()))
    4621  {
    4622  throw std::domain_error("cannot use push_back() with " + type_name());
    4623  }
    4624 
    4625  // transform null object into an array
    4626  if (is_null())
    4627  {
    4628  m_type = value_t::array;
    4629  m_value = value_t::array;
    4630  }
    4631 
    4632  // add element to array (move semantics)
    4633  assert(m_value.array != nullptr);
    4634  m_value.array->push_back(std::move(val));
    4635  // invalidate object
    4636  val.m_type = value_t::null;
    4637  }
    4638 
    4643  reference operator+=(basic_json&& val)
    4644  {
    4645  push_back(std::move(val));
    4646  return *this;
    4647  }
    4648 
    4653  void push_back(const basic_json& val)
    4654  {
    4655  // push_back only works for null objects or arrays
    4656  if (not(is_null() or is_array()))
    4657  {
    4658  throw std::domain_error("cannot use push_back() with " + type_name());
    4659  }
    4660 
    4661  // transform null object into an array
    4662  if (is_null())
    4663  {
    4664  m_type = value_t::array;
    4665  m_value = value_t::array;
    4666  }
    4667 
    4668  // add element to array
    4669  assert(m_value.array != nullptr);
    4670  m_value.array->push_back(val);
    4671  }
    4672 
    4677  reference operator+=(const basic_json& val)
    4678  {
    4679  push_back(val);
    4680  return *this;
    4681  }
    4682 
    4703  void push_back(const typename object_t::value_type& val)
    4704  {
    4705  // push_back only works for null objects or objects
    4706  if (not(is_null() or is_object()))
    4707  {
    4708  throw std::domain_error("cannot use push_back() with " + type_name());
    4709  }
    4710 
    4711  // transform null object into an object
    4712  if (is_null())
    4713  {
    4714  m_type = value_t::object;
    4715  m_value = value_t::object;
    4716  }
    4717 
    4718  // add element to array
    4719  assert(m_value.object != nullptr);
    4720  m_value.object->insert(val);
    4721  }
    4722 
    4727  reference operator+=(const typename object_t::value_type& val)
    4728  {
    4729  push_back(val);
    4730  return operator[](val.first);
    4731  }
    4732 
    4755  iterator insert(const_iterator pos, const basic_json& val)
    4756  {
    4757  // insert only works for arrays
    4758  if (is_array())
    4759  {
    4760  // check if iterator pos fits to this JSON value
    4761  if (pos.m_object != this)
    4762  {
    4763  throw std::domain_error("iterator does not fit current value");
    4764  }
    4765 
    4766  // insert to array and return iterator
    4767  iterator result(this);
    4768  assert(m_value.array != nullptr);
    4769  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4770  return result;
    4771  }
    4772  else
    4773  {
    4774  throw std::domain_error("cannot use insert() with " + type_name());
    4775  }
    4776  }
    4777 
    4782  iterator insert(const_iterator pos, basic_json&& val)
    4783  {
    4784  return insert(pos, val);
    4785  }
    4786 
    4811  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4812  {
    4813  // insert only works for arrays
    4814  if (is_array())
    4815  {
    4816  // check if iterator pos fits to this JSON value
    4817  if (pos.m_object != this)
    4818  {
    4819  throw std::domain_error("iterator does not fit current value");
    4820  }
    4821 
    4822  // insert to array and return iterator
    4823  iterator result(this);
    4824  assert(m_value.array != nullptr);
    4825  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4826  return result;
    4827  }
    4828  else
    4829  {
    4830  throw std::domain_error("cannot use insert() with " + type_name());
    4831  }
    4832  }
    4833 
    4865  {
    4866  // insert only works for arrays
    4867  if (not is_array())
    4868  {
    4869  throw std::domain_error("cannot use insert() with " + type_name());
    4870  }
    4871 
    4872  // check if iterator pos fits to this JSON value
    4873  if (pos.m_object != this)
    4874  {
    4875  throw std::domain_error("iterator does not fit current value");
    4876  }
    4877 
    4878  if (first.m_object != last.m_object)
    4879  {
    4880  throw std::domain_error("iterators do not fit");
    4881  }
    4882 
    4883  if (first.m_object == this or last.m_object == this)
    4884  {
    4885  throw std::domain_error("passed iterators may not belong to container");
    4886  }
    4887 
    4888  // insert to array and return iterator
    4889  iterator result(this);
    4890  assert(m_value.array != nullptr);
    4891  result.m_it.array_iterator = m_value.array->insert(
    4892  pos.m_it.array_iterator,
    4893  first.m_it.array_iterator,
    4894  last.m_it.array_iterator);
    4895  return result;
    4896  }
    4897 
    4922  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4923  {
    4924  // insert only works for arrays
    4925  if (not is_array())
    4926  {
    4927  throw std::domain_error("cannot use insert() with " + type_name());
    4928  }
    4929 
    4930  // check if iterator pos fits to this JSON value
    4931  if (pos.m_object != this)
    4932  {
    4933  throw std::domain_error("iterator does not fit current value");
    4934  }
    4935 
    4936  // insert to array and return iterator
    4937  iterator result(this);
    4938  assert(m_value.array != nullptr);
    4939  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4940  return result;
    4941  }
    4942 
    4960  void swap(reference other) noexcept (
    4961  std::is_nothrow_move_constructible<value_t>::value and
    4962  std::is_nothrow_move_assignable<value_t>::value and
    4963  std::is_nothrow_move_constructible<json_value>::value and
    4964  std::is_nothrow_move_assignable<json_value>::value
    4965  )
    4966  {
    4967  std::swap(m_type, other.m_type);
    4968  std::swap(m_value, other.m_value);
    4969  }
    4970 
    4991  void swap(array_t& other)
    4992  {
    4993  // swap only works for arrays
    4994  if (is_array())
    4995  {
    4996  assert(m_value.array != nullptr);
    4997  std::swap(*(m_value.array), other);
    4998  }
    4999  else
    5000  {
    5001  throw std::domain_error("cannot use swap() with " + type_name());
    5002  }
    5003  }
    5004 
    5025  void swap(object_t& other)
    5026  {
    5027  // swap only works for objects
    5028  if (is_object())
    5029  {
    5030  assert(m_value.object != nullptr);
    5031  std::swap(*(m_value.object), other);
    5032  }
    5033  else
    5034  {
    5035  throw std::domain_error("cannot use swap() with " + type_name());
    5036  }
    5037  }
    5038 
    5059  void swap(string_t& other)
    5060  {
    5061  // swap only works for strings
    5062  if (is_string())
    5063  {
    5064  assert(m_value.string != nullptr);
    5065  std::swap(*(m_value.string), other);
    5066  }
    5067  else
    5068  {
    5069  throw std::domain_error("cannot use swap() with " + type_name());
    5070  }
    5071  }
    5072 
    5074 
    5075 
    5077  // lexicographical comparison operators //
    5079 
    5082 
    5083  private:
    5093  friend bool operator<(const value_t lhs, const value_t rhs)
    5094  {
    5095  static constexpr std::array<uint8_t, 8> order = {{
    5096  0, // null
    5097  3, // object
    5098  4, // array
    5099  5, // string
    5100  1, // boolean
    5101  2, // integer
    5102  2, // unsigned
    5103  2, // float
    5104  }
    5105  };
    5106 
    5107  // discarded values are not comparable
    5108  if (lhs == value_t::discarded or rhs == value_t::discarded)
    5109  {
    5110  return false;
    5111  }
    5112 
    5113  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    5114  }
    5115 
    5116  public:
    5140  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    5141  {
    5142  const auto lhs_type = lhs.type();
    5143  const auto rhs_type = rhs.type();
    5144 
    5145  if (lhs_type == rhs_type)
    5146  {
    5147  switch (lhs_type)
    5148  {
    5149  case value_t::array:
    5150  {
    5151  assert(lhs.m_value.array != nullptr);
    5152  assert(rhs.m_value.array != nullptr);
    5153  return *lhs.m_value.array == *rhs.m_value.array;
    5154  }
    5155  case value_t::object:
    5156  {
    5157  assert(lhs.m_value.object != nullptr);
    5158  assert(rhs.m_value.object != nullptr);
    5159  return *lhs.m_value.object == *rhs.m_value.object;
    5160  }
    5161  case value_t::null:
    5162  {
    5163  return true;
    5164  }
    5165  case value_t::string:
    5166  {
    5167  assert(lhs.m_value.string != nullptr);
    5168  assert(rhs.m_value.string != nullptr);
    5169  return *lhs.m_value.string == *rhs.m_value.string;
    5170  }
    5171  case value_t::boolean:
    5172  {
    5173  return lhs.m_value.boolean == rhs.m_value.boolean;
    5174  }
    5175  case value_t::number_integer:
    5176  {
    5177  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    5178  }
    5179  case value_t::number_unsigned:
    5180  {
    5181  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
    5182  }
    5183  case value_t::number_float:
    5184  {
    5185  return lhs.m_value.number_float == rhs.m_value.number_float;
    5186  }
    5187  default:
    5188  {
    5189  return false;
    5190  }
    5191  }
    5192  }
    5193  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5194  {
    5195  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    5196  }
    5197  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5198  {
    5199  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    5200  }
    5201  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5202  {
    5203  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
    5204  }
    5205  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5206  {
    5207  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5208  }
    5209  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5210  {
    5211  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
    5212  }
    5213  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5214  {
    5215  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5216  }
    5217 
    5218  return false;
    5219  }
    5220 
    5239  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    5240  {
    5241  return v.is_null();
    5242  }
    5243 
    5248  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    5249  {
    5250  return v.is_null();
    5251  }
    5252 
    5269  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    5270  {
    5271  return not (lhs == rhs);
    5272  }
    5273 
    5292  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    5293  {
    5294  return not v.is_null();
    5295  }
    5296 
    5301  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    5302  {
    5303  return not v.is_null();
    5304  }
    5305 
    5330  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    5331  {
    5332  const auto lhs_type = lhs.type();
    5333  const auto rhs_type = rhs.type();
    5334 
    5335  if (lhs_type == rhs_type)
    5336  {
    5337  switch (lhs_type)
    5338  {
    5339  case value_t::array:
    5340  {
    5341  assert(lhs.m_value.array != nullptr);
    5342  assert(rhs.m_value.array != nullptr);
    5343  return *lhs.m_value.array < *rhs.m_value.array;
    5344  }
    5345  case value_t::object:
    5346  {
    5347  assert(lhs.m_value.object != nullptr);
    5348  assert(rhs.m_value.object != nullptr);
    5349  return *lhs.m_value.object < *rhs.m_value.object;
    5350  }
    5351  case value_t::null:
    5352  {
    5353  return false;
    5354  }
    5355  case value_t::string:
    5356  {
    5357  assert(lhs.m_value.string != nullptr);
    5358  assert(rhs.m_value.string != nullptr);
    5359  return *lhs.m_value.string < *rhs.m_value.string;
    5360  }
    5361  case value_t::boolean:
    5362  {
    5363  return lhs.m_value.boolean < rhs.m_value.boolean;
    5364  }
    5365  case value_t::number_integer:
    5366  {
    5367  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5368  }
    5369  case value_t::number_unsigned:
    5370  {
    5371  return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
    5372  }
    5373  case value_t::number_float:
    5374  {
    5375  return lhs.m_value.number_float < rhs.m_value.number_float;
    5376  }
    5377  default:
    5378  {
    5379  return false;
    5380  }
    5381  }
    5382  }
    5383  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5384  {
    5385  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
    5386  }
    5387  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5388  {
    5389  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
    5390  }
    5391  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5392  {
    5393  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
    5394  }
    5395  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5396  {
    5397  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5398  }
    5399  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5400  {
    5401  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5402  }
    5403  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5404  {
    5405  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
    5406  }
    5407 
    5408  // We only reach this line if we cannot compare values. In that case,
    5409  // we compare types. Note we have to call the operator explicitly,
    5410  // because MSVC has problems otherwise.
    5411  return operator<(lhs_type, rhs_type);
    5412  }
    5413 
    5431  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5432  {
    5433  return not (rhs < lhs);
    5434  }
    5435 
    5453  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5454  {
    5455  return not (lhs <= rhs);
    5456  }
    5457 
    5475  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5476  {
    5477  return not (lhs < rhs);
    5478  }
    5479 
    5481 
    5482 
    5484  // serialization //
    5486 
    5489 
    5512  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5513  {
    5514  // read width member and use it as indentation parameter if nonzero
    5515  const bool pretty_print = (o.width() > 0);
    5516  const auto indentation = (pretty_print ? o.width() : 0);
    5517 
    5518  // reset width to 0 for subsequent calls to this stream
    5519  o.width(0);
    5520 
    5521  // do the actual serialization
    5522  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5523  return o;
    5524  }
    5525 
    5530  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5531  {
    5532  return o << j;
    5533  }
    5534 
    5536 
    5537 
    5539  // deserialization //
    5541 
    5544 
    5569  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5570  {
    5571  return parser(s, cb).parse();
    5572  }
    5573 
    5598  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5599  {
    5600  return parser(i, cb).parse();
    5601  }
    5602 
    5606  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5607  {
    5608  return parser(i, cb).parse();
    5609  }
    5610 
    5634  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5635  {
    5636  j = parser(i).parse();
    5637  return i;
    5638  }
    5639 
    5644  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5645  {
    5646  j = parser(i).parse();
    5647  return i;
    5648  }
    5649 
    5651 
    5652 
    5653  private:
    5655  // convenience functions //
    5657 
    5659  string_t type_name() const
    5660  {
    5661  switch (m_type)
    5662  {
    5663  case value_t::null:
    5664  return "null";
    5665  case value_t::object:
    5666  return "object";
    5667  case value_t::array:
    5668  return "array";
    5669  case value_t::string:
    5670  return "string";
    5671  case value_t::boolean:
    5672  return "boolean";
    5673  case value_t::discarded:
    5674  return "discarded";
    5675  default:
    5676  return "number";
    5677  }
    5678  }
    5679 
    5688  static std::size_t extra_space(const string_t& s) noexcept
    5689  {
    5690  std::size_t result = 0;
    5691 
    5692  for (const auto& c : s)
    5693  {
    5694  switch (c)
    5695  {
    5696  case '"':
    5697  case '\\':
    5698  case '\b':
    5699  case '\f':
    5700  case '\n':
    5701  case '\r':
    5702  case '\t':
    5703  {
    5704  // from c (1 byte) to \x (2 bytes)
    5705  result += 1;
    5706  break;
    5707  }
    5708 
    5709  default:
    5710  {
    5711  if (c >= 0x00 and c <= 0x1f)
    5712  {
    5713  // from c (1 byte) to \uxxxx (6 bytes)
    5714  result += 5;
    5715  }
    5716  break;
    5717  }
    5718  }
    5719  }
    5720 
    5721  return result;
    5722  }
    5723 
    5737  static string_t escape_string(const string_t& s) noexcept
    5738  {
    5739  const auto space = extra_space(s);
    5740  if (space == 0)
    5741  {
    5742  return s;
    5743  }
    5744 
    5745  // create a result string of necessary size
    5746  string_t result(s.size() + space, '\\');
    5747  std::size_t pos = 0;
    5748 
    5749  for (const auto& c : s)
    5750  {
    5751  switch (c)
    5752  {
    5753  // quotation mark (0x22)
    5754  case '"':
    5755  {
    5756  result[pos + 1] = '"';
    5757  pos += 2;
    5758  break;
    5759  }
    5760 
    5761  // reverse solidus (0x5c)
    5762  case '\\':
    5763  {
    5764  // nothing to change
    5765  pos += 2;
    5766  break;
    5767  }
    5768 
    5769  // backspace (0x08)
    5770  case '\b':
    5771  {
    5772  result[pos + 1] = 'b';
    5773  pos += 2;
    5774  break;
    5775  }
    5776 
    5777  // formfeed (0x0c)
    5778  case '\f':
    5779  {
    5780  result[pos + 1] = 'f';
    5781  pos += 2;
    5782  break;
    5783  }
    5784 
    5785  // newline (0x0a)
    5786  case '\n':
    5787  {
    5788  result[pos + 1] = 'n';
    5789  pos += 2;
    5790  break;
    5791  }
    5792 
    5793  // carriage return (0x0d)
    5794  case '\r':
    5795  {
    5796  result[pos + 1] = 'r';
    5797  pos += 2;
    5798  break;
    5799  }
    5800 
    5801  // horizontal tab (0x09)
    5802  case '\t':
    5803  {
    5804  result[pos + 1] = 't';
    5805  pos += 2;
    5806  break;
    5807  }
    5808 
    5809  default:
    5810  {
    5811  if (c >= 0x00 and c <= 0x1f)
    5812  {
    5813  // convert a number 0..15 to its hex representation
    5814  // (0..f)
    5815  auto hexify = [](const char v) -> char
    5816  {
    5817  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5818  };
    5819 
    5820  // print character c as \uxxxx
    5821  for (const char m :
    5822  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5823  })
    5824  {
    5825  result[++pos] = m;
    5826  }
    5827 
    5828  ++pos;
    5829  }
    5830  else
    5831  {
    5832  // all other characters are added as-is
    5833  result[pos++] = c;
    5834  }
    5835  break;
    5836  }
    5837  }
    5838  }
    5839 
    5840  return result;
    5841  }
    5842 
    5860  void dump(std::ostream& o,
    5861  const bool pretty_print,
    5862  const unsigned int indent_step,
    5863  const unsigned int current_indent = 0) const
    5864  {
    5865  // variable to hold indentation for recursive calls
    5866  unsigned int new_indent = current_indent;
    5867 
    5868  switch (m_type)
    5869  {
    5870  case value_t::object:
    5871  {
    5872  assert(m_value.object != nullptr);
    5873 
    5874  if (m_value.object->empty())
    5875  {
    5876  o << "{}";
    5877  return;
    5878  }
    5879 
    5880  o << "{";
    5881 
    5882  // increase indentation
    5883  if (pretty_print)
    5884  {
    5885  new_indent += indent_step;
    5886  o << "\n";
    5887  }
    5888 
    5889  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5890  {
    5891  if (i != m_value.object->cbegin())
    5892  {
    5893  o << (pretty_print ? ",\n" : ",");
    5894  }
    5895  o << string_t(new_indent, ' ') << "\""
    5896  << escape_string(i->first) << "\":"
    5897  << (pretty_print ? " " : "");
    5898  i->second.dump(o, pretty_print, indent_step, new_indent);
    5899  }
    5900 
    5901  // decrease indentation
    5902  if (pretty_print)
    5903  {
    5904  new_indent -= indent_step;
    5905  o << "\n";
    5906  }
    5907 
    5908  o << string_t(new_indent, ' ') + "}";
    5909  return;
    5910  }
    5911 
    5912  case value_t::array:
    5913  {
    5914  assert(m_value.array != nullptr);
    5915 
    5916  if (m_value.array->empty())
    5917  {
    5918  o << "[]";
    5919  return;
    5920  }
    5921 
    5922  o << "[";
    5923 
    5924  // increase indentation
    5925  if (pretty_print)
    5926  {
    5927  new_indent += indent_step;
    5928  o << "\n";
    5929  }
    5930 
    5931  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5932  {
    5933  if (i != m_value.array->cbegin())
    5934  {
    5935  o << (pretty_print ? ",\n" : ",");
    5936  }
    5937  o << string_t(new_indent, ' ');
    5938  i->dump(o, pretty_print, indent_step, new_indent);
    5939  }
    5940 
    5941  // decrease indentation
    5942  if (pretty_print)
    5943  {
    5944  new_indent -= indent_step;
    5945  o << "\n";
    5946  }
    5947 
    5948  o << string_t(new_indent, ' ') << "]";
    5949  return;
    5950  }
    5951 
    5952  case value_t::string:
    5953  {
    5954  assert(m_value.string != nullptr);
    5955  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5956  return;
    5957  }
    5958 
    5959  case value_t::boolean:
    5960  {
    5961  o << (m_value.boolean ? "true" : "false");
    5962  return;
    5963  }
    5964 
    5965  case value_t::number_integer:
    5966  {
    5967  o << m_value.number_integer;
    5968  return;
    5969  }
    5970 
    5971  case value_t::number_unsigned:
    5972  {
    5973  o << m_value.number_unsigned;
    5974  return;
    5975  }
    5976 
    5977  case value_t::number_float:
    5978  {
    5979  // If the number is an integer then output as a fixed with with
    5980  // precision 1 to output "0.0", "1.0" etc as expected for some
    5981  // round trip tests otherwise 15 digits of precision allows
    5982  // round-trip IEEE 754 string->double->string; to be safe, we
    5983  // read this value from
    5984  // std::numeric_limits<number_float_t>::digits10
    5985  if (std::fmod(m_value.number_float, 1) == 0)
    5986  {
    5987  o << std::fixed << std::setprecision(1);
    5988  }
    5989  else
    5990  {
    5991  // std::defaultfloat not supported in gcc version < 5
    5992  o.unsetf(std::ios_base::floatfield);
    5993  o << std::setprecision(std::numeric_limits<double>::digits10);
    5994  }
    5995  o << m_value.number_float;
    5996  return;
    5997  }
    5998 
    5999  case value_t::discarded:
    6000  {
    6001  o << "<discarded>";
    6002  return;
    6003  }
    6004 
    6005  case value_t::null:
    6006  {
    6007  o << "null";
    6008  return;
    6009  }
    6010  }
    6011  }
    6012 
    6013  private:
    6015  // member variables //
    6017 
    6019  value_t m_type = value_t::null;
    6020 
    6022  json_value m_value = {};
    6023 
    6024 
    6025  private:
    6027  // iterators //
    6029 
    6039  class primitive_iterator_t
    6040  {
    6041  public:
    6043  void set_begin()
    6044  {
    6045  m_it = begin_value;
    6046  }
    6047 
    6049  void set_end()
    6050  {
    6051  m_it = end_value;
    6052  }
    6053 
    6055  bool is_begin() const
    6056  {
    6057  return (m_it == begin_value);
    6058  }
    6059 
    6061  bool is_end() const
    6062  {
    6063  return (m_it == end_value);
    6064  }
    6065 
    6067  operator difference_type& ()
    6068  {
    6069  return m_it;
    6070  }
    6071 
    6073  operator difference_type () const
    6074  {
    6075  return m_it;
    6076  }
    6077 
    6078  private:
    6079  static constexpr difference_type begin_value = 0;
    6080  static constexpr difference_type end_value = begin_value + 1;
    6081 
    6083  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    6084  };
    6085 
    6093  struct internal_iterator
    6094  {
    6096  typename object_t::iterator object_iterator;
    6098  typename array_t::iterator array_iterator;
    6100  primitive_iterator_t primitive_iterator;
    6101 
    6103  internal_iterator()
    6104  : object_iterator(), array_iterator(), primitive_iterator()
    6105  {}
    6106  };
    6107 
    6109  template<typename IteratorType>
    6110  class iteration_proxy
    6111  {
    6112  private:
    6114  class iteration_proxy_internal
    6115  {
    6116  private:
    6118  IteratorType anchor;
    6120  size_t array_index = 0;
    6121 
    6122  public:
    6123  iteration_proxy_internal(IteratorType it)
    6124  : anchor(it)
    6125  {}
    6126 
    6128  iteration_proxy_internal& operator*()
    6129  {
    6130  return *this;
    6131  }
    6132 
    6134  iteration_proxy_internal& operator++()
    6135  {
    6136  ++anchor;
    6137  ++array_index;
    6138 
    6139  return *this;
    6140  }
    6141 
    6143  bool operator!= (const iteration_proxy_internal& o) const
    6144  {
    6145  return anchor != o.anchor;
    6146  }
    6147 
    6149  typename basic_json::string_t key() const
    6150  {
    6151  assert(anchor.m_object != nullptr);
    6152 
    6153  switch (anchor.m_object->type())
    6154  {
    6155  // use integer array index as key
    6156  case value_t::array:
    6157  {
    6158  return std::to_string(array_index);
    6159  }
    6160 
    6161  // use key from the object
    6162  case value_t::object:
    6163  {
    6164  return anchor.key();
    6165  }
    6166 
    6167  // use an empty key for all primitive types
    6168  default:
    6169  {
    6170  return "";
    6171  }
    6172  }
    6173  }
    6174 
    6176  typename IteratorType::reference value() const
    6177  {
    6178  return anchor.value();
    6179  }
    6180  };
    6181 
    6183  typename IteratorType::reference container;
    6184 
    6185  public:
    6187  iteration_proxy(typename IteratorType::reference cont)
    6188  : container(cont)
    6189  {}
    6190 
    6192  iteration_proxy_internal begin()
    6193  {
    6194  return iteration_proxy_internal(container.begin());
    6195  }
    6196 
    6198  iteration_proxy_internal end()
    6199  {
    6200  return iteration_proxy_internal(container.end());
    6201  }
    6202  };
    6203 
    6204  public:
    6218  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    6219  {
    6221  friend class basic_json;
    6222 
    6223  public:
    6233  using iterator_category = std::bidirectional_iterator_tag;
    6234 
    6236  const_iterator() = default;
    6237 
    6239  const_iterator(pointer object) : m_object(object)
    6240  {
    6241  assert(m_object != nullptr);
    6242 
    6243  switch (m_object->m_type)
    6244  {
    6246  {
    6247  m_it.object_iterator = typename object_t::iterator();
    6248  break;
    6249  }
    6250 
    6252  {
    6253  m_it.array_iterator = typename array_t::iterator();
    6254  break;
    6255  }
    6256 
    6257  default:
    6258  {
    6259  m_it.primitive_iterator = primitive_iterator_t();
    6260  break;
    6261  }
    6262  }
    6263  }
    6264 
    6266  const_iterator(const iterator& other) : m_object(other.m_object)
    6267  {
    6268  assert(m_object != nullptr);
    6269 
    6270  switch (m_object->m_type)
    6271  {
    6273  {
    6274  m_it.object_iterator = other.m_it.object_iterator;
    6275  break;
    6276  }
    6277 
    6279  {
    6280  m_it.array_iterator = other.m_it.array_iterator;
    6281  break;
    6282  }
    6283 
    6284  default:
    6285  {
    6286  m_it.primitive_iterator = other.m_it.primitive_iterator;
    6287  break;
    6288  }
    6289  }
    6290  }
    6291 
    6293  const_iterator(const const_iterator& other) noexcept
    6294  : m_object(other.m_object), m_it(other.m_it)
    6295  {}
    6296 
    6299  std::is_nothrow_move_constructible<pointer>::value and
    6300  std::is_nothrow_move_assignable<pointer>::value and
    6301  std::is_nothrow_move_constructible<internal_iterator>::value and
    6302  std::is_nothrow_move_assignable<internal_iterator>::value
    6303  )
    6304  {
    6305  std::swap(m_object, other.m_object);
    6306  std::swap(m_it, other.m_it);
    6307  return *this;
    6308  }
    6309 
    6310  private:
    6312  void set_begin()
    6313  {
    6314  assert(m_object != nullptr);
    6315 
    6316  switch (m_object->m_type)
    6317  {
    6319  {
    6320  assert(m_object->m_value.object != nullptr);
    6321  m_it.object_iterator = m_object->m_value.object->begin();
    6322  break;
    6323  }
    6324 
    6326  {
    6327  assert(m_object->m_value.array != nullptr);
    6328  m_it.array_iterator = m_object->m_value.array->begin();
    6329  break;
    6330  }
    6331 
    6333  {
    6334  // set to end so begin()==end() is true: null is empty
    6335  m_it.primitive_iterator.set_end();
    6336  break;
    6337  }
    6338 
    6339  default:
    6340  {
    6341  m_it.primitive_iterator.set_begin();
    6342  break;
    6343  }
    6344  }
    6345  }
    6346 
    6348  void set_end()
    6349  {
    6350  assert(m_object != nullptr);
    6351 
    6352  switch (m_object->m_type)
    6353  {
    6355  {
    6356  assert(m_object->m_value.object != nullptr);
    6357  m_it.object_iterator = m_object->m_value.object->end();
    6358  break;
    6359  }
    6360 
    6362  {
    6363  assert(m_object->m_value.array != nullptr);
    6364  m_it.array_iterator = m_object->m_value.array->end();
    6365  break;
    6366  }
    6367 
    6368  default:
    6369  {
    6370  m_it.primitive_iterator.set_end();
    6371  break;
    6372  }
    6373  }
    6374  }
    6375 
    6376  public:
    6379  {
    6380  assert(m_object != nullptr);
    6381 
    6382  switch (m_object->m_type)
    6383  {
    6385  {
    6386  assert(m_object->m_value.object);
    6387  assert(m_it.object_iterator != m_object->m_value.object->end());
    6388  return m_it.object_iterator->second;
    6389  }
    6390 
    6392  {
    6393  assert(m_object->m_value.array);
    6394  assert(m_it.array_iterator != m_object->m_value.array->end());
    6395  return *m_it.array_iterator;
    6396  }
    6397 
    6399  {
    6400  throw std::out_of_range("cannot get value");
    6401  }
    6402 
    6403  default:
    6404  {
    6405  if (m_it.primitive_iterator.is_begin())
    6406  {
    6407  return *m_object;
    6408  }
    6409  else
    6410  {
    6411  throw std::out_of_range("cannot get value");
    6412  }
    6413  }
    6414  }
    6415  }
    6416 
    6419  {
    6420  assert(m_object != nullptr);
    6421 
    6422  switch (m_object->m_type)
    6423  {
    6425  {
    6426  assert(m_object->m_value.object);
    6427  assert(m_it.object_iterator != m_object->m_value.object->end());
    6428  return &(m_it.object_iterator->second);
    6429  }
    6430 
    6432  {
    6433  assert(m_object->m_value.array);
    6434  assert(m_it.array_iterator != m_object->m_value.array->end());
    6435  return &*m_it.array_iterator;
    6436  }
    6437 
    6438  default:
    6439  {
    6440  if (m_it.primitive_iterator.is_begin())
    6441  {
    6442  return m_object;
    6443  }
    6444  else
    6445  {
    6446  throw std::out_of_range("cannot get value");
    6447  }
    6448  }
    6449  }
    6450  }
    6451 
    6454  {
    6455  auto result = *this;
    6456  ++(*this);
    6457  return result;
    6458  }
    6459 
    6462  {
    6463  assert(m_object != nullptr);
    6464 
    6465  switch (m_object->m_type)
    6466  {
    6468  {
    6469  ++m_it.object_iterator;
    6470  break;
    6471  }
    6472 
    6474  {
    6475  ++m_it.array_iterator;
    6476  break;
    6477  }
    6478 
    6479  default:
    6480  {
    6481  ++m_it.primitive_iterator;
    6482  break;
    6483  }
    6484  }
    6485 
    6486  return *this;
    6487  }
    6488 
    6491  {
    6492  auto result = *this;
    6493  --(*this);
    6494  return result;
    6495  }
    6496 
    6499  {
    6500  assert(m_object != nullptr);
    6501 
    6502  switch (m_object->m_type)
    6503  {
    6505  {
    6506  --m_it.object_iterator;
    6507  break;
    6508  }
    6509 
    6511  {
    6512  --m_it.array_iterator;
    6513  break;
    6514  }
    6515 
    6516  default:
    6517  {
    6518  --m_it.primitive_iterator;
    6519  break;
    6520  }
    6521  }
    6522 
    6523  return *this;
    6524  }
    6525 
    6527  bool operator==(const const_iterator& other) const
    6528  {
    6529  // if objects are not the same, the comparison is undefined
    6530  if (m_object != other.m_object)
    6531  {
    6532  throw std::domain_error("cannot compare iterators of different containers");
    6533  }
    6534 
    6535  assert(m_object != nullptr);
    6536 
    6537  switch (m_object->m_type)
    6538  {
    6540  {
    6541  return (m_it.object_iterator == other.m_it.object_iterator);
    6542  }
    6543 
    6545  {
    6546  return (m_it.array_iterator == other.m_it.array_iterator);
    6547  }
    6548 
    6549  default:
    6550  {
    6551  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6552  }
    6553  }
    6554  }
    6555 
    6557  bool operator!=(const const_iterator& other) const
    6558  {
    6559  return not operator==(other);
    6560  }
    6561 
    6563  bool operator<(const const_iterator& other) const
    6564  {
    6565  // if objects are not the same, the comparison is undefined
    6566  if (m_object != other.m_object)
    6567  {
    6568  throw std::domain_error("cannot compare iterators of different containers");
    6569  }
    6570 
    6571  assert(m_object != nullptr);
    6572 
    6573  switch (m_object->m_type)
    6574  {
    6576  {
    6577  throw std::domain_error("cannot compare order of object iterators");
    6578  }
    6579 
    6581  {
    6582  return (m_it.array_iterator < other.m_it.array_iterator);
    6583  }
    6584 
    6585  default:
    6586  {
    6587  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6588  }
    6589  }
    6590  }
    6591 
    6593  bool operator<=(const const_iterator& other) const
    6594  {
    6595  return not other.operator < (*this);
    6596  }
    6597 
    6599  bool operator>(const const_iterator& other) const
    6600  {
    6601  return not operator<=(other);
    6602  }
    6603 
    6605  bool operator>=(const const_iterator& other) const
    6606  {
    6607  return not operator<(other);
    6608  }
    6609 
    6612  {
    6613  assert(m_object != nullptr);
    6614 
    6615  switch (m_object->m_type)
    6616  {
    6618  {
    6619  throw std::domain_error("cannot use offsets with object iterators");
    6620  }
    6621 
    6623  {
    6624  m_it.array_iterator += i;
    6625  break;
    6626  }
    6627 
    6628  default:
    6629  {
    6630  m_it.primitive_iterator += i;
    6631  break;
    6632  }
    6633  }
    6634 
    6635  return *this;
    6636  }
    6637 
    6640  {
    6641  return operator+=(-i);
    6642  }
    6643 
    6646  {
    6647  auto result = *this;
    6648  result += i;
    6649  return result;
    6650  }
    6651 
    6654  {
    6655  auto result = *this;
    6656  result -= i;
    6657  return result;
    6658  }
    6659 
    6662  {
    6663  assert(m_object != nullptr);
    6664 
    6665  switch (m_object->m_type)
    6666  {
    6668  {
    6669  throw std::domain_error("cannot use offsets with object iterators");
    6670  }
    6671 
    6673  {
    6674  return m_it.array_iterator - other.m_it.array_iterator;
    6675  }
    6676 
    6677  default:
    6678  {
    6679  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6680  }
    6681  }
    6682  }
    6683 
    6686  {
    6687  assert(m_object != nullptr);
    6688 
    6689  switch (m_object->m_type)
    6690  {
    6692  {
    6693  throw std::domain_error("cannot use operator[] for object iterators");
    6694  }
    6695 
    6697  {
    6698  return *(m_it.array_iterator + n);
    6699  }
    6700 
    6702  {
    6703  throw std::out_of_range("cannot get value");
    6704  }
    6705 
    6706  default:
    6707  {
    6708  if (m_it.primitive_iterator == -n)
    6709  {
    6710  return *m_object;
    6711  }
    6712  else
    6713  {
    6714  throw std::out_of_range("cannot get value");
    6715  }
    6716  }
    6717  }
    6718  }
    6719 
    6721  typename object_t::key_type key() const
    6722  {
    6723  assert(m_object != nullptr);
    6724 
    6725  if (m_object->is_object())
    6726  {
    6727  return m_it.object_iterator->first;
    6728  }
    6729  else
    6730  {
    6731  throw std::domain_error("cannot use key() for non-object iterators");
    6732  }
    6733  }
    6734 
    6737  {
    6738  return operator*();
    6739  }
    6740 
    6741  private:
    6743  pointer m_object = nullptr;
    6745  internal_iterator m_it = internal_iterator();
    6746  };
    6747 
    6760  class iterator : public const_iterator
    6761  {
    6762  public:
    6764  using pointer = typename basic_json::pointer;
    6766 
    6768  iterator() = default;
    6769 
    6771  iterator(pointer object) noexcept
    6772  : base_iterator(object)
    6773  {}
    6774 
    6776  iterator(const iterator& other) noexcept
    6777  : base_iterator(other)
    6778  {}
    6779 
    6781  iterator& operator=(iterator other) noexcept(
    6782  std::is_nothrow_move_constructible<pointer>::value and
    6783  std::is_nothrow_move_assignable<pointer>::value and
    6784  std::is_nothrow_move_constructible<internal_iterator>::value and
    6785  std::is_nothrow_move_assignable<internal_iterator>::value
    6786  )
    6787  {
    6788  base_iterator::operator=(other);
    6789  return *this;
    6790  }
    6791 
    6794  {
    6795  return const_cast<reference>(base_iterator::operator*());
    6796  }
    6797 
    6800  {
    6801  return const_cast<pointer>(base_iterator::operator->());
    6802  }
    6803 
    6806  {
    6807  iterator result = *this;
    6808  base_iterator::operator++();
    6809  return result;
    6810  }
    6811 
    6814  {
    6815  base_iterator::operator++();
    6816  return *this;
    6817  }
    6818 
    6821  {
    6822  iterator result = *this;
    6823  base_iterator::operator--();
    6824  return result;
    6825  }
    6826 
    6829  {
    6830  base_iterator::operator--();
    6831  return *this;
    6832  }
    6833 
    6836  {
    6837  base_iterator::operator+=(i);
    6838  return *this;
    6839  }
    6840 
    6843  {
    6844  base_iterator::operator-=(i);
    6845  return *this;
    6846  }
    6847 
    6850  {
    6851  auto result = *this;
    6852  result += i;
    6853  return result;
    6854  }
    6855 
    6858  {
    6859  auto result = *this;
    6860  result -= i;
    6861  return result;
    6862  }
    6863 
    6865  difference_type operator-(const iterator& other) const
    6866  {
    6867  return base_iterator::operator-(other);
    6868  }
    6869 
    6872  {
    6873  return const_cast<reference>(base_iterator::operator[](n));
    6874  }
    6875 
    6878  {
    6879  return const_cast<reference>(base_iterator::value());
    6880  }
    6881  };
    6882 
    6900  template<typename Base>
    6901  class json_reverse_iterator : public std::reverse_iterator<Base>
    6902  {
    6903  public:
    6905  using base_iterator = std::reverse_iterator<Base>;
    6907  using reference = typename Base::reference;
    6908 
    6910  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6911  : base_iterator(it)
    6912  {}
    6913 
    6916  : base_iterator(it)
    6917  {}
    6918 
    6921  {
    6922  return base_iterator::operator++(1);
    6923  }
    6924 
    6927  {
    6928  base_iterator::operator++();
    6929  return *this;
    6930  }
    6931 
    6934  {
    6935  return base_iterator::operator--(1);
    6936  }
    6937 
    6940  {
    6941  base_iterator::operator--();
    6942  return *this;
    6943  }
    6944 
    6947  {
    6948  base_iterator::operator+=(i);
    6949  return *this;
    6950  }
    6951 
    6954  {
    6955  auto result = *this;
    6956  result += i;
    6957  return result;
    6958  }
    6959 
    6962  {
    6963  auto result = *this;
    6964  result -= i;
    6965  return result;
    6966  }
    6967 
    6970  {
    6971  return this->base() - other.base();
    6972  }
    6973 
    6976  {
    6977  return *(this->operator+(n));
    6978  }
    6979 
    6981  typename object_t::key_type key() const
    6982  {
    6983  auto it = --this->base();
    6984  return it.key();
    6985  }
    6986 
    6989  {
    6990  auto it = --this->base();
    6991  return it.operator * ();
    6992  }
    6993  };
    6994 
    6995 
    6996  private:
    6998  // lexer and parser //
    7000 
    7008  class lexer
    7009  {
    7010  public:
    7012  enum class token_type
    7013  {
    7014  uninitialized,
    7015  literal_true,
    7016  literal_false,
    7017  literal_null,
    7018  value_string,
    7019  value_number,
    7020  begin_array,
    7021  begin_object,
    7022  end_array,
    7023  end_object,
    7024  name_separator,
    7025  value_separator,
    7026  parse_error,
    7027  end_of_input
    7028  };
    7029 
    7031  using lexer_char_t = unsigned char;
    7032 
    7034  explicit lexer(const string_t& s) noexcept
    7035  : m_stream(nullptr), m_buffer(s)
    7036  {
    7037  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    7038  assert(m_content != nullptr);
    7039  m_start = m_cursor = m_content;
    7040  m_limit = m_content + s.size();
    7041  }
    7042 
    7044  explicit lexer(std::istream* s) noexcept
    7045  : m_stream(s), m_buffer()
    7046  {
    7047  assert(m_stream != nullptr);
    7048  getline(*m_stream, m_buffer);
    7049  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7050  assert(m_content != nullptr);
    7051  m_start = m_cursor = m_content;
    7052  m_limit = m_content + m_buffer.size();
    7053  }
    7054 
    7056  lexer() = default;
    7057 
    7058  // switch off unwanted functions
    7059  lexer(const lexer&) = delete;
    7060  lexer operator=(const lexer&) = delete;
    7061 
    7077  static string_t to_unicode(const std::size_t codepoint1,
    7078  const std::size_t codepoint2 = 0)
    7079  {
    7080  // calculate the codepoint from the given code points
    7081  std::size_t codepoint = codepoint1;
    7082 
    7083  // check if codepoint1 is a high surrogate
    7084  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    7085  {
    7086  // check if codepoint2 is a low surrogate
    7087  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    7088  {
    7089  codepoint =
    7090  // high surrogate occupies the most significant 22 bits
    7091  (codepoint1 << 10)
    7092  // low surrogate occupies the least significant 15 bits
    7093  + codepoint2
    7094  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    7095  // in the result so we have to subtract with:
    7096  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    7097  - 0x35FDC00;
    7098  }
    7099  else
    7100  {
    7101  throw std::invalid_argument("missing or wrong low surrogate");
    7102  }
    7103  }
    7104 
    7105  string_t result;
    7106 
    7107  if (codepoint < 0x80)
    7108  {
    7109  // 1-byte characters: 0xxxxxxx (ASCII)
    7110  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    7111  }
    7112  else if (codepoint <= 0x7ff)
    7113  {
    7114  // 2-byte characters: 110xxxxx 10xxxxxx
    7115  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    7116  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7117  }
    7118  else if (codepoint <= 0xffff)
    7119  {
    7120  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    7121  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    7122  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7123  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7124  }
    7125  else if (codepoint <= 0x10ffff)
    7126  {
    7127  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    7128  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    7129  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    7130  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7131  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7132  }
    7133  else
    7134  {
    7135  throw std::out_of_range("code points above 0x10FFFF are invalid");
    7136  }
    7137 
    7138  return result;
    7139  }
    7140 
    7142  static std::string token_type_name(token_type t)
    7143  {
    7144  switch (t)
    7145  {
    7146  case token_type::uninitialized:
    7147  return "<uninitialized>";
    7148  case token_type::literal_true:
    7149  return "true literal";
    7150  case token_type::literal_false:
    7151  return "false literal";
    7152  case token_type::literal_null:
    7153  return "null literal";
    7154  case token_type::value_string:
    7155  return "string literal";
    7156  case token_type::value_number:
    7157  return "number literal";
    7158  case token_type::begin_array:
    7159  return "'['";
    7160  case token_type::begin_object:
    7161  return "'{'";
    7162  case token_type::end_array:
    7163  return "']'";
    7164  case token_type::end_object:
    7165  return "'}'";
    7166  case token_type::name_separator:
    7167  return "':'";
    7168  case token_type::value_separator:
    7169  return "','";
    7170  case token_type::parse_error:
    7171  return "<parse error>";
    7172  case token_type::end_of_input:
    7173  return "end of input";
    7174  default:
    7175  {
    7176  // catch non-enum values
    7177  return "unknown token"; // LCOV_EXCL_LINE
    7178  }
    7179  }
    7180  }
    7181 
    7192  token_type scan() noexcept
    7193  {
    7194  // pointer for backtracking information
    7195  m_marker = nullptr;
    7196 
    7197  // remember the begin of the token
    7198  m_start = m_cursor;
    7199  assert(m_start != nullptr);
    7200 
    7201 
    7202  {
    7203  lexer_char_t yych;
    7204  unsigned int yyaccept = 0;
    7205  static const unsigned char yybm[] =
    7206  {
    7207  0, 0, 0, 0, 0, 0, 0, 0,
    7208  0, 32, 32, 0, 0, 32, 0, 0,
    7209  128, 128, 128, 128, 128, 128, 128, 128,
    7210  128, 128, 128, 128, 128, 128, 128, 128,
    7211  160, 128, 0, 128, 128, 128, 128, 128,
    7212  128, 128, 128, 128, 128, 128, 128, 128,
    7213  192, 192, 192, 192, 192, 192, 192, 192,
    7214  192, 192, 128, 128, 128, 128, 128, 128,
    7215  128, 128, 128, 128, 128, 128, 128, 128,
    7216  128, 128, 128, 128, 128, 128, 128, 128,
    7217  128, 128, 128, 128, 128, 128, 128, 128,
    7218  128, 128, 128, 128, 0, 128, 128, 128,
    7219  128, 128, 128, 128, 128, 128, 128, 128,
    7220  128, 128, 128, 128, 128, 128, 128, 128,
    7221  128, 128, 128, 128, 128, 128, 128, 128,
    7222  128, 128, 128, 128, 128, 128, 128, 128,
    7223  128, 128, 128, 128, 128, 128, 128, 128,
    7224  128, 128, 128, 128, 128, 128, 128, 128,
    7225  128, 128, 128, 128, 128, 128, 128, 128,
    7226  128, 128, 128, 128, 128, 128, 128, 128,
    7227  128, 128, 128, 128, 128, 128, 128, 128,
    7228  128, 128, 128, 128, 128, 128, 128, 128,
    7229  128, 128, 128, 128, 128, 128, 128, 128,
    7230  128, 128, 128, 128, 128, 128, 128, 128,
    7231  128, 128, 128, 128, 128, 128, 128, 128,
    7232  128, 128, 128, 128, 128, 128, 128, 128,
    7233  128, 128, 128, 128, 128, 128, 128, 128,
    7234  128, 128, 128, 128, 128, 128, 128, 128,
    7235  128, 128, 128, 128, 128, 128, 128, 128,
    7236  128, 128, 128, 128, 128, 128, 128, 128,
    7237  128, 128, 128, 128, 128, 128, 128, 128,
    7238  128, 128, 128, 128, 128, 128, 128, 128,
    7239  };
    7240  if ((m_limit - m_cursor) < 5)
    7241  {
    7242  yyfill(); // LCOV_EXCL_LINE;
    7243  }
    7244  yych = *m_cursor;
    7245  if (yybm[0 + yych] & 32)
    7246  {
    7247  goto basic_json_parser_6;
    7248  }
    7249  if (yych <= '\\')
    7250  {
    7251  if (yych <= '-')
    7252  {
    7253  if (yych <= '"')
    7254  {
    7255  if (yych <= 0x00)
    7256  {
    7257  goto basic_json_parser_2;
    7258  }
    7259  if (yych <= '!')
    7260  {
    7261  goto basic_json_parser_4;
    7262  }
    7263  goto basic_json_parser_9;
    7264  }
    7265  else
    7266  {
    7267  if (yych <= '+')
    7268  {
    7269  goto basic_json_parser_4;
    7270  }
    7271  if (yych <= ',')
    7272  {
    7273  goto basic_json_parser_10;
    7274  }
    7275  goto basic_json_parser_12;
    7276  }
    7277  }
    7278  else
    7279  {
    7280  if (yych <= '9')
    7281  {
    7282  if (yych <= '/')
    7283  {
    7284  goto basic_json_parser_4;
    7285  }
    7286  if (yych <= '0')
    7287  {
    7288  goto basic_json_parser_13;
    7289  }
    7290  goto basic_json_parser_15;
    7291  }
    7292  else
    7293  {
    7294  if (yych <= ':')
    7295  {
    7296  goto basic_json_parser_17;
    7297  }
    7298  if (yych == '[')
    7299  {
    7300  goto basic_json_parser_19;
    7301  }
    7302  goto basic_json_parser_4;
    7303  }
    7304  }
    7305  }
    7306  else
    7307  {
    7308  if (yych <= 't')
    7309  {
    7310  if (yych <= 'f')
    7311  {
    7312  if (yych <= ']')
    7313  {
    7314  goto basic_json_parser_21;
    7315  }
    7316  if (yych <= 'e')
    7317  {
    7318  goto basic_json_parser_4;
    7319  }
    7320  goto basic_json_parser_23;
    7321  }
    7322  else
    7323  {
    7324  if (yych == 'n')
    7325  {
    7326  goto basic_json_parser_24;
    7327  }
    7328  if (yych <= 's')
    7329  {
    7330  goto basic_json_parser_4;
    7331  }
    7332  goto basic_json_parser_25;
    7333  }
    7334  }
    7335  else
    7336  {
    7337  if (yych <= '|')
    7338  {
    7339  if (yych == '{')
    7340  {
    7341  goto basic_json_parser_26;
    7342  }
    7343  goto basic_json_parser_4;
    7344  }
    7345  else
    7346  {
    7347  if (yych <= '}')
    7348  {
    7349  goto basic_json_parser_28;
    7350  }
    7351  if (yych == 0xEF)
    7352  {
    7353  goto basic_json_parser_30;
    7354  }
    7355  goto basic_json_parser_4;
    7356  }
    7357  }
    7358  }
    7359 basic_json_parser_2:
    7360  ++m_cursor;
    7361  {
    7362  return token_type::end_of_input;
    7363  }
    7364 basic_json_parser_4:
    7365  ++m_cursor;
    7366 basic_json_parser_5:
    7367  {
    7368  return token_type::parse_error;
    7369  }
    7370 basic_json_parser_6:
    7371  ++m_cursor;
    7372  if (m_limit <= m_cursor)
    7373  {
    7374  yyfill(); // LCOV_EXCL_LINE;
    7375  }
    7376  yych = *m_cursor;
    7377  if (yybm[0 + yych] & 32)
    7378  {
    7379  goto basic_json_parser_6;
    7380  }
    7381  {
    7382  return scan();
    7383  }
    7384 basic_json_parser_9:
    7385  yyaccept = 0;
    7386  yych = *(m_marker = ++m_cursor);
    7387  if (yych <= 0x0F)
    7388  {
    7389  goto basic_json_parser_5;
    7390  }
    7391  goto basic_json_parser_32;
    7392 basic_json_parser_10:
    7393  ++m_cursor;
    7394  {
    7395  return token_type::value_separator;
    7396  }
    7397 basic_json_parser_12:
    7398  yych = *++m_cursor;
    7399  if (yych <= '/')
    7400  {
    7401  goto basic_json_parser_5;
    7402  }
    7403  if (yych <= '0')
    7404  {
    7405  goto basic_json_parser_13;
    7406  }
    7407  if (yych <= '9')
    7408  {
    7409  goto basic_json_parser_15;
    7410  }
    7411  goto basic_json_parser_5;
    7412 basic_json_parser_13:
    7413  yyaccept = 1;
    7414  yych = *(m_marker = ++m_cursor);
    7415  if (yych <= 'D')
    7416  {
    7417  if (yych == '.')
    7418  {
    7419  goto basic_json_parser_37;
    7420  }
    7421  }
    7422  else
    7423  {
    7424  if (yych <= 'E')
    7425  {
    7426  goto basic_json_parser_38;
    7427  }
    7428  if (yych == 'e')
    7429  {
    7430  goto basic_json_parser_38;
    7431  }
    7432  }
    7433 basic_json_parser_14:
    7434  {
    7435  return token_type::value_number;
    7436  }
    7437 basic_json_parser_15:
    7438  yyaccept = 1;
    7439  m_marker = ++m_cursor;
    7440  if ((m_limit - m_cursor) < 3)
    7441  {
    7442  yyfill(); // LCOV_EXCL_LINE;
    7443  }
    7444  yych = *m_cursor;
    7445  if (yybm[0 + yych] & 64)
    7446  {
    7447  goto basic_json_parser_15;
    7448  }
    7449  if (yych <= 'D')
    7450  {
    7451  if (yych == '.')
    7452  {
    7453  goto basic_json_parser_37;
    7454  }
    7455  goto basic_json_parser_14;
    7456  }
    7457  else
    7458  {
    7459  if (yych <= 'E')
    7460  {
    7461  goto basic_json_parser_38;
    7462  }
    7463  if (yych == 'e')
    7464  {
    7465  goto basic_json_parser_38;
    7466  }
    7467  goto basic_json_parser_14;
    7468  }
    7469 basic_json_parser_17:
    7470  ++m_cursor;
    7471  {
    7472  return token_type::name_separator;
    7473  }
    7474 basic_json_parser_19:
    7475  ++m_cursor;
    7476  {
    7477  return token_type::begin_array;
    7478  }
    7479 basic_json_parser_21:
    7480  ++m_cursor;
    7481  {
    7482  return token_type::end_array;
    7483  }
    7484 basic_json_parser_23:
    7485  yyaccept = 0;
    7486  yych = *(m_marker = ++m_cursor);
    7487  if (yych == 'a')
    7488  {
    7489  goto basic_json_parser_39;
    7490  }
    7491  goto basic_json_parser_5;
    7492 basic_json_parser_24:
    7493  yyaccept = 0;
    7494  yych = *(m_marker = ++m_cursor);
    7495  if (yych == 'u')
    7496  {
    7497  goto basic_json_parser_40;
    7498  }
    7499  goto basic_json_parser_5;
    7500 basic_json_parser_25:
    7501  yyaccept = 0;
    7502  yych = *(m_marker = ++m_cursor);
    7503  if (yych == 'r')
    7504  {
    7505  goto basic_json_parser_41;
    7506  }
    7507  goto basic_json_parser_5;
    7508 basic_json_parser_26:
    7509  ++m_cursor;
    7510  {
    7511  return token_type::begin_object;
    7512  }
    7513 basic_json_parser_28:
    7514  ++m_cursor;
    7515  {
    7516  return token_type::end_object;
    7517  }
    7518 basic_json_parser_30:
    7519  yyaccept = 0;
    7520  yych = *(m_marker = ++m_cursor);
    7521  if (yych == 0xBB)
    7522  {
    7523  goto basic_json_parser_42;
    7524  }
    7525  goto basic_json_parser_5;
    7526 basic_json_parser_31:
    7527  ++m_cursor;
    7528  if (m_limit <= m_cursor)
    7529  {
    7530  yyfill(); // LCOV_EXCL_LINE;
    7531  }
    7532  yych = *m_cursor;
    7533 basic_json_parser_32:
    7534  if (yybm[0 + yych] & 128)
    7535  {
    7536  goto basic_json_parser_31;
    7537  }
    7538  if (yych <= 0x0F)
    7539  {
    7540  goto basic_json_parser_33;
    7541  }
    7542  if (yych <= '"')
    7543  {
    7544  goto basic_json_parser_34;
    7545  }
    7546  goto basic_json_parser_36;
    7547 basic_json_parser_33:
    7548  m_cursor = m_marker;
    7549  if (yyaccept == 0)
    7550  {
    7551  goto basic_json_parser_5;
    7552  }
    7553  else
    7554  {
    7555  goto basic_json_parser_14;
    7556  }
    7557 basic_json_parser_34:
    7558  ++m_cursor;
    7559  {
    7560  return token_type::value_string;
    7561  }
    7562 basic_json_parser_36:
    7563  ++m_cursor;
    7564  if (m_limit <= m_cursor)
    7565  {
    7566  yyfill(); // LCOV_EXCL_LINE;
    7567  }
    7568  yych = *m_cursor;
    7569  if (yych <= 'e')
    7570  {
    7571  if (yych <= '/')
    7572  {
    7573  if (yych == '"')
    7574  {
    7575  goto basic_json_parser_31;
    7576  }
    7577  if (yych <= '.')
    7578  {
    7579  goto basic_json_parser_33;
    7580  }
    7581  goto basic_json_parser_31;
    7582  }
    7583  else
    7584  {
    7585  if (yych <= '\\')
    7586  {
    7587  if (yych <= '[')
    7588  {
    7589  goto basic_json_parser_33;
    7590  }
    7591  goto basic_json_parser_31;
    7592  }
    7593  else
    7594  {
    7595  if (yych == 'b')
    7596  {
    7597  goto basic_json_parser_31;
    7598  }
    7599  goto basic_json_parser_33;
    7600  }
    7601  }
    7602  }
    7603  else
    7604  {
    7605  if (yych <= 'q')
    7606  {
    7607  if (yych <= 'f')
    7608  {
    7609  goto basic_json_parser_31;
    7610  }
    7611  if (yych == 'n')
    7612  {
    7613  goto basic_json_parser_31;
    7614  }
    7615  goto basic_json_parser_33;
    7616  }
    7617  else
    7618  {
    7619  if (yych <= 's')
    7620  {
    7621  if (yych <= 'r')
    7622  {
    7623  goto basic_json_parser_31;
    7624  }
    7625  goto basic_json_parser_33;
    7626  }
    7627  else
    7628  {
    7629  if (yych <= 't')
    7630  {
    7631  goto basic_json_parser_31;
    7632  }
    7633  if (yych <= 'u')
    7634  {
    7635  goto basic_json_parser_43;
    7636  }
    7637  goto basic_json_parser_33;
    7638  }
    7639  }
    7640  }
    7641 basic_json_parser_37:
    7642  yych = *++m_cursor;
    7643  if (yych <= '/')
    7644  {
    7645  goto basic_json_parser_33;
    7646  }
    7647  if (yych <= '9')
    7648  {
    7649  goto basic_json_parser_44;
    7650  }
    7651  goto basic_json_parser_33;
    7652 basic_json_parser_38:
    7653  yych = *++m_cursor;
    7654  if (yych <= ',')
    7655  {
    7656  if (yych == '+')
    7657  {
    7658  goto basic_json_parser_46;
    7659  }
    7660  goto basic_json_parser_33;
    7661  }
    7662  else
    7663  {
    7664  if (yych <= '-')
    7665  {
    7666  goto basic_json_parser_46;
    7667  }
    7668  if (yych <= '/')
    7669  {
    7670  goto basic_json_parser_33;
    7671  }
    7672  if (yych <= '9')
    7673  {
    7674  goto basic_json_parser_47;
    7675  }
    7676  goto basic_json_parser_33;
    7677  }
    7678 basic_json_parser_39:
    7679  yych = *++m_cursor;
    7680  if (yych == 'l')
    7681  {
    7682  goto basic_json_parser_49;
    7683  }
    7684  goto basic_json_parser_33;
    7685 basic_json_parser_40:
    7686  yych = *++m_cursor;
    7687  if (yych == 'l')
    7688  {
    7689  goto basic_json_parser_50;
    7690  }
    7691  goto basic_json_parser_33;
    7692 basic_json_parser_41:
    7693  yych = *++m_cursor;
    7694  if (yych == 'u')
    7695  {
    7696  goto basic_json_parser_51;
    7697  }
    7698  goto basic_json_parser_33;
    7699 basic_json_parser_42:
    7700  yych = *++m_cursor;
    7701  if (yych == 0xBF)
    7702  {
    7703  goto basic_json_parser_52;
    7704  }
    7705  goto basic_json_parser_33;
    7706 basic_json_parser_43:
    7707  ++m_cursor;
    7708  if (m_limit <= m_cursor)
    7709  {
    7710  yyfill(); // LCOV_EXCL_LINE;
    7711  }
    7712  yych = *m_cursor;
    7713  if (yych <= '@')
    7714  {
    7715  if (yych <= '/')
    7716  {
    7717  goto basic_json_parser_33;
    7718  }
    7719  if (yych <= '9')
    7720  {
    7721  goto basic_json_parser_54;
    7722  }
    7723  goto basic_json_parser_33;
    7724  }
    7725  else
    7726  {
    7727  if (yych <= 'F')
    7728  {
    7729  goto basic_json_parser_54;
    7730  }
    7731  if (yych <= '`')
    7732  {
    7733  goto basic_json_parser_33;
    7734  }
    7735  if (yych <= 'f')
    7736  {
    7737  goto basic_json_parser_54;
    7738  }
    7739  goto basic_json_parser_33;
    7740  }
    7741 basic_json_parser_44:
    7742  yyaccept = 1;
    7743  m_marker = ++m_cursor;
    7744  if ((m_limit - m_cursor) < 3)
    7745  {
    7746  yyfill(); // LCOV_EXCL_LINE;
    7747  }
    7748  yych = *m_cursor;
    7749  if (yych <= 'D')
    7750  {
    7751  if (yych <= '/')
    7752  {
    7753  goto basic_json_parser_14;
    7754  }
    7755  if (yych <= '9')
    7756  {
    7757  goto basic_json_parser_44;
    7758  }
    7759  goto basic_json_parser_14;
    7760  }
    7761  else
    7762  {
    7763  if (yych <= 'E')
    7764  {
    7765  goto basic_json_parser_38;
    7766  }
    7767  if (yych == 'e')
    7768  {
    7769  goto basic_json_parser_38;
    7770  }
    7771  goto basic_json_parser_14;
    7772  }
    7773 basic_json_parser_46:
    7774  yych = *++m_cursor;
    7775  if (yych <= '/')
    7776  {
    7777  goto basic_json_parser_33;
    7778  }
    7779  if (yych >= ':')
    7780  {
    7781  goto basic_json_parser_33;
    7782  }
    7783 basic_json_parser_47:
    7784  ++m_cursor;
    7785  if (m_limit <= m_cursor)
    7786  {
    7787  yyfill(); // LCOV_EXCL_LINE;
    7788  }
    7789  yych = *m_cursor;
    7790  if (yych <= '/')
    7791  {
    7792  goto basic_json_parser_14;
    7793  }
    7794  if (yych <= '9')
    7795  {
    7796  goto basic_json_parser_47;
    7797  }
    7798  goto basic_json_parser_14;
    7799 basic_json_parser_49:
    7800  yych = *++m_cursor;
    7801  if (yych == 's')
    7802  {
    7803  goto basic_json_parser_55;
    7804  }
    7805  goto basic_json_parser_33;
    7806 basic_json_parser_50:
    7807  yych = *++m_cursor;
    7808  if (yych == 'l')
    7809  {
    7810  goto basic_json_parser_56;
    7811  }
    7812  goto basic_json_parser_33;
    7813 basic_json_parser_51:
    7814  yych = *++m_cursor;
    7815  if (yych == 'e')
    7816  {
    7817  goto basic_json_parser_58;
    7818  }
    7819  goto basic_json_parser_33;
    7820 basic_json_parser_52:
    7821  ++m_cursor;
    7822  {
    7823  return scan();
    7824  }
    7825 basic_json_parser_54:
    7826  ++m_cursor;
    7827  if (m_limit <= m_cursor)
    7828  {
    7829  yyfill(); // LCOV_EXCL_LINE;
    7830  }
    7831  yych = *m_cursor;
    7832  if (yych <= '@')
    7833  {
    7834  if (yych <= '/')
    7835  {
    7836  goto basic_json_parser_33;
    7837  }
    7838  if (yych <= '9')
    7839  {
    7840  goto basic_json_parser_60;
    7841  }
    7842  goto basic_json_parser_33;
    7843  }
    7844  else
    7845  {
    7846  if (yych <= 'F')
    7847  {
    7848  goto basic_json_parser_60;
    7849  }
    7850  if (yych <= '`')
    7851  {
    7852  goto basic_json_parser_33;
    7853  }
    7854  if (yych <= 'f')
    7855  {
    7856  goto basic_json_parser_60;
    7857  }
    7858  goto basic_json_parser_33;
    7859  }
    7860 basic_json_parser_55:
    7861  yych = *++m_cursor;
    7862  if (yych == 'e')
    7863  {
    7864  goto basic_json_parser_61;
    7865  }
    7866  goto basic_json_parser_33;
    7867 basic_json_parser_56:
    7868  ++m_cursor;
    7869  {
    7870  return token_type::literal_null;
    7871  }
    7872 basic_json_parser_58:
    7873  ++m_cursor;
    7874  {
    7875  return token_type::literal_true;
    7876  }
    7877 basic_json_parser_60:
    7878  ++m_cursor;
    7879  if (m_limit <= m_cursor)
    7880  {
    7881  yyfill(); // LCOV_EXCL_LINE;
    7882  }
    7883  yych = *m_cursor;
    7884  if (yych <= '@')
    7885  {
    7886  if (yych <= '/')
    7887  {
    7888  goto basic_json_parser_33;
    7889  }
    7890  if (yych <= '9')
    7891  {
    7892  goto basic_json_parser_63;
    7893  }
    7894  goto basic_json_parser_33;
    7895  }
    7896  else
    7897  {
    7898  if (yych <= 'F')
    7899  {
    7900  goto basic_json_parser_63;
    7901  }
    7902  if (yych <= '`')
    7903  {
    7904  goto basic_json_parser_33;
    7905  }
    7906  if (yych <= 'f')
    7907  {
    7908  goto basic_json_parser_63;
    7909  }
    7910  goto basic_json_parser_33;
    7911  }
    7912 basic_json_parser_61:
    7913  ++m_cursor;
    7914  {
    7915  return token_type::literal_false;
    7916  }
    7917 basic_json_parser_63:
    7918  ++m_cursor;
    7919  if (m_limit <= m_cursor)
    7920  {
    7921  yyfill(); // LCOV_EXCL_LINE;
    7922  }
    7923  yych = *m_cursor;
    7924  if (yych <= '@')
    7925  {
    7926  if (yych <= '/')
    7927  {
    7928  goto basic_json_parser_33;
    7929  }
    7930  if (yych <= '9')
    7931  {
    7932  goto basic_json_parser_31;
    7933  }
    7934  goto basic_json_parser_33;
    7935  }
    7936  else
    7937  {
    7938  if (yych <= 'F')
    7939  {
    7940  goto basic_json_parser_31;
    7941  }
    7942  if (yych <= '`')
    7943  {
    7944  goto basic_json_parser_33;
    7945  }
    7946  if (yych <= 'f')
    7947  {
    7948  goto basic_json_parser_31;
    7949  }
    7950  goto basic_json_parser_33;
    7951  }
    7952  }
    7953 
    7954 
    7955  }
    7956 
    7958  void yyfill() noexcept
    7959  {
    7960  if (m_stream == nullptr or not * m_stream)
    7961  {
    7962  return;
    7963  }
    7964 
    7965  const ssize_t offset_start = m_start - m_content;
    7966  const ssize_t offset_marker = m_marker - m_start;
    7967  const ssize_t offset_cursor = m_cursor - m_start;
    7968 
    7969  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7970  std::string line;
    7971  assert(m_stream != nullptr);
    7972  std::getline(*m_stream, line);
    7973  m_buffer += "\n" + line; // add line with newline symbol
    7974 
    7975  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7976  assert(m_content != nullptr);
    7977  m_start = m_content;
    7978  m_marker = m_start + offset_marker;
    7979  m_cursor = m_start + offset_cursor;
    7980  m_limit = m_start + m_buffer.size() - 1;
    7981  }
    7982 
    7984  string_t get_token() const noexcept
    7985  {
    7986  assert(m_start != nullptr);
    7987  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7988  static_cast<size_t>(m_cursor - m_start));
    7989  }
    7990 
    8012  string_t get_string() const
    8013  {
    8014  string_t result;
    8015  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    8016 
    8017  // iterate the result between the quotes
    8018  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    8019  {
    8020  // process escaped characters
    8021  if (*i == '\\')
    8022  {
    8023  // read next character
    8024  ++i;
    8025 
    8026  switch (*i)
    8027  {
    8028  // the default escapes
    8029  case 't':
    8030  {
    8031  result += "\t";
    8032  break;
    8033  }
    8034  case 'b':
    8035  {
    8036  result += "\b";
    8037  break;
    8038  }
    8039  case 'f':
    8040  {
    8041  result += "\f";
    8042  break;
    8043  }
    8044  case 'n':
    8045  {
    8046  result += "\n";
    8047  break;
    8048  }
    8049  case 'r':
    8050  {
    8051  result += "\r";
    8052  break;
    8053  }
    8054  case '\\':
    8055  {
    8056  result += "\\";
    8057  break;
    8058  }
    8059  case '/':
    8060  {
    8061  result += "/";
    8062  break;
    8063  }
    8064  case '"':
    8065  {
    8066  result += "\"";
    8067  break;
    8068  }
    8069 
    8070  // unicode
    8071  case 'u':
    8072  {
    8073  // get code xxxx from uxxxx
    8074  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    8075  4).c_str(), nullptr, 16);
    8076 
    8077  // check if codepoint is a high surrogate
    8078  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    8079  {
    8080  // make sure there is a subsequent unicode
    8081  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    8082  {
    8083  throw std::invalid_argument("missing low surrogate");
    8084  }
    8085 
    8086  // get code yyyy from uxxxx\uyyyy
    8087  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    8088  (i + 7), 4).c_str(), nullptr, 16);
    8089  result += to_unicode(codepoint, codepoint2);
    8090  // skip the next 10 characters (xxxx\uyyyy)
    8091  i += 10;
    8092  }
    8093  else
    8094  {
    8095  // add unicode character(s)
    8096  result += to_unicode(codepoint);
    8097  // skip the next four characters (xxxx)
    8098  i += 4;
    8099  }
    8100  break;
    8101  }
    8102  }
    8103  }
    8104  else
    8105  {
    8106  // all other characters are just copied to the end of the
    8107  // string
    8108  result.append(1, static_cast<typename string_t::value_type>(*i));
    8109  }
    8110  }
    8111 
    8112  return result;
    8113  }
    8114 
    8135  long double str_to_float_t(long double* /* type */, char** endptr) const
    8136  {
    8137  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8138  }
    8139 
    8155  double str_to_float_t(double* /* type */, char** endptr) const
    8156  {
    8157  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8158  }
    8159 
    8175  float str_to_float_t(float* /* type */, char** endptr) const
    8176  {
    8177  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8178  }
    8179 
    8192  template <typename T_A, typename T_B>
    8193  bool attempt_cast(T_A source, T_B& dest) const
    8194  {
    8195  dest = static_cast<T_B>(source);
    8196  return (source == static_cast<T_A>(dest));
    8197  }
    8198 
    8237  void get_number(basic_json& result) const
    8238  {
    8239  typename string_t::value_type* endptr;
    8240  assert(m_start != nullptr);
    8241  errno = 0;
    8242 
    8243  // attempt to parse it as an integer - first checking for a
    8244  // negative number
    8245  if (*reinterpret_cast<typename string_t::const_pointer>(m_start) != '-')
    8246  {
    8247  // positive, parse with strtoull and attempt cast to
    8248  // number_unsigned_t
    8249  if (attempt_cast(std::strtoull(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8250  10), result.m_value.number_unsigned))
    8251  {
    8252  result.m_type = value_t::number_unsigned;
    8253  }
    8254  else
    8255  {
    8256  // cast failed due to overflow - store as float
    8257  result.m_type = value_t::number_float;
    8258  }
    8259  }
    8260  else
    8261  {
    8262  // Negative, parse with strtoll and attempt cast to
    8263  // number_integer_t
    8264  if (attempt_cast(std::strtoll(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8265  10), result.m_value.number_integer))
    8266  {
    8267  result.m_type = value_t::number_integer;
    8268  }
    8269  else
    8270  {
    8271  // cast failed due to overflow - store as float
    8272  result.m_type = value_t::number_float;
    8273  }
    8274  }
    8275 
    8276  // check the end of the number was reached and no range error
    8277  // occurred
    8278  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor || errno == ERANGE)
    8279  {
    8280  result.m_type = value_t::number_float;
    8281  }
    8282 
    8283  if (result.m_type == value_t::number_float)
    8284  {
    8285  // either the number won't fit in an integer (range error from
    8286  // strtoull/strtoll or overflow on cast) or there was something
    8287  // else after the number, which could be an exponent
    8288 
    8289  // parse with strtod
    8290  result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), &endptr);
    8291 
    8292  // anything after the number is an error
    8293  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor)
    8294  {
    8295  throw std::invalid_argument(std::string("parse error - ") + get_token() + " is not a number");
    8296  }
    8297  }
    8298  }
    8299 
    8300  private:
    8302  std::istream* m_stream = nullptr;
    8304  string_t m_buffer;
    8306  const lexer_char_t* m_content = nullptr;
    8308  const lexer_char_t* m_start = nullptr;
    8310  const lexer_char_t* m_marker = nullptr;
    8312  const lexer_char_t* m_cursor = nullptr;
    8314  const lexer_char_t* m_limit = nullptr;
    8315  };
    8316 
    8322  class parser
    8323  {
    8324  public:
    8326  parser(const string_t& s, parser_callback_t cb = nullptr)
    8327  : callback(cb), m_lexer(s)
    8328  {
    8329  // read first token
    8330  get_token();
    8331  }
    8332 
    8334  parser(std::istream& _is, parser_callback_t cb = nullptr)
    8335  : callback(cb), m_lexer(&_is)
    8336  {
    8337  // read first token
    8338  get_token();
    8339  }
    8340 
    8342  basic_json parse()
    8343  {
    8344  basic_json result = parse_internal(true);
    8345 
    8346  expect(lexer::token_type::end_of_input);
    8347 
    8348  // return parser result and replace it with null in case the
    8349  // top-level value was discarded by the callback function
    8350  return result.is_discarded() ? basic_json() : result;
    8351  }
    8352 
    8353  private:
    8355  basic_json parse_internal(bool keep)
    8356  {
    8357  auto result = basic_json(value_t::discarded);
    8358 
    8359  switch (last_token)
    8360  {
    8361  case lexer::token_type::begin_object:
    8362  {
    8363  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    8364  {
    8365  // explicitly set result to object to cope with {}
    8366  result.m_type = value_t::object;
    8367  result.m_value = json_value(value_t::object);
    8368  }
    8369 
    8370  // read next token
    8371  get_token();
    8372 
    8373  // closing } -> we are done
    8374  if (last_token == lexer::token_type::end_object)
    8375  {
    8376  get_token();
    8377  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8378  {
    8379  result = basic_json(value_t::discarded);
    8380  }
    8381  return result;
    8382  }
    8383 
    8384  // no comma is expected here
    8385  unexpect(lexer::token_type::value_separator);
    8386 
    8387  // otherwise: parse key-value pairs
    8388  do
    8389  {
    8390  // ugly, but could be fixed with loop reorganization
    8391  if (last_token == lexer::token_type::value_separator)
    8392  {
    8393  get_token();
    8394  }
    8395 
    8396  // store key
    8397  expect(lexer::token_type::value_string);
    8398  const auto key = m_lexer.get_string();
    8399 
    8400  bool keep_tag = false;
    8401  if (keep)
    8402  {
    8403  if (callback)
    8404  {
    8405  basic_json k(key);
    8406  keep_tag = callback(depth, parse_event_t::key, k);
    8407  }
    8408  else
    8409  {
    8410  keep_tag = true;
    8411  }
    8412  }
    8413 
    8414  // parse separator (:)
    8415  get_token();
    8416  expect(lexer::token_type::name_separator);
    8417 
    8418  // parse and add value
    8419  get_token();
    8420  auto value = parse_internal(keep);
    8421  if (keep and keep_tag and not value.is_discarded())
    8422  {
    8423  result[key] = std::move(value);
    8424  }
    8425  }
    8426  while (last_token == lexer::token_type::value_separator);
    8427 
    8428  // closing }
    8429  expect(lexer::token_type::end_object);
    8430  get_token();
    8431  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8432  {
    8433  result = basic_json(value_t::discarded);
    8434  }
    8435 
    8436  return result;
    8437  }
    8438 
    8439  case lexer::token_type::begin_array:
    8440  {
    8441  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    8442  {
    8443  // explicitly set result to object to cope with []
    8444  result.m_type = value_t::array;
    8445  result.m_value = json_value(value_t::array);
    8446  }
    8447 
    8448  // read next token
    8449  get_token();
    8450 
    8451  // closing ] -> we are done
    8452  if (last_token == lexer::token_type::end_array)
    8453  {
    8454  get_token();
    8455  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8456  {
    8457  result = basic_json(value_t::discarded);
    8458  }
    8459  return result;
    8460  }
    8461 
    8462  // no comma is expected here
    8463  unexpect(lexer::token_type::value_separator);
    8464 
    8465  // otherwise: parse values
    8466  do
    8467  {
    8468  // ugly, but could be fixed with loop reorganization
    8469  if (last_token == lexer::token_type::value_separator)
    8470  {
    8471  get_token();
    8472  }
    8473 
    8474  // parse value
    8475  auto value = parse_internal(keep);
    8476  if (keep and not value.is_discarded())
    8477  {
    8478  result.push_back(std::move(value));
    8479  }
    8480  }
    8481  while (last_token == lexer::token_type::value_separator);
    8482 
    8483  // closing ]
    8484  expect(lexer::token_type::end_array);
    8485  get_token();
    8486  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8487  {
    8488  result = basic_json(value_t::discarded);
    8489  }
    8490 
    8491  return result;
    8492  }
    8493 
    8494  case lexer::token_type::literal_null:
    8495  {
    8496  get_token();
    8497  result.m_type = value_t::null;
    8498  break;
    8499  }
    8500 
    8501  case lexer::token_type::value_string:
    8502  {
    8503  const auto s = m_lexer.get_string();
    8504  get_token();
    8505  result = basic_json(s);
    8506  break;
    8507  }
    8508 
    8509  case lexer::token_type::literal_true:
    8510  {
    8511  get_token();
    8512  result.m_type = value_t::boolean;
    8513  result.m_value = true;
    8514  break;
    8515  }
    8516 
    8517  case lexer::token_type::literal_false:
    8518  {
    8519  get_token();
    8520  result.m_type = value_t::boolean;
    8521  result.m_value = false;
    8522  break;
    8523  }
    8524 
    8525  case lexer::token_type::value_number:
    8526  {
    8527  m_lexer.get_number(result);
    8528  get_token();
    8529  break;
    8530  }
    8531 
    8532  default:
    8533  {
    8534  // the last token was unexpected
    8535  unexpect(last_token);
    8536  }
    8537  }
    8538 
    8539  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8540  {
    8541  result = basic_json(value_t::discarded);
    8542  }
    8543  return result;
    8544  }
    8545 
    8547  typename lexer::token_type get_token()
    8548  {
    8549  last_token = m_lexer.scan();
    8550  return last_token;
    8551  }
    8552 
    8553  void expect(typename lexer::token_type t) const
    8554  {
    8555  if (t != last_token)
    8556  {
    8557  std::string error_msg = "parse error - unexpected ";
    8558  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8559  lexer::token_type_name(last_token));
    8560  error_msg += "; expected " + lexer::token_type_name(t);
    8561  throw std::invalid_argument(error_msg);
    8562  }
    8563  }
    8564 
    8565  void unexpect(typename lexer::token_type t) const
    8566  {
    8567  if (t == last_token)
    8568  {
    8569  std::string error_msg = "parse error - unexpected ";
    8570  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8571  lexer::token_type_name(last_token));
    8572  throw std::invalid_argument(error_msg);
    8573  }
    8574  }
    8575 
    8576  private:
    8578  int depth = 0;
    8580  parser_callback_t callback;
    8582  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8584  lexer m_lexer;
    8585  };
    8586 };
    8587 
    8588 
    8590 // presets //
    8592 
    8602 }
    8603 
    8604 
    8606 // nonmember functions //
    8608 
    8609 // specialization of std::swap, and std::hash
    8610 namespace std
    8611 {
    8617 template <>
    8618 inline void swap(nlohmann::json& j1,
    8619  nlohmann::json& j2) noexcept(
    8620  is_nothrow_move_constructible<nlohmann::json>::value and
    8621  is_nothrow_move_assignable<nlohmann::json>::value
    8622  )
    8623 {
    8624  j1.swap(j2);
    8625 }
    8626 
    8628 template <>
    8629 struct hash<nlohmann::json>
    8630 {
    8636  std::size_t operator()(const nlohmann::json& j) const
    8637  {
    8638  // a naive hashing via the string representation
    8639  const auto& h = hash<nlohmann::json::string_t>();
    8640  return h(j.dump());
    8641  }
    8642 };
    8643 }
    8644 
    8657 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8658 {
    8659  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8660 }
    8661 
    8662 // restore GCC/clang diagnostic settings
    8663 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    8664  #pragma GCC diagnostic pop
    8665 #endif
    8666 
    8667 #endif
    bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:2169
    -
    reference operator*()
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6793
    -
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:4173
    -
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5431
    +
    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 
    970  basic_json() noexcept = default;
    971 
    991  basic_json(std::nullptr_t) noexcept
    992  : basic_json(value_t::null)
    993  {}
    994 
    1014  basic_json(const object_t& val)
    1015  : m_type(value_t::object), m_value(val)
    1016  {}
    1017 
    1044  template <class CompatibleObjectType, typename
    1045  std::enable_if<
    1046  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    1047  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    1048  = 0>
    1049  basic_json(const CompatibleObjectType& val)
    1050  : m_type(value_t::object)
    1051  {
    1052  using std::begin;
    1053  using std::end;
    1054  m_value.object = create<object_t>(begin(val), end(val));
    1055  }
    1056 
    1076  basic_json(const array_t& val)
    1077  : m_type(value_t::array), m_value(val)
    1078  {}
    1079 
    1106  template <class CompatibleArrayType, typename
    1107  std::enable_if<
    1108  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1109  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1110  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1111  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1112  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1113  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1114  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1115  = 0>
    1116  basic_json(const CompatibleArrayType& val)
    1117  : m_type(value_t::array)
    1118  {
    1119  using std::begin;
    1120  using std::end;
    1121  m_value.array = create<array_t>(begin(val), end(val));
    1122  }
    1123 
    1145  basic_json(const string_t& val)
    1146  : m_type(value_t::string), m_value(val)
    1147  {}
    1148 
    1169  basic_json(const typename string_t::value_type* val)
    1170  : basic_json(string_t(val))
    1171  {}
    1172 
    1196  template <class CompatibleStringType, typename
    1197  std::enable_if<
    1198  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1199  = 0>
    1200  basic_json(const CompatibleStringType& val)
    1201  : basic_json(string_t(val))
    1202  {}
    1203 
    1219  : m_type(value_t::boolean), m_value(val)
    1220  {}
    1221 
    1245  template<typename T,
    1246  typename std::enable_if<
    1247  not (std::is_same<T, int>::value)
    1248  and std::is_same<T, number_integer_t>::value
    1249  , int>::type
    1250  = 0>
    1252  : m_type(value_t::number_integer), m_value(val)
    1253  {}
    1254 
    1280  basic_json(const int val)
    1281  : m_type(value_t::number_integer),
    1282  m_value(static_cast<number_integer_t>(val))
    1283  {}
    1284 
    1310  template<typename CompatibleNumberIntegerType, typename
    1311  std::enable_if<
    1312  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1313  std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
    1314  std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
    1315  CompatibleNumberIntegerType>::type
    1316  = 0>
    1317  basic_json(const CompatibleNumberIntegerType val) noexcept
    1318  : m_type(value_t::number_integer),
    1319  m_value(static_cast<number_integer_t>(val))
    1320  {}
    1321 
    1339  template<typename T,
    1340  typename std::enable_if<
    1341  not (std::is_same<T, int>::value)
    1342  and std::is_same<T, number_unsigned_t>::value
    1343  , int>::type
    1344  = 0>
    1346  : m_type(value_t::number_unsigned), m_value(val)
    1347  {}
    1348 
    1369  template < typename CompatibleNumberUnsignedType, typename
    1370  std::enable_if <
    1371  std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
    1372  std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
    1373  !std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
    1374  CompatibleNumberUnsignedType >::type
    1375  = 0 >
    1376  basic_json(const CompatibleNumberUnsignedType val) noexcept
    1377  : m_type(value_t::number_unsigned),
    1378  m_value(static_cast<number_unsigned_t>(val))
    1379  {}
    1380 
    1406  : m_type(value_t::number_float), m_value(val)
    1407  {
    1408  // replace infinity and NAN by null
    1409  if (not std::isfinite(val))
    1410  {
    1411  m_type = value_t::null;
    1412  m_value = json_value();
    1413  }
    1414  }
    1415 
    1446  template<typename CompatibleNumberFloatType, typename = typename
    1447  std::enable_if<
    1448  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1449  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1450  >
    1451  basic_json(const CompatibleNumberFloatType val) noexcept
    1452  : basic_json(number_float_t(val))
    1453  {}
    1454 
    1524  basic_json(std::initializer_list<basic_json> init,
    1525  bool type_deduction = true,
    1526  value_t manual_type = value_t::array)
    1527  {
    1528  // the initializer list could describe an object
    1529  bool is_an_object = true;
    1530 
    1531  // check if each element is an array with two elements whose first
    1532  // element is a string
    1533  for (const auto& element : init)
    1534  {
    1535  if (not element.is_array() or element.size() != 2
    1536  or not element[0].is_string())
    1537  {
    1538  // we found an element that makes it impossible to use the
    1539  // initializer list as object
    1540  is_an_object = false;
    1541  break;
    1542  }
    1543  }
    1544 
    1545  // adjust type if type deduction is not wanted
    1546  if (not type_deduction)
    1547  {
    1548  // if array is wanted, do not create an object though possible
    1549  if (manual_type == value_t::array)
    1550  {
    1551  is_an_object = false;
    1552  }
    1553 
    1554  // if object is wanted but impossible, throw an exception
    1555  if (manual_type == value_t::object and not is_an_object)
    1556  {
    1557  throw std::domain_error("cannot create object from initializer list");
    1558  }
    1559  }
    1560 
    1561  if (is_an_object)
    1562  {
    1563  // the initializer list is a list of pairs -> create object
    1564  m_type = value_t::object;
    1565  m_value = value_t::object;
    1566 
    1567  assert(m_value.object != nullptr);
    1568 
    1569  for (auto& element : init)
    1570  {
    1571  m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1]));
    1572  }
    1573  }
    1574  else
    1575  {
    1576  // the initializer list describes an array -> create array
    1577  m_type = value_t::array;
    1578  m_value.array = create<array_t>(std::move(init));
    1579  }
    1580  }
    1581 
    1616  static basic_json array(std::initializer_list<basic_json> init =
    1617  std::initializer_list<basic_json>())
    1618  {
    1619  return basic_json(init, false, value_t::array);
    1620  }
    1621 
    1656  static basic_json object(std::initializer_list<basic_json> init =
    1657  std::initializer_list<basic_json>())
    1658  {
    1659  return basic_json(init, false, value_t::object);
    1660  }
    1661 
    1680  basic_json(size_type cnt, const basic_json& val)
    1681  : m_type(value_t::array)
    1682  {
    1683  m_value.array = create<array_t>(cnt, val);
    1684  }
    1685 
    1720  template <class InputIT, typename
    1721  std::enable_if<
    1722  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1723  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1724  , int>::type
    1725  = 0>
    1726  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1727  {
    1728  // make sure iterator fits the current value
    1729  if (first.m_object != last.m_object)
    1730  {
    1731  throw std::domain_error("iterators are not compatible");
    1732  }
    1733 
    1734  // check if iterator range is complete for primitive values
    1735  switch (m_type)
    1736  {
    1737  case value_t::boolean:
    1738  case value_t::number_float:
    1739  case value_t::number_integer:
    1740  case value_t::number_unsigned:
    1741  case value_t::string:
    1742  {
    1743  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1744  {
    1745  throw std::out_of_range("iterators out of range");
    1746  }
    1747  break;
    1748  }
    1749 
    1750  default:
    1751  {
    1752  break;
    1753  }
    1754  }
    1755 
    1756  switch (m_type)
    1757  {
    1758  case value_t::number_integer:
    1759  {
    1760  assert(first.m_object != nullptr);
    1761  m_value.number_integer = first.m_object->m_value.number_integer;
    1762  break;
    1763  }
    1764 
    1765  case value_t::number_unsigned:
    1766  {
    1767  assert(first.m_object != nullptr);
    1768  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
    1769  break;
    1770  }
    1771 
    1772  case value_t::number_float:
    1773  {
    1774  assert(first.m_object != nullptr);
    1775  m_value.number_float = first.m_object->m_value.number_float;
    1776  break;
    1777  }
    1778 
    1779  case value_t::boolean:
    1780  {
    1781  assert(first.m_object != nullptr);
    1782  m_value.boolean = first.m_object->m_value.boolean;
    1783  break;
    1784  }
    1785 
    1786  case value_t::string:
    1787  {
    1788  assert(first.m_object != nullptr);
    1789  m_value = *first.m_object->m_value.string;
    1790  break;
    1791  }
    1792 
    1793  case value_t::object:
    1794  {
    1795  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1796  break;
    1797  }
    1798 
    1799  case value_t::array:
    1800  {
    1801  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1802  break;
    1803  }
    1804 
    1805  default:
    1806  {
    1807  assert(first.m_object != nullptr);
    1808  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1809  }
    1810  }
    1811  }
    1812 
    1833  explicit basic_json(std::istream& i, parser_callback_t cb = nullptr)
    1834  {
    1835  *this = parser(i, cb).parse();
    1836  }
    1837 
    1839  // other constructors and destructor //
    1841 
    1864  basic_json(const basic_json& other)
    1865  : m_type(other.m_type)
    1866  {
    1867  switch (m_type)
    1868  {
    1869  case value_t::object:
    1870  {
    1871  assert(other.m_value.object != nullptr);
    1872  m_value = *other.m_value.object;
    1873  break;
    1874  }
    1875 
    1876  case value_t::array:
    1877  {
    1878  assert(other.m_value.array != nullptr);
    1879  m_value = *other.m_value.array;
    1880  break;
    1881  }
    1882 
    1883  case value_t::string:
    1884  {
    1885  assert(other.m_value.string != nullptr);
    1886  m_value = *other.m_value.string;
    1887  break;
    1888  }
    1889 
    1890  case value_t::boolean:
    1891  {
    1892  m_value = other.m_value.boolean;
    1893  break;
    1894  }
    1895 
    1896  case value_t::number_integer:
    1897  {
    1898  m_value = other.m_value.number_integer;
    1899  break;
    1900  }
    1901 
    1902  case value_t::number_unsigned:
    1903  {
    1904  m_value = other.m_value.number_unsigned;
    1905  break;
    1906  }
    1907 
    1908  case value_t::number_float:
    1909  {
    1910  m_value = other.m_value.number_float;
    1911  break;
    1912  }
    1913 
    1914  default:
    1915  {
    1916  break;
    1917  }
    1918  }
    1919  }
    1920 
    1939  basic_json(basic_json&& other) noexcept
    1940  : m_type(std::move(other.m_type)),
    1941  m_value(std::move(other.m_value))
    1942  {
    1943  // invalidate payload
    1944  other.m_type = value_t::null;
    1945  other.m_value = {};
    1946  }
    1947 
    1971  reference& operator=(basic_json other) noexcept (
    1972  std::is_nothrow_move_constructible<value_t>::value and
    1973  std::is_nothrow_move_assignable<value_t>::value and
    1974  std::is_nothrow_move_constructible<json_value>::value and
    1975  std::is_nothrow_move_assignable<json_value>::value
    1976  )
    1977  {
    1978  using std::swap;
    1979  swap(m_type, other.m_type);
    1980  swap(m_value, other.m_value);
    1981  return *this;
    1982  }
    1983 
    2000  {
    2001  switch (m_type)
    2002  {
    2003  case value_t::object:
    2004  {
    2005  AllocatorType<object_t> alloc;
    2006  alloc.destroy(m_value.object);
    2007  alloc.deallocate(m_value.object, 1);
    2008  break;
    2009  }
    2010 
    2011  case value_t::array:
    2012  {
    2013  AllocatorType<array_t> alloc;
    2014  alloc.destroy(m_value.array);
    2015  alloc.deallocate(m_value.array, 1);
    2016  break;
    2017  }
    2018 
    2019  case value_t::string:
    2020  {
    2021  AllocatorType<string_t> alloc;
    2022  alloc.destroy(m_value.string);
    2023  alloc.deallocate(m_value.string, 1);
    2024  break;
    2025  }
    2026 
    2027  default:
    2028  {
    2029  // all other types need no specific destructor
    2030  break;
    2031  }
    2032  }
    2033  }
    2034 
    2036 
    2037  public:
    2039  // object inspection //
    2041 
    2044 
    2068  string_t dump(const int indent = -1) const
    2069  {
    2070  std::stringstream ss;
    2071 
    2072  if (indent >= 0)
    2073  {
    2074  dump(ss, true, static_cast<unsigned int>(indent));
    2075  }
    2076  else
    2077  {
    2078  dump(ss, false, 0);
    2079  }
    2080 
    2081  return ss.str();
    2082  }
    2083 
    2099  value_t type() const noexcept
    2100  {
    2101  return m_type;
    2102  }
    2103 
    2126  bool is_primitive() const noexcept
    2127  {
    2128  return is_null() or is_string() or is_boolean() or is_number();
    2129  }
    2130 
    2150  bool is_structured() const noexcept
    2151  {
    2152  return is_array() or is_object();
    2153  }
    2154 
    2169  bool is_null() const noexcept
    2170  {
    2171  return m_type == value_t::null;
    2172  }
    2173 
    2188  bool is_boolean() const noexcept
    2189  {
    2190  return m_type == value_t::boolean;
    2191  }
    2192 
    2215  bool is_number() const noexcept
    2216  {
    2217  return is_number_integer() or is_number_float();
    2218  }
    2219 
    2241  bool is_number_integer() const noexcept
    2242  {
    2243  return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
    2244  }
    2245 
    2266  bool is_number_unsigned() const noexcept
    2267  {
    2268  return m_type == value_t::number_unsigned;
    2269  }
    2270 
    2291  bool is_number_float() const noexcept
    2292  {
    2293  return m_type == value_t::number_float;
    2294  }
    2295 
    2310  bool is_object() const noexcept
    2311  {
    2312  return m_type == value_t::object;
    2313  }
    2314 
    2329  bool is_array() const noexcept
    2330  {
    2331  return m_type == value_t::array;
    2332  }
    2333 
    2348  bool is_string() const noexcept
    2349  {
    2350  return m_type == value_t::string;
    2351  }
    2352 
    2372  bool is_discarded() const noexcept
    2373  {
    2374  return m_type == value_t::discarded;
    2375  }
    2376 
    2392  operator value_t() const noexcept
    2393  {
    2394  return m_type;
    2395  }
    2396 
    2398 
    2399  private:
    2401  // value access //
    2403 
    2405  template <class T, typename
    2406  std::enable_if<
    2407  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2408  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2409  , int>::type = 0>
    2410  T get_impl(T*) const
    2411  {
    2412  if (is_object())
    2413  {
    2414  assert(m_value.object != nullptr);
    2415  return T(m_value.object->begin(), m_value.object->end());
    2416  }
    2417  else
    2418  {
    2419  throw std::domain_error("type must be object, but is " + type_name());
    2420  }
    2421  }
    2422 
    2424  object_t get_impl(object_t*) const
    2425  {
    2426  if (is_object())
    2427  {
    2428  assert(m_value.object != nullptr);
    2429  return *(m_value.object);
    2430  }
    2431  else
    2432  {
    2433  throw std::domain_error("type must be object, but is " + type_name());
    2434  }
    2435  }
    2436 
    2438  template <class T, typename
    2439  std::enable_if<
    2440  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2441  not std::is_same<basic_json_t, typename T::value_type>::value and
    2442  not std::is_arithmetic<T>::value and
    2443  not std::is_convertible<std::string, T>::value and
    2444  not has_mapped_type<T>::value
    2445  , int>::type = 0>
    2446  T get_impl(T*) const
    2447  {
    2448  if (is_array())
    2449  {
    2450  T to_vector;
    2451  assert(m_value.array != nullptr);
    2452  std::transform(m_value.array->begin(), m_value.array->end(),
    2453  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2454  {
    2455  return i.get<typename T::value_type>();
    2456  });
    2457  return to_vector;
    2458  }
    2459  else
    2460  {
    2461  throw std::domain_error("type must be array, but is " + type_name());
    2462  }
    2463  }
    2464 
    2466  template <class T, typename
    2467  std::enable_if<
    2468  std::is_convertible<basic_json_t, T>::value and
    2469  not std::is_same<basic_json_t, T>::value
    2470  , int>::type = 0>
    2471  std::vector<T> get_impl(std::vector<T>*) const
    2472  {
    2473  if (is_array())
    2474  {
    2475  std::vector<T> to_vector;
    2476  assert(m_value.array != nullptr);
    2477  to_vector.reserve(m_value.array->size());
    2478  std::transform(m_value.array->begin(), m_value.array->end(),
    2479  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2480  {
    2481  return i.get<T>();
    2482  });
    2483  return to_vector;
    2484  }
    2485  else
    2486  {
    2487  throw std::domain_error("type must be array, but is " + type_name());
    2488  }
    2489  }
    2490 
    2492  template <class T, typename
    2493  std::enable_if<
    2494  std::is_same<basic_json, typename T::value_type>::value and
    2495  not has_mapped_type<T>::value
    2496  , int>::type = 0>
    2497  T get_impl(T*) const
    2498  {
    2499  if (is_array())
    2500  {
    2501  assert(m_value.array != nullptr);
    2502  return T(m_value.array->begin(), m_value.array->end());
    2503  }
    2504  else
    2505  {
    2506  throw std::domain_error("type must be array, but is " + type_name());
    2507  }
    2508  }
    2509 
    2511  array_t get_impl(array_t*) const
    2512  {
    2513  if (is_array())
    2514  {
    2515  assert(m_value.array != nullptr);
    2516  return *(m_value.array);
    2517  }
    2518  else
    2519  {
    2520  throw std::domain_error("type must be array, but is " + type_name());
    2521  }
    2522  }
    2523 
    2525  template <typename T, typename
    2526  std::enable_if<
    2527  std::is_convertible<string_t, T>::value
    2528  , int>::type = 0>
    2529  T get_impl(T*) const
    2530  {
    2531  if (is_string())
    2532  {
    2533  assert(m_value.string != nullptr);
    2534  return *m_value.string;
    2535  }
    2536  else
    2537  {
    2538  throw std::domain_error("type must be string, but is " + type_name());
    2539  }
    2540  }
    2541 
    2543  template<typename T, typename
    2544  std::enable_if<
    2545  std::is_arithmetic<T>::value
    2546  , int>::type = 0>
    2547  T get_impl(T*) const
    2548  {
    2549  switch (m_type)
    2550  {
    2551  case value_t::number_integer:
    2552  {
    2553  return static_cast<T>(m_value.number_integer);
    2554  }
    2555 
    2556  case value_t::number_unsigned:
    2557  {
    2558  return static_cast<T>(m_value.number_unsigned);
    2559  }
    2560 
    2561  case value_t::number_float:
    2562  {
    2563  return static_cast<T>(m_value.number_float);
    2564  }
    2565 
    2566  default:
    2567  {
    2568  throw std::domain_error("type must be number, but is " + type_name());
    2569  }
    2570  }
    2571  }
    2572 
    2574  boolean_t get_impl(boolean_t*) const
    2575  {
    2576  if (is_boolean())
    2577  {
    2578  return m_value.boolean;
    2579  }
    2580  else
    2581  {
    2582  throw std::domain_error("type must be boolean, but is " + type_name());
    2583  }
    2584  }
    2585 
    2587  object_t* get_impl_ptr(object_t*) noexcept
    2588  {
    2589  return is_object() ? m_value.object : nullptr;
    2590  }
    2591 
    2593  const object_t* get_impl_ptr(const object_t*) const noexcept
    2594  {
    2595  return is_object() ? m_value.object : nullptr;
    2596  }
    2597 
    2599  array_t* get_impl_ptr(array_t*) noexcept
    2600  {
    2601  return is_array() ? m_value.array : nullptr;
    2602  }
    2603 
    2605  const array_t* get_impl_ptr(const array_t*) const noexcept
    2606  {
    2607  return is_array() ? m_value.array : nullptr;
    2608  }
    2609 
    2611  string_t* get_impl_ptr(string_t*) noexcept
    2612  {
    2613  return is_string() ? m_value.string : nullptr;
    2614  }
    2615 
    2617  const string_t* get_impl_ptr(const string_t*) const noexcept
    2618  {
    2619  return is_string() ? m_value.string : nullptr;
    2620  }
    2621 
    2623  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2624  {
    2625  return is_boolean() ? &m_value.boolean : nullptr;
    2626  }
    2627 
    2629  const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2630  {
    2631  return is_boolean() ? &m_value.boolean : nullptr;
    2632  }
    2633 
    2635  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2636  {
    2637  return is_number_integer() ? &m_value.number_integer : nullptr;
    2638  }
    2639 
    2641  const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2642  {
    2643  return is_number_integer() ? &m_value.number_integer : nullptr;
    2644  }
    2645 
    2647  number_unsigned_t* get_impl_ptr(number_unsigned_t*) noexcept
    2648  {
    2649  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2650  }
    2651 
    2653  const number_unsigned_t* get_impl_ptr(const number_unsigned_t*) const noexcept
    2654  {
    2655  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2656  }
    2657 
    2659  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2660  {
    2661  return is_number_float() ? &m_value.number_float : nullptr;
    2662  }
    2663 
    2665  const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2666  {
    2667  return is_number_float() ? &m_value.number_float : nullptr;
    2668  }
    2669 
    2681  template<typename ReferenceType, typename ThisType>
    2682  static ReferenceType get_ref_impl(ThisType& obj)
    2683  {
    2684  // delegate the call to get_ptr<>()
    2685  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2686  auto ptr = obj.template get_ptr<PointerType>();
    2687 
    2688  if (ptr != nullptr)
    2689  {
    2690  return *ptr;
    2691  }
    2692  else
    2693  {
    2694  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2695  obj.type_name());
    2696  }
    2697  }
    2698 
    2699  public:
    2700 
    2703 
    2737  template<typename ValueType, typename
    2738  std::enable_if<
    2739  not std::is_pointer<ValueType>::value
    2740  , int>::type = 0>
    2741  ValueType get() const
    2742  {
    2743  return get_impl(static_cast<ValueType*>(nullptr));
    2744  }
    2745 
    2772  template<typename PointerType, typename
    2773  std::enable_if<
    2774  std::is_pointer<PointerType>::value
    2775  , int>::type = 0>
    2776  PointerType get() noexcept
    2777  {
    2778  // delegate the call to get_ptr
    2779  return get_ptr<PointerType>();
    2780  }
    2781 
    2786  template<typename PointerType, typename
    2787  std::enable_if<
    2788  std::is_pointer<PointerType>::value
    2789  , int>::type = 0>
    2790  const PointerType get() const noexcept
    2791  {
    2792  // delegate the call to get_ptr
    2793  return get_ptr<PointerType>();
    2794  }
    2795 
    2821  template<typename PointerType, typename
    2822  std::enable_if<
    2823  std::is_pointer<PointerType>::value
    2824  , int>::type = 0>
    2825  PointerType get_ptr() noexcept
    2826  {
    2827  // delegate the call to get_impl_ptr<>()
    2828  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2829  }
    2830 
    2835  template<typename PointerType, typename
    2836  std::enable_if<
    2837  std::is_pointer<PointerType>::value
    2838  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2839  , int>::type = 0>
    2840  const PointerType get_ptr() const noexcept
    2841  {
    2842  // delegate the call to get_impl_ptr<>() const
    2843  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2844  }
    2845 
    2872  template<typename ReferenceType, typename
    2873  std::enable_if<
    2874  std::is_reference<ReferenceType>::value
    2875  , int>::type = 0>
    2876  ReferenceType get_ref()
    2877  {
    2878  // delegate call to get_ref_impl
    2879  return get_ref_impl<ReferenceType>(*this);
    2880  }
    2881 
    2886  template<typename ReferenceType, typename
    2887  std::enable_if<
    2888  std::is_reference<ReferenceType>::value
    2889  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2890  , int>::type = 0>
    2891  ReferenceType get_ref() const
    2892  {
    2893  // delegate call to get_ref_impl
    2894  return get_ref_impl<ReferenceType>(*this);
    2895  }
    2896 
    2925  template < typename ValueType, typename
    2926  std::enable_if <
    2927  not std::is_pointer<ValueType>::value
    2928  and not std::is_same<ValueType, typename string_t::value_type>::value
    2929 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2930  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2931 #endif
    2932  , int >::type = 0 >
    2933  operator ValueType() const
    2934  {
    2935  // delegate the call to get<>() const
    2936  return get<ValueType>();
    2937  }
    2938 
    2940 
    2941 
    2943  // element access //
    2945 
    2948 
    2972  {
    2973  // at only works for arrays
    2974  if (is_array())
    2975  {
    2976  try
    2977  {
    2978  assert(m_value.array != nullptr);
    2979  return m_value.array->at(idx);
    2980  }
    2981  catch (std::out_of_range&)
    2982  {
    2983  // create better exception explanation
    2984  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2985  }
    2986  }
    2987  else
    2988  {
    2989  throw std::domain_error("cannot use at() with " + type_name());
    2990  }
    2991  }
    2992 
    3016  {
    3017  // at only works for arrays
    3018  if (is_array())
    3019  {
    3020  try
    3021  {
    3022  assert(m_value.array != nullptr);
    3023  return m_value.array->at(idx);
    3024  }
    3025  catch (std::out_of_range&)
    3026  {
    3027  // create better exception explanation
    3028  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3029  }
    3030  }
    3031  else
    3032  {
    3033  throw std::domain_error("cannot use at() with " + type_name());
    3034  }
    3035  }
    3036 
    3063  reference at(const typename object_t::key_type& key)
    3064  {
    3065  // at only works for objects
    3066  if (is_object())
    3067  {
    3068  try
    3069  {
    3070  assert(m_value.object != nullptr);
    3071  return m_value.object->at(key);
    3072  }
    3073  catch (std::out_of_range&)
    3074  {
    3075  // create better exception explanation
    3076  throw std::out_of_range("key '" + key + "' not found");
    3077  }
    3078  }
    3079  else
    3080  {
    3081  throw std::domain_error("cannot use at() with " + type_name());
    3082  }
    3083  }
    3084 
    3111  const_reference at(const typename object_t::key_type& key) const
    3112  {
    3113  // at only works for objects
    3114  if (is_object())
    3115  {
    3116  try
    3117  {
    3118  assert(m_value.object != nullptr);
    3119  return m_value.object->at(key);
    3120  }
    3121  catch (std::out_of_range&)
    3122  {
    3123  // create better exception explanation
    3124  throw std::out_of_range("key '" + key + "' not found");
    3125  }
    3126  }
    3127  else
    3128  {
    3129  throw std::domain_error("cannot use at() with " + type_name());
    3130  }
    3131  }
    3132 
    3159  {
    3160  // implicitly convert null value to an empty array
    3161  if (is_null())
    3162  {
    3163  m_type = value_t::array;
    3164  m_value.array = create<array_t>();
    3165  }
    3166 
    3167  // operator[] only works for arrays
    3168  if (is_array())
    3169  {
    3170  // fill up array with null values until given idx is reached
    3171  assert(m_value.array != nullptr);
    3172  for (size_t i = m_value.array->size(); i <= idx; ++i)
    3173  {
    3174  m_value.array->push_back(basic_json());
    3175  }
    3176 
    3177  return m_value.array->operator[](idx);
    3178  }
    3179  else
    3180  {
    3181  throw std::domain_error("cannot use operator[] with " + type_name());
    3182  }
    3183  }
    3184 
    3205  {
    3206  // const operator[] only works for arrays
    3207  if (is_array())
    3208  {
    3209  assert(m_value.array != nullptr);
    3210  return m_value.array->operator[](idx);
    3211  }
    3212  else
    3213  {
    3214  throw std::domain_error("cannot use operator[] with " + type_name());
    3215  }
    3216  }
    3217 
    3245  reference operator[](const typename object_t::key_type& key)
    3246  {
    3247  // implicitly convert null value to an empty object
    3248  if (is_null())
    3249  {
    3250  m_type = value_t::object;
    3251  m_value.object = create<object_t>();
    3252  }
    3253 
    3254  // operator[] only works for objects
    3255  if (is_object())
    3256  {
    3257  assert(m_value.object != nullptr);
    3258  return m_value.object->operator[](key);
    3259  }
    3260  else
    3261  {
    3262  throw std::domain_error("cannot use operator[] with " + type_name());
    3263  }
    3264  }
    3265 
    3293  const_reference operator[](const typename object_t::key_type& key) const
    3294  {
    3295  // const operator[] only works for objects
    3296  if (is_object())
    3297  {
    3298  assert(m_value.object != nullptr);
    3299  assert(m_value.object->find(key) != m_value.object->end());
    3300  return m_value.object->find(key)->second;
    3301  }
    3302  else
    3303  {
    3304  throw std::domain_error("cannot use operator[] with " + type_name());
    3305  }
    3306  }
    3307 
    3335  template<typename T, std::size_t n>
    3336  reference operator[](T * (&key)[n])
    3337  {
    3338  return operator[](static_cast<const T>(key));
    3339  }
    3340 
    3370  template<typename T, std::size_t n>
    3371  const_reference operator[](T * (&key)[n]) const
    3372  {
    3373  return operator[](static_cast<const T>(key));
    3374  }
    3375 
    3403  template<typename T>
    3405  {
    3406  // implicitly convert null to object
    3407  if (is_null())
    3408  {
    3409  m_type = value_t::object;
    3410  m_value = value_t::object;
    3411  }
    3412 
    3413  // at only works for objects
    3414  if (is_object())
    3415  {
    3416  assert(m_value.object != nullptr);
    3417  return m_value.object->operator[](key);
    3418  }
    3419  else
    3420  {
    3421  throw std::domain_error("cannot use operator[] with " + type_name());
    3422  }
    3423  }
    3424 
    3452  template<typename T>
    3454  {
    3455  // at only works for objects
    3456  if (is_object())
    3457  {
    3458  assert(m_value.object != nullptr);
    3459  assert(m_value.object->find(key) != m_value.object->end());
    3460  return m_value.object->find(key)->second;
    3461  }
    3462  else
    3463  {
    3464  throw std::domain_error("cannot use operator[] with " + type_name());
    3465  }
    3466  }
    3467 
    3516  template <class ValueType, typename
    3517  std::enable_if<
    3518  std::is_convertible<basic_json_t, ValueType>::value
    3519  , int>::type = 0>
    3520  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3521  {
    3522  // at only works for objects
    3523  if (is_object())
    3524  {
    3525  // if key is found, return value and given default value otherwise
    3526  const auto it = find(key);
    3527  if (it != end())
    3528  {
    3529  return *it;
    3530  }
    3531  else
    3532  {
    3533  return default_value;
    3534  }
    3535  }
    3536  else
    3537  {
    3538  throw std::domain_error("cannot use value() with " + type_name());
    3539  }
    3540  }
    3541 
    3546  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3547  {
    3548  return value(key, string_t(default_value));
    3549  }
    3550 
    3576  {
    3577  return *begin();
    3578  }
    3579 
    3584  {
    3585  return *cbegin();
    3586  }
    3587 
    3618  {
    3619  auto tmp = end();
    3620  --tmp;
    3621  return *tmp;
    3622  }
    3623 
    3628  {
    3629  auto tmp = cend();
    3630  --tmp;
    3631  return *tmp;
    3632  }
    3633 
    3679  template <class InteratorType, typename
    3680  std::enable_if<
    3681  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3682  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3683  , int>::type
    3684  = 0>
    3685  InteratorType erase(InteratorType pos)
    3686  {
    3687  // make sure iterator fits the current value
    3688  if (this != pos.m_object)
    3689  {
    3690  throw std::domain_error("iterator does not fit current value");
    3691  }
    3692 
    3693  InteratorType result = end();
    3694 
    3695  switch (m_type)
    3696  {
    3697  case value_t::boolean:
    3698  case value_t::number_float:
    3699  case value_t::number_integer:
    3700  case value_t::number_unsigned:
    3701  case value_t::string:
    3702  {
    3703  if (not pos.m_it.primitive_iterator.is_begin())
    3704  {
    3705  throw std::out_of_range("iterator out of range");
    3706  }
    3707 
    3708  if (is_string())
    3709  {
    3710  delete m_value.string;
    3711  m_value.string = nullptr;
    3712  }
    3713 
    3714  m_type = value_t::null;
    3715  break;
    3716  }
    3717 
    3718  case value_t::object:
    3719  {
    3720  assert(m_value.object != nullptr);
    3721  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3722  break;
    3723  }
    3724 
    3725  case value_t::array:
    3726  {
    3727  assert(m_value.array != nullptr);
    3728  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3729  break;
    3730  }
    3731 
    3732  default:
    3733  {
    3734  throw std::domain_error("cannot use erase() with " + type_name());
    3735  }
    3736  }
    3737 
    3738  return result;
    3739  }
    3740 
    3787  template <class InteratorType, typename
    3788  std::enable_if<
    3789  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3790  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3791  , int>::type
    3792  = 0>
    3793  InteratorType erase(InteratorType first, InteratorType last)
    3794  {
    3795  // make sure iterator fits the current value
    3796  if (this != first.m_object or this != last.m_object)
    3797  {
    3798  throw std::domain_error("iterators do not fit current value");
    3799  }
    3800 
    3801  InteratorType result = end();
    3802 
    3803  switch (m_type)
    3804  {
    3805  case value_t::boolean:
    3806  case value_t::number_float:
    3807  case value_t::number_integer:
    3808  case value_t::number_unsigned:
    3809  case value_t::string:
    3810  {
    3811  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3812  {
    3813  throw std::out_of_range("iterators out of range");
    3814  }
    3815 
    3816  if (is_string())
    3817  {
    3818  delete m_value.string;
    3819  m_value.string = nullptr;
    3820  }
    3821 
    3822  m_type = value_t::null;
    3823  break;
    3824  }
    3825 
    3826  case value_t::object:
    3827  {
    3828  assert(m_value.object != nullptr);
    3829  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3830  last.m_it.object_iterator);
    3831  break;
    3832  }
    3833 
    3834  case value_t::array:
    3835  {
    3836  assert(m_value.array != nullptr);
    3837  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3838  last.m_it.array_iterator);
    3839  break;
    3840  }
    3841 
    3842  default:
    3843  {
    3844  throw std::domain_error("cannot use erase() with " + type_name());
    3845  }
    3846  }
    3847 
    3848  return result;
    3849  }
    3850 
    3880  size_type erase(const typename object_t::key_type& key)
    3881  {
    3882  // this erase only works for objects
    3883  if (is_object())
    3884  {
    3885  assert(m_value.object != nullptr);
    3886  return m_value.object->erase(key);
    3887  }
    3888  else
    3889  {
    3890  throw std::domain_error("cannot use erase() with " + type_name());
    3891  }
    3892  }
    3893 
    3918  void erase(const size_type idx)
    3919  {
    3920  // this erase only works for arrays
    3921  if (is_array())
    3922  {
    3923  if (idx >= size())
    3924  {
    3925  throw std::out_of_range("index out of range");
    3926  }
    3927 
    3928  assert(m_value.array != nullptr);
    3929  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3930  }
    3931  else
    3932  {
    3933  throw std::domain_error("cannot use erase() with " + type_name());
    3934  }
    3935  }
    3936 
    3938 
    3939 
    3941  // lookup //
    3943 
    3946 
    3964  iterator find(typename object_t::key_type key)
    3965  {
    3966  auto result = end();
    3967 
    3968  if (is_object())
    3969  {
    3970  assert(m_value.object != nullptr);
    3971  result.m_it.object_iterator = m_value.object->find(key);
    3972  }
    3973 
    3974  return result;
    3975  }
    3976 
    3981  const_iterator find(typename object_t::key_type key) const
    3982  {
    3983  auto result = cend();
    3984 
    3985  if (is_object())
    3986  {
    3987  assert(m_value.object != nullptr);
    3988  result.m_it.object_iterator = m_value.object->find(key);
    3989  }
    3990 
    3991  return result;
    3992  }
    3993 
    4012  size_type count(typename object_t::key_type key) const
    4013  {
    4014  // return 0 for all nonobject types
    4015  assert(not is_object() or m_value.object != nullptr);
    4016  return is_object() ? m_value.object->count(key) : 0;
    4017  }
    4018 
    4020 
    4021 
    4023  // iterators //
    4025 
    4028 
    4054  {
    4055  iterator result(this);
    4056  result.set_begin();
    4057  return result;
    4058  }
    4059 
    4064  {
    4065  return cbegin();
    4066  }
    4067 
    4094  {
    4095  const_iterator result(this);
    4096  result.set_begin();
    4097  return result;
    4098  }
    4099 
    4125  {
    4126  iterator result(this);
    4127  result.set_end();
    4128  return result;
    4129  }
    4130 
    4135  {
    4136  return cend();
    4137  }
    4138 
    4165  {
    4166  const_iterator result(this);
    4167  result.set_end();
    4168  return result;
    4169  }
    4170 
    4195  {
    4196  return reverse_iterator(end());
    4197  }
    4198 
    4203  {
    4204  return crbegin();
    4205  }
    4206 
    4232  {
    4233  return reverse_iterator(begin());
    4234  }
    4235 
    4240  {
    4241  return crend();
    4242  }
    4243 
    4269  {
    4270  return const_reverse_iterator(cend());
    4271  }
    4272 
    4298  {
    4299  return const_reverse_iterator(cbegin());
    4300  }
    4301 
    4302  private:
    4303  // forward declaration
    4304  template<typename IteratorType> class iteration_proxy;
    4305 
    4306  public:
    4318  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    4319  {
    4320  return iteration_proxy<iterator>(cont);
    4321  }
    4322 
    4326  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4327  {
    4328  return iteration_proxy<const_iterator>(cont);
    4329  }
    4330 
    4332 
    4333 
    4335  // capacity //
    4337 
    4340 
    4374  bool empty() const noexcept
    4375  {
    4376  switch (m_type)
    4377  {
    4378  case value_t::null:
    4379  {
    4380  // null values are empty
    4381  return true;
    4382  }
    4383 
    4384  case value_t::array:
    4385  {
    4386  assert(m_value.array != nullptr);
    4387  return m_value.array->empty();
    4388  }
    4389 
    4390  case value_t::object:
    4391  {
    4392  assert(m_value.object != nullptr);
    4393  return m_value.object->empty();
    4394  }
    4395 
    4396  default:
    4397  {
    4398  // all other types are nonempty
    4399  return false;
    4400  }
    4401  }
    4402  }
    4403 
    4437  size_type size() const noexcept
    4438  {
    4439  switch (m_type)
    4440  {
    4441  case value_t::null:
    4442  {
    4443  // null values are empty
    4444  return 0;
    4445  }
    4446 
    4447  case value_t::array:
    4448  {
    4449  assert(m_value.array != nullptr);
    4450  return m_value.array->size();
    4451  }
    4452 
    4453  case value_t::object:
    4454  {
    4455  assert(m_value.object != nullptr);
    4456  return m_value.object->size();
    4457  }
    4458 
    4459  default:
    4460  {
    4461  // all other types have size 1
    4462  return 1;
    4463  }
    4464  }
    4465  }
    4466 
    4503  size_type max_size() const noexcept
    4504  {
    4505  switch (m_type)
    4506  {
    4507  case value_t::array:
    4508  {
    4509  assert(m_value.array != nullptr);
    4510  return m_value.array->max_size();
    4511  }
    4512 
    4513  case value_t::object:
    4514  {
    4515  assert(m_value.object != nullptr);
    4516  return m_value.object->max_size();
    4517  }
    4518 
    4519  default:
    4520  {
    4521  // all other types have max_size() == size()
    4522  return size();
    4523  }
    4524  }
    4525  }
    4526 
    4528 
    4529 
    4531  // modifiers //
    4533 
    4536 
    4562  void clear() noexcept
    4563  {
    4564  switch (m_type)
    4565  {
    4566  case value_t::number_integer:
    4567  {
    4568  m_value.number_integer = 0;
    4569  break;
    4570  }
    4571 
    4572  case value_t::number_unsigned:
    4573  {
    4574  m_value.number_unsigned = 0;
    4575  break;
    4576  }
    4577 
    4578  case value_t::number_float:
    4579  {
    4580  m_value.number_float = 0.0;
    4581  break;
    4582  }
    4583 
    4584  case value_t::boolean:
    4585  {
    4586  m_value.boolean = false;
    4587  break;
    4588  }
    4589 
    4590  case value_t::string:
    4591  {
    4592  assert(m_value.string != nullptr);
    4593  m_value.string->clear();
    4594  break;
    4595  }
    4596 
    4597  case value_t::array:
    4598  {
    4599  assert(m_value.array != nullptr);
    4600  m_value.array->clear();
    4601  break;
    4602  }
    4603 
    4604  case value_t::object:
    4605  {
    4606  assert(m_value.object != nullptr);
    4607  m_value.object->clear();
    4608  break;
    4609  }
    4610 
    4611  default:
    4612  {
    4613  break;
    4614  }
    4615  }
    4616  }
    4617 
    4638  void push_back(basic_json&& val)
    4639  {
    4640  // push_back only works for null objects or arrays
    4641  if (not(is_null() or is_array()))
    4642  {
    4643  throw std::domain_error("cannot use push_back() with " + type_name());
    4644  }
    4645 
    4646  // transform null object into an array
    4647  if (is_null())
    4648  {
    4649  m_type = value_t::array;
    4650  m_value = value_t::array;
    4651  }
    4652 
    4653  // add element to array (move semantics)
    4654  assert(m_value.array != nullptr);
    4655  m_value.array->push_back(std::move(val));
    4656  // invalidate object
    4657  val.m_type = value_t::null;
    4658  }
    4659 
    4664  reference operator+=(basic_json&& val)
    4665  {
    4666  push_back(std::move(val));
    4667  return *this;
    4668  }
    4669 
    4674  void push_back(const basic_json& val)
    4675  {
    4676  // push_back only works for null objects or arrays
    4677  if (not(is_null() or is_array()))
    4678  {
    4679  throw std::domain_error("cannot use push_back() with " + type_name());
    4680  }
    4681 
    4682  // transform null object into an array
    4683  if (is_null())
    4684  {
    4685  m_type = value_t::array;
    4686  m_value = value_t::array;
    4687  }
    4688 
    4689  // add element to array
    4690  assert(m_value.array != nullptr);
    4691  m_value.array->push_back(val);
    4692  }
    4693 
    4698  reference operator+=(const basic_json& val)
    4699  {
    4700  push_back(val);
    4701  return *this;
    4702  }
    4703 
    4724  void push_back(const typename object_t::value_type& val)
    4725  {
    4726  // push_back only works for null objects or objects
    4727  if (not(is_null() or is_object()))
    4728  {
    4729  throw std::domain_error("cannot use push_back() with " + type_name());
    4730  }
    4731 
    4732  // transform null object into an object
    4733  if (is_null())
    4734  {
    4735  m_type = value_t::object;
    4736  m_value = value_t::object;
    4737  }
    4738 
    4739  // add element to array
    4740  assert(m_value.object != nullptr);
    4741  m_value.object->insert(val);
    4742  }
    4743 
    4748  reference operator+=(const typename object_t::value_type& val)
    4749  {
    4750  push_back(val);
    4751  return operator[](val.first);
    4752  }
    4753 
    4776  iterator insert(const_iterator pos, const basic_json& val)
    4777  {
    4778  // insert only works for arrays
    4779  if (is_array())
    4780  {
    4781  // check if iterator pos fits to this JSON value
    4782  if (pos.m_object != this)
    4783  {
    4784  throw std::domain_error("iterator does not fit current value");
    4785  }
    4786 
    4787  // insert to array and return iterator
    4788  iterator result(this);
    4789  assert(m_value.array != nullptr);
    4790  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4791  return result;
    4792  }
    4793  else
    4794  {
    4795  throw std::domain_error("cannot use insert() with " + type_name());
    4796  }
    4797  }
    4798 
    4803  iterator insert(const_iterator pos, basic_json&& val)
    4804  {
    4805  return insert(pos, val);
    4806  }
    4807 
    4832  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4833  {
    4834  // insert only works for arrays
    4835  if (is_array())
    4836  {
    4837  // check if iterator pos fits to this JSON value
    4838  if (pos.m_object != this)
    4839  {
    4840  throw std::domain_error("iterator does not fit current value");
    4841  }
    4842 
    4843  // insert to array and return iterator
    4844  iterator result(this);
    4845  assert(m_value.array != nullptr);
    4846  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4847  return result;
    4848  }
    4849  else
    4850  {
    4851  throw std::domain_error("cannot use insert() with " + type_name());
    4852  }
    4853  }
    4854 
    4886  {
    4887  // insert only works for arrays
    4888  if (not is_array())
    4889  {
    4890  throw std::domain_error("cannot use insert() with " + type_name());
    4891  }
    4892 
    4893  // check if iterator pos fits to this JSON value
    4894  if (pos.m_object != this)
    4895  {
    4896  throw std::domain_error("iterator does not fit current value");
    4897  }
    4898 
    4899  if (first.m_object != last.m_object)
    4900  {
    4901  throw std::domain_error("iterators do not fit");
    4902  }
    4903 
    4904  if (first.m_object == this or last.m_object == this)
    4905  {
    4906  throw std::domain_error("passed iterators may not belong to container");
    4907  }
    4908 
    4909  // insert to array and return iterator
    4910  iterator result(this);
    4911  assert(m_value.array != nullptr);
    4912  result.m_it.array_iterator = m_value.array->insert(
    4913  pos.m_it.array_iterator,
    4914  first.m_it.array_iterator,
    4915  last.m_it.array_iterator);
    4916  return result;
    4917  }
    4918 
    4943  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4944  {
    4945  // insert only works for arrays
    4946  if (not is_array())
    4947  {
    4948  throw std::domain_error("cannot use insert() with " + type_name());
    4949  }
    4950 
    4951  // check if iterator pos fits to this JSON value
    4952  if (pos.m_object != this)
    4953  {
    4954  throw std::domain_error("iterator does not fit current value");
    4955  }
    4956 
    4957  // insert to array and return iterator
    4958  iterator result(this);
    4959  assert(m_value.array != nullptr);
    4960  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4961  return result;
    4962  }
    4963 
    4981  void swap(reference other) noexcept (
    4982  std::is_nothrow_move_constructible<value_t>::value and
    4983  std::is_nothrow_move_assignable<value_t>::value and
    4984  std::is_nothrow_move_constructible<json_value>::value and
    4985  std::is_nothrow_move_assignable<json_value>::value
    4986  )
    4987  {
    4988  std::swap(m_type, other.m_type);
    4989  std::swap(m_value, other.m_value);
    4990  }
    4991 
    5012  void swap(array_t& other)
    5013  {
    5014  // swap only works for arrays
    5015  if (is_array())
    5016  {
    5017  assert(m_value.array != nullptr);
    5018  std::swap(*(m_value.array), other);
    5019  }
    5020  else
    5021  {
    5022  throw std::domain_error("cannot use swap() with " + type_name());
    5023  }
    5024  }
    5025 
    5046  void swap(object_t& other)
    5047  {
    5048  // swap only works for objects
    5049  if (is_object())
    5050  {
    5051  assert(m_value.object != nullptr);
    5052  std::swap(*(m_value.object), other);
    5053  }
    5054  else
    5055  {
    5056  throw std::domain_error("cannot use swap() with " + type_name());
    5057  }
    5058  }
    5059 
    5080  void swap(string_t& other)
    5081  {
    5082  // swap only works for strings
    5083  if (is_string())
    5084  {
    5085  assert(m_value.string != nullptr);
    5086  std::swap(*(m_value.string), other);
    5087  }
    5088  else
    5089  {
    5090  throw std::domain_error("cannot use swap() with " + type_name());
    5091  }
    5092  }
    5093 
    5095 
    5096 
    5098  // lexicographical comparison operators //
    5100 
    5103 
    5104  private:
    5114  friend bool operator<(const value_t lhs, const value_t rhs)
    5115  {
    5116  static constexpr std::array<uint8_t, 8> order = {{
    5117  0, // null
    5118  3, // object
    5119  4, // array
    5120  5, // string
    5121  1, // boolean
    5122  2, // integer
    5123  2, // unsigned
    5124  2, // float
    5125  }
    5126  };
    5127 
    5128  // discarded values are not comparable
    5129  if (lhs == value_t::discarded or rhs == value_t::discarded)
    5130  {
    5131  return false;
    5132  }
    5133 
    5134  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    5135  }
    5136 
    5137  public:
    5161  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    5162  {
    5163  const auto lhs_type = lhs.type();
    5164  const auto rhs_type = rhs.type();
    5165 
    5166  if (lhs_type == rhs_type)
    5167  {
    5168  switch (lhs_type)
    5169  {
    5170  case value_t::array:
    5171  {
    5172  assert(lhs.m_value.array != nullptr);
    5173  assert(rhs.m_value.array != nullptr);
    5174  return *lhs.m_value.array == *rhs.m_value.array;
    5175  }
    5176  case value_t::object:
    5177  {
    5178  assert(lhs.m_value.object != nullptr);
    5179  assert(rhs.m_value.object != nullptr);
    5180  return *lhs.m_value.object == *rhs.m_value.object;
    5181  }
    5182  case value_t::null:
    5183  {
    5184  return true;
    5185  }
    5186  case value_t::string:
    5187  {
    5188  assert(lhs.m_value.string != nullptr);
    5189  assert(rhs.m_value.string != nullptr);
    5190  return *lhs.m_value.string == *rhs.m_value.string;
    5191  }
    5192  case value_t::boolean:
    5193  {
    5194  return lhs.m_value.boolean == rhs.m_value.boolean;
    5195  }
    5196  case value_t::number_integer:
    5197  {
    5198  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    5199  }
    5200  case value_t::number_unsigned:
    5201  {
    5202  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
    5203  }
    5204  case value_t::number_float:
    5205  {
    5206  return lhs.m_value.number_float == rhs.m_value.number_float;
    5207  }
    5208  default:
    5209  {
    5210  return false;
    5211  }
    5212  }
    5213  }
    5214  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5215  {
    5216  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    5217  }
    5218  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5219  {
    5220  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    5221  }
    5222  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5223  {
    5224  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
    5225  }
    5226  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5227  {
    5228  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5229  }
    5230  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5231  {
    5232  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
    5233  }
    5234  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5235  {
    5236  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5237  }
    5238 
    5239  return false;
    5240  }
    5241 
    5260  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    5261  {
    5262  return v.is_null();
    5263  }
    5264 
    5269  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    5270  {
    5271  return v.is_null();
    5272  }
    5273 
    5290  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    5291  {
    5292  return not (lhs == rhs);
    5293  }
    5294 
    5313  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    5314  {
    5315  return not v.is_null();
    5316  }
    5317 
    5322  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    5323  {
    5324  return not v.is_null();
    5325  }
    5326 
    5351  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    5352  {
    5353  const auto lhs_type = lhs.type();
    5354  const auto rhs_type = rhs.type();
    5355 
    5356  if (lhs_type == rhs_type)
    5357  {
    5358  switch (lhs_type)
    5359  {
    5360  case value_t::array:
    5361  {
    5362  assert(lhs.m_value.array != nullptr);
    5363  assert(rhs.m_value.array != nullptr);
    5364  return *lhs.m_value.array < *rhs.m_value.array;
    5365  }
    5366  case value_t::object:
    5367  {
    5368  assert(lhs.m_value.object != nullptr);
    5369  assert(rhs.m_value.object != nullptr);
    5370  return *lhs.m_value.object < *rhs.m_value.object;
    5371  }
    5372  case value_t::null:
    5373  {
    5374  return false;
    5375  }
    5376  case value_t::string:
    5377  {
    5378  assert(lhs.m_value.string != nullptr);
    5379  assert(rhs.m_value.string != nullptr);
    5380  return *lhs.m_value.string < *rhs.m_value.string;
    5381  }
    5382  case value_t::boolean:
    5383  {
    5384  return lhs.m_value.boolean < rhs.m_value.boolean;
    5385  }
    5386  case value_t::number_integer:
    5387  {
    5388  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5389  }
    5390  case value_t::number_unsigned:
    5391  {
    5392  return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
    5393  }
    5394  case value_t::number_float:
    5395  {
    5396  return lhs.m_value.number_float < rhs.m_value.number_float;
    5397  }
    5398  default:
    5399  {
    5400  return false;
    5401  }
    5402  }
    5403  }
    5404  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5405  {
    5406  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
    5407  }
    5408  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5409  {
    5410  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
    5411  }
    5412  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5413  {
    5414  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
    5415  }
    5416  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5417  {
    5418  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5419  }
    5420  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5421  {
    5422  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5423  }
    5424  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5425  {
    5426  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
    5427  }
    5428 
    5429  // We only reach this line if we cannot compare values. In that case,
    5430  // we compare types. Note we have to call the operator explicitly,
    5431  // because MSVC has problems otherwise.
    5432  return operator<(lhs_type, rhs_type);
    5433  }
    5434 
    5452  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5453  {
    5454  return not (rhs < lhs);
    5455  }
    5456 
    5474  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5475  {
    5476  return not (lhs <= rhs);
    5477  }
    5478 
    5496  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5497  {
    5498  return not (lhs < rhs);
    5499  }
    5500 
    5502 
    5503 
    5505  // serialization //
    5507 
    5510 
    5533  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5534  {
    5535  // read width member and use it as indentation parameter if nonzero
    5536  const bool pretty_print = (o.width() > 0);
    5537  const auto indentation = (pretty_print ? o.width() : 0);
    5538 
    5539  // reset width to 0 for subsequent calls to this stream
    5540  o.width(0);
    5541 
    5542  // do the actual serialization
    5543  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5544  return o;
    5545  }
    5546 
    5551  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5552  {
    5553  return o << j;
    5554  }
    5555 
    5557 
    5558 
    5560  // deserialization //
    5562 
    5565 
    5590  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5591  {
    5592  return parser(s, cb).parse();
    5593  }
    5594 
    5619  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5620  {
    5621  return parser(i, cb).parse();
    5622  }
    5623 
    5627  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5628  {
    5629  return parser(i, cb).parse();
    5630  }
    5631 
    5655  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5656  {
    5657  j = parser(i).parse();
    5658  return i;
    5659  }
    5660 
    5665  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5666  {
    5667  j = parser(i).parse();
    5668  return i;
    5669  }
    5670 
    5672 
    5673 
    5674  private:
    5676  // convenience functions //
    5678 
    5680  string_t type_name() const
    5681  {
    5682  switch (m_type)
    5683  {
    5684  case value_t::null:
    5685  return "null";
    5686  case value_t::object:
    5687  return "object";
    5688  case value_t::array:
    5689  return "array";
    5690  case value_t::string:
    5691  return "string";
    5692  case value_t::boolean:
    5693  return "boolean";
    5694  case value_t::discarded:
    5695  return "discarded";
    5696  default:
    5697  return "number";
    5698  }
    5699  }
    5700 
    5709  static std::size_t extra_space(const string_t& s) noexcept
    5710  {
    5711  std::size_t result = 0;
    5712 
    5713  for (const auto& c : s)
    5714  {
    5715  switch (c)
    5716  {
    5717  case '"':
    5718  case '\\':
    5719  case '\b':
    5720  case '\f':
    5721  case '\n':
    5722  case '\r':
    5723  case '\t':
    5724  {
    5725  // from c (1 byte) to \x (2 bytes)
    5726  result += 1;
    5727  break;
    5728  }
    5729 
    5730  default:
    5731  {
    5732  if (c >= 0x00 and c <= 0x1f)
    5733  {
    5734  // from c (1 byte) to \uxxxx (6 bytes)
    5735  result += 5;
    5736  }
    5737  break;
    5738  }
    5739  }
    5740  }
    5741 
    5742  return result;
    5743  }
    5744 
    5758  static string_t escape_string(const string_t& s) noexcept
    5759  {
    5760  const auto space = extra_space(s);
    5761  if (space == 0)
    5762  {
    5763  return s;
    5764  }
    5765 
    5766  // create a result string of necessary size
    5767  string_t result(s.size() + space, '\\');
    5768  std::size_t pos = 0;
    5769 
    5770  for (const auto& c : s)
    5771  {
    5772  switch (c)
    5773  {
    5774  // quotation mark (0x22)
    5775  case '"':
    5776  {
    5777  result[pos + 1] = '"';
    5778  pos += 2;
    5779  break;
    5780  }
    5781 
    5782  // reverse solidus (0x5c)
    5783  case '\\':
    5784  {
    5785  // nothing to change
    5786  pos += 2;
    5787  break;
    5788  }
    5789 
    5790  // backspace (0x08)
    5791  case '\b':
    5792  {
    5793  result[pos + 1] = 'b';
    5794  pos += 2;
    5795  break;
    5796  }
    5797 
    5798  // formfeed (0x0c)
    5799  case '\f':
    5800  {
    5801  result[pos + 1] = 'f';
    5802  pos += 2;
    5803  break;
    5804  }
    5805 
    5806  // newline (0x0a)
    5807  case '\n':
    5808  {
    5809  result[pos + 1] = 'n';
    5810  pos += 2;
    5811  break;
    5812  }
    5813 
    5814  // carriage return (0x0d)
    5815  case '\r':
    5816  {
    5817  result[pos + 1] = 'r';
    5818  pos += 2;
    5819  break;
    5820  }
    5821 
    5822  // horizontal tab (0x09)
    5823  case '\t':
    5824  {
    5825  result[pos + 1] = 't';
    5826  pos += 2;
    5827  break;
    5828  }
    5829 
    5830  default:
    5831  {
    5832  if (c >= 0x00 and c <= 0x1f)
    5833  {
    5834  // convert a number 0..15 to its hex representation
    5835  // (0..f)
    5836  auto hexify = [](const char v) -> char
    5837  {
    5838  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5839  };
    5840 
    5841  // print character c as \uxxxx
    5842  for (const char m :
    5843  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5844  })
    5845  {
    5846  result[++pos] = m;
    5847  }
    5848 
    5849  ++pos;
    5850  }
    5851  else
    5852  {
    5853  // all other characters are added as-is
    5854  result[pos++] = c;
    5855  }
    5856  break;
    5857  }
    5858  }
    5859  }
    5860 
    5861  return result;
    5862  }
    5863 
    5881  void dump(std::ostream& o,
    5882  const bool pretty_print,
    5883  const unsigned int indent_step,
    5884  const unsigned int current_indent = 0) const
    5885  {
    5886  // variable to hold indentation for recursive calls
    5887  unsigned int new_indent = current_indent;
    5888 
    5889  switch (m_type)
    5890  {
    5891  case value_t::object:
    5892  {
    5893  assert(m_value.object != nullptr);
    5894 
    5895  if (m_value.object->empty())
    5896  {
    5897  o << "{}";
    5898  return;
    5899  }
    5900 
    5901  o << "{";
    5902 
    5903  // increase indentation
    5904  if (pretty_print)
    5905  {
    5906  new_indent += indent_step;
    5907  o << "\n";
    5908  }
    5909 
    5910  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5911  {
    5912  if (i != m_value.object->cbegin())
    5913  {
    5914  o << (pretty_print ? ",\n" : ",");
    5915  }
    5916  o << string_t(new_indent, ' ') << "\""
    5917  << escape_string(i->first) << "\":"
    5918  << (pretty_print ? " " : "");
    5919  i->second.dump(o, pretty_print, indent_step, new_indent);
    5920  }
    5921 
    5922  // decrease indentation
    5923  if (pretty_print)
    5924  {
    5925  new_indent -= indent_step;
    5926  o << "\n";
    5927  }
    5928 
    5929  o << string_t(new_indent, ' ') + "}";
    5930  return;
    5931  }
    5932 
    5933  case value_t::array:
    5934  {
    5935  assert(m_value.array != nullptr);
    5936 
    5937  if (m_value.array->empty())
    5938  {
    5939  o << "[]";
    5940  return;
    5941  }
    5942 
    5943  o << "[";
    5944 
    5945  // increase indentation
    5946  if (pretty_print)
    5947  {
    5948  new_indent += indent_step;
    5949  o << "\n";
    5950  }
    5951 
    5952  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5953  {
    5954  if (i != m_value.array->cbegin())
    5955  {
    5956  o << (pretty_print ? ",\n" : ",");
    5957  }
    5958  o << string_t(new_indent, ' ');
    5959  i->dump(o, pretty_print, indent_step, new_indent);
    5960  }
    5961 
    5962  // decrease indentation
    5963  if (pretty_print)
    5964  {
    5965  new_indent -= indent_step;
    5966  o << "\n";
    5967  }
    5968 
    5969  o << string_t(new_indent, ' ') << "]";
    5970  return;
    5971  }
    5972 
    5973  case value_t::string:
    5974  {
    5975  assert(m_value.string != nullptr);
    5976  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5977  return;
    5978  }
    5979 
    5980  case value_t::boolean:
    5981  {
    5982  o << (m_value.boolean ? "true" : "false");
    5983  return;
    5984  }
    5985 
    5986  case value_t::number_integer:
    5987  {
    5988  o << m_value.number_integer;
    5989  return;
    5990  }
    5991 
    5992  case value_t::number_unsigned:
    5993  {
    5994  o << m_value.number_unsigned;
    5995  return;
    5996  }
    5997 
    5998  case value_t::number_float:
    5999  {
    6000  // If the number is an integer then output as a fixed with with
    6001  // precision 1 to output "0.0", "1.0" etc as expected for some
    6002  // round trip tests otherwise 15 digits of precision allows
    6003  // round-trip IEEE 754 string->double->string; to be safe, we
    6004  // read this value from
    6005  // std::numeric_limits<number_float_t>::digits10
    6006  if (std::fmod(m_value.number_float, 1) == 0)
    6007  {
    6008  o << std::fixed << std::setprecision(1);
    6009  }
    6010  else
    6011  {
    6012  // std::defaultfloat not supported in gcc version < 5
    6013  o.unsetf(std::ios_base::floatfield);
    6014  o << std::setprecision(std::numeric_limits<double>::digits10);
    6015  }
    6016  o << m_value.number_float;
    6017  return;
    6018  }
    6019 
    6020  case value_t::discarded:
    6021  {
    6022  o << "<discarded>";
    6023  return;
    6024  }
    6025 
    6026  case value_t::null:
    6027  {
    6028  o << "null";
    6029  return;
    6030  }
    6031  }
    6032  }
    6033 
    6034  private:
    6036  // member variables //
    6038 
    6040  value_t m_type = value_t::null;
    6041 
    6043  json_value m_value = {};
    6044 
    6045 
    6046  private:
    6048  // iterators //
    6050 
    6060  class primitive_iterator_t
    6061  {
    6062  public:
    6064  void set_begin()
    6065  {
    6066  m_it = begin_value;
    6067  }
    6068 
    6070  void set_end()
    6071  {
    6072  m_it = end_value;
    6073  }
    6074 
    6076  bool is_begin() const
    6077  {
    6078  return (m_it == begin_value);
    6079  }
    6080 
    6082  bool is_end() const
    6083  {
    6084  return (m_it == end_value);
    6085  }
    6086 
    6088  operator difference_type& ()
    6089  {
    6090  return m_it;
    6091  }
    6092 
    6094  operator difference_type () const
    6095  {
    6096  return m_it;
    6097  }
    6098 
    6099  private:
    6100  static constexpr difference_type begin_value = 0;
    6101  static constexpr difference_type end_value = begin_value + 1;
    6102 
    6104  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    6105  };
    6106 
    6114  struct internal_iterator
    6115  {
    6117  typename object_t::iterator object_iterator;
    6119  typename array_t::iterator array_iterator;
    6121  primitive_iterator_t primitive_iterator;
    6122 
    6124  internal_iterator()
    6125  : object_iterator(), array_iterator(), primitive_iterator()
    6126  {}
    6127  };
    6128 
    6130  template<typename IteratorType>
    6131  class iteration_proxy
    6132  {
    6133  private:
    6135  class iteration_proxy_internal
    6136  {
    6137  private:
    6139  IteratorType anchor;
    6141  size_t array_index = 0;
    6142 
    6143  public:
    6144  iteration_proxy_internal(IteratorType it)
    6145  : anchor(it)
    6146  {}
    6147 
    6149  iteration_proxy_internal& operator*()
    6150  {
    6151  return *this;
    6152  }
    6153 
    6155  iteration_proxy_internal& operator++()
    6156  {
    6157  ++anchor;
    6158  ++array_index;
    6159 
    6160  return *this;
    6161  }
    6162 
    6164  bool operator!= (const iteration_proxy_internal& o) const
    6165  {
    6166  return anchor != o.anchor;
    6167  }
    6168 
    6170  typename basic_json::string_t key() const
    6171  {
    6172  assert(anchor.m_object != nullptr);
    6173 
    6174  switch (anchor.m_object->type())
    6175  {
    6176  // use integer array index as key
    6177  case value_t::array:
    6178  {
    6179  return std::to_string(array_index);
    6180  }
    6181 
    6182  // use key from the object
    6183  case value_t::object:
    6184  {
    6185  return anchor.key();
    6186  }
    6187 
    6188  // use an empty key for all primitive types
    6189  default:
    6190  {
    6191  return "";
    6192  }
    6193  }
    6194  }
    6195 
    6197  typename IteratorType::reference value() const
    6198  {
    6199  return anchor.value();
    6200  }
    6201  };
    6202 
    6204  typename IteratorType::reference container;
    6205 
    6206  public:
    6208  iteration_proxy(typename IteratorType::reference cont)
    6209  : container(cont)
    6210  {}
    6211 
    6213  iteration_proxy_internal begin()
    6214  {
    6215  return iteration_proxy_internal(container.begin());
    6216  }
    6217 
    6219  iteration_proxy_internal end()
    6220  {
    6221  return iteration_proxy_internal(container.end());
    6222  }
    6223  };
    6224 
    6225  public:
    6239  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    6240  {
    6242  friend class basic_json;
    6243 
    6244  public:
    6254  using iterator_category = std::bidirectional_iterator_tag;
    6255 
    6257  const_iterator() = default;
    6258 
    6260  const_iterator(pointer object) : m_object(object)
    6261  {
    6262  assert(m_object != nullptr);
    6263 
    6264  switch (m_object->m_type)
    6265  {
    6267  {
    6268  m_it.object_iterator = typename object_t::iterator();
    6269  break;
    6270  }
    6271 
    6273  {
    6274  m_it.array_iterator = typename array_t::iterator();
    6275  break;
    6276  }
    6277 
    6278  default:
    6279  {
    6280  m_it.primitive_iterator = primitive_iterator_t();
    6281  break;
    6282  }
    6283  }
    6284  }
    6285 
    6287  const_iterator(const iterator& other) : m_object(other.m_object)
    6288  {
    6289  assert(m_object != nullptr);
    6290 
    6291  switch (m_object->m_type)
    6292  {
    6294  {
    6295  m_it.object_iterator = other.m_it.object_iterator;
    6296  break;
    6297  }
    6298 
    6300  {
    6301  m_it.array_iterator = other.m_it.array_iterator;
    6302  break;
    6303  }
    6304 
    6305  default:
    6306  {
    6307  m_it.primitive_iterator = other.m_it.primitive_iterator;
    6308  break;
    6309  }
    6310  }
    6311  }
    6312 
    6314  const_iterator(const const_iterator& other) noexcept
    6315  : m_object(other.m_object), m_it(other.m_it)
    6316  {}
    6317 
    6320  std::is_nothrow_move_constructible<pointer>::value and
    6321  std::is_nothrow_move_assignable<pointer>::value and
    6322  std::is_nothrow_move_constructible<internal_iterator>::value and
    6323  std::is_nothrow_move_assignable<internal_iterator>::value
    6324  )
    6325  {
    6326  std::swap(m_object, other.m_object);
    6327  std::swap(m_it, other.m_it);
    6328  return *this;
    6329  }
    6330 
    6331  private:
    6333  void set_begin()
    6334  {
    6335  assert(m_object != nullptr);
    6336 
    6337  switch (m_object->m_type)
    6338  {
    6340  {
    6341  assert(m_object->m_value.object != nullptr);
    6342  m_it.object_iterator = m_object->m_value.object->begin();
    6343  break;
    6344  }
    6345 
    6347  {
    6348  assert(m_object->m_value.array != nullptr);
    6349  m_it.array_iterator = m_object->m_value.array->begin();
    6350  break;
    6351  }
    6352 
    6354  {
    6355  // set to end so begin()==end() is true: null is empty
    6356  m_it.primitive_iterator.set_end();
    6357  break;
    6358  }
    6359 
    6360  default:
    6361  {
    6362  m_it.primitive_iterator.set_begin();
    6363  break;
    6364  }
    6365  }
    6366  }
    6367 
    6369  void set_end()
    6370  {
    6371  assert(m_object != nullptr);
    6372 
    6373  switch (m_object->m_type)
    6374  {
    6376  {
    6377  assert(m_object->m_value.object != nullptr);
    6378  m_it.object_iterator = m_object->m_value.object->end();
    6379  break;
    6380  }
    6381 
    6383  {
    6384  assert(m_object->m_value.array != nullptr);
    6385  m_it.array_iterator = m_object->m_value.array->end();
    6386  break;
    6387  }
    6388 
    6389  default:
    6390  {
    6391  m_it.primitive_iterator.set_end();
    6392  break;
    6393  }
    6394  }
    6395  }
    6396 
    6397  public:
    6400  {
    6401  assert(m_object != nullptr);
    6402 
    6403  switch (m_object->m_type)
    6404  {
    6406  {
    6407  assert(m_object->m_value.object);
    6408  assert(m_it.object_iterator != m_object->m_value.object->end());
    6409  return m_it.object_iterator->second;
    6410  }
    6411 
    6413  {
    6414  assert(m_object->m_value.array);
    6415  assert(m_it.array_iterator != m_object->m_value.array->end());
    6416  return *m_it.array_iterator;
    6417  }
    6418 
    6420  {
    6421  throw std::out_of_range("cannot get value");
    6422  }
    6423 
    6424  default:
    6425  {
    6426  if (m_it.primitive_iterator.is_begin())
    6427  {
    6428  return *m_object;
    6429  }
    6430  else
    6431  {
    6432  throw std::out_of_range("cannot get value");
    6433  }
    6434  }
    6435  }
    6436  }
    6437 
    6440  {
    6441  assert(m_object != nullptr);
    6442 
    6443  switch (m_object->m_type)
    6444  {
    6446  {
    6447  assert(m_object->m_value.object);
    6448  assert(m_it.object_iterator != m_object->m_value.object->end());
    6449  return &(m_it.object_iterator->second);
    6450  }
    6451 
    6453  {
    6454  assert(m_object->m_value.array);
    6455  assert(m_it.array_iterator != m_object->m_value.array->end());
    6456  return &*m_it.array_iterator;
    6457  }
    6458 
    6459  default:
    6460  {
    6461  if (m_it.primitive_iterator.is_begin())
    6462  {
    6463  return m_object;
    6464  }
    6465  else
    6466  {
    6467  throw std::out_of_range("cannot get value");
    6468  }
    6469  }
    6470  }
    6471  }
    6472 
    6475  {
    6476  auto result = *this;
    6477  ++(*this);
    6478  return result;
    6479  }
    6480 
    6483  {
    6484  assert(m_object != nullptr);
    6485 
    6486  switch (m_object->m_type)
    6487  {
    6489  {
    6490  ++m_it.object_iterator;
    6491  break;
    6492  }
    6493 
    6495  {
    6496  ++m_it.array_iterator;
    6497  break;
    6498  }
    6499 
    6500  default:
    6501  {
    6502  ++m_it.primitive_iterator;
    6503  break;
    6504  }
    6505  }
    6506 
    6507  return *this;
    6508  }
    6509 
    6512  {
    6513  auto result = *this;
    6514  --(*this);
    6515  return result;
    6516  }
    6517 
    6520  {
    6521  assert(m_object != nullptr);
    6522 
    6523  switch (m_object->m_type)
    6524  {
    6526  {
    6527  --m_it.object_iterator;
    6528  break;
    6529  }
    6530 
    6532  {
    6533  --m_it.array_iterator;
    6534  break;
    6535  }
    6536 
    6537  default:
    6538  {
    6539  --m_it.primitive_iterator;
    6540  break;
    6541  }
    6542  }
    6543 
    6544  return *this;
    6545  }
    6546 
    6548  bool operator==(const const_iterator& other) const
    6549  {
    6550  // if objects are not the same, the comparison is undefined
    6551  if (m_object != other.m_object)
    6552  {
    6553  throw std::domain_error("cannot compare iterators of different containers");
    6554  }
    6555 
    6556  assert(m_object != nullptr);
    6557 
    6558  switch (m_object->m_type)
    6559  {
    6561  {
    6562  return (m_it.object_iterator == other.m_it.object_iterator);
    6563  }
    6564 
    6566  {
    6567  return (m_it.array_iterator == other.m_it.array_iterator);
    6568  }
    6569 
    6570  default:
    6571  {
    6572  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6573  }
    6574  }
    6575  }
    6576 
    6578  bool operator!=(const const_iterator& other) const
    6579  {
    6580  return not operator==(other);
    6581  }
    6582 
    6584  bool operator<(const const_iterator& other) const
    6585  {
    6586  // if objects are not the same, the comparison is undefined
    6587  if (m_object != other.m_object)
    6588  {
    6589  throw std::domain_error("cannot compare iterators of different containers");
    6590  }
    6591 
    6592  assert(m_object != nullptr);
    6593 
    6594  switch (m_object->m_type)
    6595  {
    6597  {
    6598  throw std::domain_error("cannot compare order of object iterators");
    6599  }
    6600 
    6602  {
    6603  return (m_it.array_iterator < other.m_it.array_iterator);
    6604  }
    6605 
    6606  default:
    6607  {
    6608  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6609  }
    6610  }
    6611  }
    6612 
    6614  bool operator<=(const const_iterator& other) const
    6615  {
    6616  return not other.operator < (*this);
    6617  }
    6618 
    6620  bool operator>(const const_iterator& other) const
    6621  {
    6622  return not operator<=(other);
    6623  }
    6624 
    6626  bool operator>=(const const_iterator& other) const
    6627  {
    6628  return not operator<(other);
    6629  }
    6630 
    6633  {
    6634  assert(m_object != nullptr);
    6635 
    6636  switch (m_object->m_type)
    6637  {
    6639  {
    6640  throw std::domain_error("cannot use offsets with object iterators");
    6641  }
    6642 
    6644  {
    6645  m_it.array_iterator += i;
    6646  break;
    6647  }
    6648 
    6649  default:
    6650  {
    6651  m_it.primitive_iterator += i;
    6652  break;
    6653  }
    6654  }
    6655 
    6656  return *this;
    6657  }
    6658 
    6661  {
    6662  return operator+=(-i);
    6663  }
    6664 
    6667  {
    6668  auto result = *this;
    6669  result += i;
    6670  return result;
    6671  }
    6672 
    6675  {
    6676  auto result = *this;
    6677  result -= i;
    6678  return result;
    6679  }
    6680 
    6683  {
    6684  assert(m_object != nullptr);
    6685 
    6686  switch (m_object->m_type)
    6687  {
    6689  {
    6690  throw std::domain_error("cannot use offsets with object iterators");
    6691  }
    6692 
    6694  {
    6695  return m_it.array_iterator - other.m_it.array_iterator;
    6696  }
    6697 
    6698  default:
    6699  {
    6700  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6701  }
    6702  }
    6703  }
    6704 
    6707  {
    6708  assert(m_object != nullptr);
    6709 
    6710  switch (m_object->m_type)
    6711  {
    6713  {
    6714  throw std::domain_error("cannot use operator[] for object iterators");
    6715  }
    6716 
    6718  {
    6719  return *(m_it.array_iterator + n);
    6720  }
    6721 
    6723  {
    6724  throw std::out_of_range("cannot get value");
    6725  }
    6726 
    6727  default:
    6728  {
    6729  if (m_it.primitive_iterator == -n)
    6730  {
    6731  return *m_object;
    6732  }
    6733  else
    6734  {
    6735  throw std::out_of_range("cannot get value");
    6736  }
    6737  }
    6738  }
    6739  }
    6740 
    6742  typename object_t::key_type key() const
    6743  {
    6744  assert(m_object != nullptr);
    6745 
    6746  if (m_object->is_object())
    6747  {
    6748  return m_it.object_iterator->first;
    6749  }
    6750  else
    6751  {
    6752  throw std::domain_error("cannot use key() for non-object iterators");
    6753  }
    6754  }
    6755 
    6758  {
    6759  return operator*();
    6760  }
    6761 
    6762  private:
    6764  pointer m_object = nullptr;
    6766  internal_iterator m_it = internal_iterator();
    6767  };
    6768 
    6781  class iterator : public const_iterator
    6782  {
    6783  public:
    6785  using pointer = typename basic_json::pointer;
    6787 
    6789  iterator() = default;
    6790 
    6792  iterator(pointer object) noexcept
    6793  : base_iterator(object)
    6794  {}
    6795 
    6797  iterator(const iterator& other) noexcept
    6798  : base_iterator(other)
    6799  {}
    6800 
    6802  iterator& operator=(iterator other) noexcept(
    6803  std::is_nothrow_move_constructible<pointer>::value and
    6804  std::is_nothrow_move_assignable<pointer>::value and
    6805  std::is_nothrow_move_constructible<internal_iterator>::value and
    6806  std::is_nothrow_move_assignable<internal_iterator>::value
    6807  )
    6808  {
    6809  base_iterator::operator=(other);
    6810  return *this;
    6811  }
    6812 
    6815  {
    6816  return const_cast<reference>(base_iterator::operator*());
    6817  }
    6818 
    6821  {
    6822  return const_cast<pointer>(base_iterator::operator->());
    6823  }
    6824 
    6827  {
    6828  iterator result = *this;
    6829  base_iterator::operator++();
    6830  return result;
    6831  }
    6832 
    6835  {
    6836  base_iterator::operator++();
    6837  return *this;
    6838  }
    6839 
    6842  {
    6843  iterator result = *this;
    6844  base_iterator::operator--();
    6845  return result;
    6846  }
    6847 
    6850  {
    6851  base_iterator::operator--();
    6852  return *this;
    6853  }
    6854 
    6857  {
    6858  base_iterator::operator+=(i);
    6859  return *this;
    6860  }
    6861 
    6864  {
    6865  base_iterator::operator-=(i);
    6866  return *this;
    6867  }
    6868 
    6871  {
    6872  auto result = *this;
    6873  result += i;
    6874  return result;
    6875  }
    6876 
    6879  {
    6880  auto result = *this;
    6881  result -= i;
    6882  return result;
    6883  }
    6884 
    6886  difference_type operator-(const iterator& other) const
    6887  {
    6888  return base_iterator::operator-(other);
    6889  }
    6890 
    6893  {
    6894  return const_cast<reference>(base_iterator::operator[](n));
    6895  }
    6896 
    6899  {
    6900  return const_cast<reference>(base_iterator::value());
    6901  }
    6902  };
    6903 
    6921  template<typename Base>
    6922  class json_reverse_iterator : public std::reverse_iterator<Base>
    6923  {
    6924  public:
    6926  using base_iterator = std::reverse_iterator<Base>;
    6928  using reference = typename Base::reference;
    6929 
    6931  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6932  : base_iterator(it)
    6933  {}
    6934 
    6937  : base_iterator(it)
    6938  {}
    6939 
    6942  {
    6943  return base_iterator::operator++(1);
    6944  }
    6945 
    6948  {
    6949  base_iterator::operator++();
    6950  return *this;
    6951  }
    6952 
    6955  {
    6956  return base_iterator::operator--(1);
    6957  }
    6958 
    6961  {
    6962  base_iterator::operator--();
    6963  return *this;
    6964  }
    6965 
    6968  {
    6969  base_iterator::operator+=(i);
    6970  return *this;
    6971  }
    6972 
    6975  {
    6976  auto result = *this;
    6977  result += i;
    6978  return result;
    6979  }
    6980 
    6983  {
    6984  auto result = *this;
    6985  result -= i;
    6986  return result;
    6987  }
    6988 
    6991  {
    6992  return this->base() - other.base();
    6993  }
    6994 
    6997  {
    6998  return *(this->operator+(n));
    6999  }
    7000 
    7002  typename object_t::key_type key() const
    7003  {
    7004  auto it = --this->base();
    7005  return it.key();
    7006  }
    7007 
    7010  {
    7011  auto it = --this->base();
    7012  return it.operator * ();
    7013  }
    7014  };
    7015 
    7016 
    7017  private:
    7019  // lexer and parser //
    7021 
    7029  class lexer
    7030  {
    7031  public:
    7033  enum class token_type
    7034  {
    7035  uninitialized,
    7036  literal_true,
    7037  literal_false,
    7038  literal_null,
    7039  value_string,
    7040  value_number,
    7041  begin_array,
    7042  begin_object,
    7043  end_array,
    7044  end_object,
    7045  name_separator,
    7046  value_separator,
    7047  parse_error,
    7048  end_of_input
    7049  };
    7050 
    7052  using lexer_char_t = unsigned char;
    7053 
    7055  explicit lexer(const string_t& s) noexcept
    7056  : m_stream(nullptr), m_buffer(s)
    7057  {
    7058  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    7059  assert(m_content != nullptr);
    7060  m_start = m_cursor = m_content;
    7061  m_limit = m_content + s.size();
    7062  }
    7063 
    7065  explicit lexer(std::istream* s) noexcept
    7066  : m_stream(s), m_buffer()
    7067  {
    7068  assert(m_stream != nullptr);
    7069  getline(*m_stream, m_buffer);
    7070  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7071  assert(m_content != nullptr);
    7072  m_start = m_cursor = m_content;
    7073  m_limit = m_content + m_buffer.size();
    7074  }
    7075 
    7077  lexer() = default;
    7078 
    7079  // switch off unwanted functions
    7080  lexer(const lexer&) = delete;
    7081  lexer operator=(const lexer&) = delete;
    7082 
    7098  static string_t to_unicode(const std::size_t codepoint1,
    7099  const std::size_t codepoint2 = 0)
    7100  {
    7101  // calculate the codepoint from the given code points
    7102  std::size_t codepoint = codepoint1;
    7103 
    7104  // check if codepoint1 is a high surrogate
    7105  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    7106  {
    7107  // check if codepoint2 is a low surrogate
    7108  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    7109  {
    7110  codepoint =
    7111  // high surrogate occupies the most significant 22 bits
    7112  (codepoint1 << 10)
    7113  // low surrogate occupies the least significant 15 bits
    7114  + codepoint2
    7115  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    7116  // in the result so we have to subtract with:
    7117  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    7118  - 0x35FDC00;
    7119  }
    7120  else
    7121  {
    7122  throw std::invalid_argument("missing or wrong low surrogate");
    7123  }
    7124  }
    7125 
    7126  string_t result;
    7127 
    7128  if (codepoint < 0x80)
    7129  {
    7130  // 1-byte characters: 0xxxxxxx (ASCII)
    7131  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    7132  }
    7133  else if (codepoint <= 0x7ff)
    7134  {
    7135  // 2-byte characters: 110xxxxx 10xxxxxx
    7136  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    7137  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7138  }
    7139  else if (codepoint <= 0xffff)
    7140  {
    7141  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    7142  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    7143  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7144  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7145  }
    7146  else if (codepoint <= 0x10ffff)
    7147  {
    7148  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    7149  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    7150  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    7151  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7152  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7153  }
    7154  else
    7155  {
    7156  throw std::out_of_range("code points above 0x10FFFF are invalid");
    7157  }
    7158 
    7159  return result;
    7160  }
    7161 
    7163  static std::string token_type_name(token_type t)
    7164  {
    7165  switch (t)
    7166  {
    7167  case token_type::uninitialized:
    7168  return "<uninitialized>";
    7169  case token_type::literal_true:
    7170  return "true literal";
    7171  case token_type::literal_false:
    7172  return "false literal";
    7173  case token_type::literal_null:
    7174  return "null literal";
    7175  case token_type::value_string:
    7176  return "string literal";
    7177  case token_type::value_number:
    7178  return "number literal";
    7179  case token_type::begin_array:
    7180  return "'['";
    7181  case token_type::begin_object:
    7182  return "'{'";
    7183  case token_type::end_array:
    7184  return "']'";
    7185  case token_type::end_object:
    7186  return "'}'";
    7187  case token_type::name_separator:
    7188  return "':'";
    7189  case token_type::value_separator:
    7190  return "','";
    7191  case token_type::parse_error:
    7192  return "<parse error>";
    7193  case token_type::end_of_input:
    7194  return "end of input";
    7195  default:
    7196  {
    7197  // catch non-enum values
    7198  return "unknown token"; // LCOV_EXCL_LINE
    7199  }
    7200  }
    7201  }
    7202 
    7213  token_type scan() noexcept
    7214  {
    7215  // pointer for backtracking information
    7216  m_marker = nullptr;
    7217 
    7218  // remember the begin of the token
    7219  m_start = m_cursor;
    7220  assert(m_start != nullptr);
    7221 
    7222 
    7223  {
    7224  lexer_char_t yych;
    7225  unsigned int yyaccept = 0;
    7226  static const unsigned char yybm[] =
    7227  {
    7228  0, 0, 0, 0, 0, 0, 0, 0,
    7229  0, 32, 32, 0, 0, 32, 0, 0,
    7230  128, 128, 128, 128, 128, 128, 128, 128,
    7231  128, 128, 128, 128, 128, 128, 128, 128,
    7232  160, 128, 0, 128, 128, 128, 128, 128,
    7233  128, 128, 128, 128, 128, 128, 128, 128,
    7234  192, 192, 192, 192, 192, 192, 192, 192,
    7235  192, 192, 128, 128, 128, 128, 128, 128,
    7236  128, 128, 128, 128, 128, 128, 128, 128,
    7237  128, 128, 128, 128, 128, 128, 128, 128,
    7238  128, 128, 128, 128, 128, 128, 128, 128,
    7239  128, 128, 128, 128, 0, 128, 128, 128,
    7240  128, 128, 128, 128, 128, 128, 128, 128,
    7241  128, 128, 128, 128, 128, 128, 128, 128,
    7242  128, 128, 128, 128, 128, 128, 128, 128,
    7243  128, 128, 128, 128, 128, 128, 128, 128,
    7244  128, 128, 128, 128, 128, 128, 128, 128,
    7245  128, 128, 128, 128, 128, 128, 128, 128,
    7246  128, 128, 128, 128, 128, 128, 128, 128,
    7247  128, 128, 128, 128, 128, 128, 128, 128,
    7248  128, 128, 128, 128, 128, 128, 128, 128,
    7249  128, 128, 128, 128, 128, 128, 128, 128,
    7250  128, 128, 128, 128, 128, 128, 128, 128,
    7251  128, 128, 128, 128, 128, 128, 128, 128,
    7252  128, 128, 128, 128, 128, 128, 128, 128,
    7253  128, 128, 128, 128, 128, 128, 128, 128,
    7254  128, 128, 128, 128, 128, 128, 128, 128,
    7255  128, 128, 128, 128, 128, 128, 128, 128,
    7256  128, 128, 128, 128, 128, 128, 128, 128,
    7257  128, 128, 128, 128, 128, 128, 128, 128,
    7258  128, 128, 128, 128, 128, 128, 128, 128,
    7259  128, 128, 128, 128, 128, 128, 128, 128,
    7260  };
    7261  if ((m_limit - m_cursor) < 5)
    7262  {
    7263  yyfill(); // LCOV_EXCL_LINE;
    7264  }
    7265  yych = *m_cursor;
    7266  if (yybm[0 + yych] & 32)
    7267  {
    7268  goto basic_json_parser_6;
    7269  }
    7270  if (yych <= '\\')
    7271  {
    7272  if (yych <= '-')
    7273  {
    7274  if (yych <= '"')
    7275  {
    7276  if (yych <= 0x00)
    7277  {
    7278  goto basic_json_parser_2;
    7279  }
    7280  if (yych <= '!')
    7281  {
    7282  goto basic_json_parser_4;
    7283  }
    7284  goto basic_json_parser_9;
    7285  }
    7286  else
    7287  {
    7288  if (yych <= '+')
    7289  {
    7290  goto basic_json_parser_4;
    7291  }
    7292  if (yych <= ',')
    7293  {
    7294  goto basic_json_parser_10;
    7295  }
    7296  goto basic_json_parser_12;
    7297  }
    7298  }
    7299  else
    7300  {
    7301  if (yych <= '9')
    7302  {
    7303  if (yych <= '/')
    7304  {
    7305  goto basic_json_parser_4;
    7306  }
    7307  if (yych <= '0')
    7308  {
    7309  goto basic_json_parser_13;
    7310  }
    7311  goto basic_json_parser_15;
    7312  }
    7313  else
    7314  {
    7315  if (yych <= ':')
    7316  {
    7317  goto basic_json_parser_17;
    7318  }
    7319  if (yych == '[')
    7320  {
    7321  goto basic_json_parser_19;
    7322  }
    7323  goto basic_json_parser_4;
    7324  }
    7325  }
    7326  }
    7327  else
    7328  {
    7329  if (yych <= 't')
    7330  {
    7331  if (yych <= 'f')
    7332  {
    7333  if (yych <= ']')
    7334  {
    7335  goto basic_json_parser_21;
    7336  }
    7337  if (yych <= 'e')
    7338  {
    7339  goto basic_json_parser_4;
    7340  }
    7341  goto basic_json_parser_23;
    7342  }
    7343  else
    7344  {
    7345  if (yych == 'n')
    7346  {
    7347  goto basic_json_parser_24;
    7348  }
    7349  if (yych <= 's')
    7350  {
    7351  goto basic_json_parser_4;
    7352  }
    7353  goto basic_json_parser_25;
    7354  }
    7355  }
    7356  else
    7357  {
    7358  if (yych <= '|')
    7359  {
    7360  if (yych == '{')
    7361  {
    7362  goto basic_json_parser_26;
    7363  }
    7364  goto basic_json_parser_4;
    7365  }
    7366  else
    7367  {
    7368  if (yych <= '}')
    7369  {
    7370  goto basic_json_parser_28;
    7371  }
    7372  if (yych == 0xEF)
    7373  {
    7374  goto basic_json_parser_30;
    7375  }
    7376  goto basic_json_parser_4;
    7377  }
    7378  }
    7379  }
    7380 basic_json_parser_2:
    7381  ++m_cursor;
    7382  {
    7383  return token_type::end_of_input;
    7384  }
    7385 basic_json_parser_4:
    7386  ++m_cursor;
    7387 basic_json_parser_5:
    7388  {
    7389  return token_type::parse_error;
    7390  }
    7391 basic_json_parser_6:
    7392  ++m_cursor;
    7393  if (m_limit <= m_cursor)
    7394  {
    7395  yyfill(); // LCOV_EXCL_LINE;
    7396  }
    7397  yych = *m_cursor;
    7398  if (yybm[0 + yych] & 32)
    7399  {
    7400  goto basic_json_parser_6;
    7401  }
    7402  {
    7403  return scan();
    7404  }
    7405 basic_json_parser_9:
    7406  yyaccept = 0;
    7407  yych = *(m_marker = ++m_cursor);
    7408  if (yych <= 0x0F)
    7409  {
    7410  goto basic_json_parser_5;
    7411  }
    7412  goto basic_json_parser_32;
    7413 basic_json_parser_10:
    7414  ++m_cursor;
    7415  {
    7416  return token_type::value_separator;
    7417  }
    7418 basic_json_parser_12:
    7419  yych = *++m_cursor;
    7420  if (yych <= '/')
    7421  {
    7422  goto basic_json_parser_5;
    7423  }
    7424  if (yych <= '0')
    7425  {
    7426  goto basic_json_parser_13;
    7427  }
    7428  if (yych <= '9')
    7429  {
    7430  goto basic_json_parser_15;
    7431  }
    7432  goto basic_json_parser_5;
    7433 basic_json_parser_13:
    7434  yyaccept = 1;
    7435  yych = *(m_marker = ++m_cursor);
    7436  if (yych <= 'D')
    7437  {
    7438  if (yych == '.')
    7439  {
    7440  goto basic_json_parser_37;
    7441  }
    7442  }
    7443  else
    7444  {
    7445  if (yych <= 'E')
    7446  {
    7447  goto basic_json_parser_38;
    7448  }
    7449  if (yych == 'e')
    7450  {
    7451  goto basic_json_parser_38;
    7452  }
    7453  }
    7454 basic_json_parser_14:
    7455  {
    7456  return token_type::value_number;
    7457  }
    7458 basic_json_parser_15:
    7459  yyaccept = 1;
    7460  m_marker = ++m_cursor;
    7461  if ((m_limit - m_cursor) < 3)
    7462  {
    7463  yyfill(); // LCOV_EXCL_LINE;
    7464  }
    7465  yych = *m_cursor;
    7466  if (yybm[0 + yych] & 64)
    7467  {
    7468  goto basic_json_parser_15;
    7469  }
    7470  if (yych <= 'D')
    7471  {
    7472  if (yych == '.')
    7473  {
    7474  goto basic_json_parser_37;
    7475  }
    7476  goto basic_json_parser_14;
    7477  }
    7478  else
    7479  {
    7480  if (yych <= 'E')
    7481  {
    7482  goto basic_json_parser_38;
    7483  }
    7484  if (yych == 'e')
    7485  {
    7486  goto basic_json_parser_38;
    7487  }
    7488  goto basic_json_parser_14;
    7489  }
    7490 basic_json_parser_17:
    7491  ++m_cursor;
    7492  {
    7493  return token_type::name_separator;
    7494  }
    7495 basic_json_parser_19:
    7496  ++m_cursor;
    7497  {
    7498  return token_type::begin_array;
    7499  }
    7500 basic_json_parser_21:
    7501  ++m_cursor;
    7502  {
    7503  return token_type::end_array;
    7504  }
    7505 basic_json_parser_23:
    7506  yyaccept = 0;
    7507  yych = *(m_marker = ++m_cursor);
    7508  if (yych == 'a')
    7509  {
    7510  goto basic_json_parser_39;
    7511  }
    7512  goto basic_json_parser_5;
    7513 basic_json_parser_24:
    7514  yyaccept = 0;
    7515  yych = *(m_marker = ++m_cursor);
    7516  if (yych == 'u')
    7517  {
    7518  goto basic_json_parser_40;
    7519  }
    7520  goto basic_json_parser_5;
    7521 basic_json_parser_25:
    7522  yyaccept = 0;
    7523  yych = *(m_marker = ++m_cursor);
    7524  if (yych == 'r')
    7525  {
    7526  goto basic_json_parser_41;
    7527  }
    7528  goto basic_json_parser_5;
    7529 basic_json_parser_26:
    7530  ++m_cursor;
    7531  {
    7532  return token_type::begin_object;
    7533  }
    7534 basic_json_parser_28:
    7535  ++m_cursor;
    7536  {
    7537  return token_type::end_object;
    7538  }
    7539 basic_json_parser_30:
    7540  yyaccept = 0;
    7541  yych = *(m_marker = ++m_cursor);
    7542  if (yych == 0xBB)
    7543  {
    7544  goto basic_json_parser_42;
    7545  }
    7546  goto basic_json_parser_5;
    7547 basic_json_parser_31:
    7548  ++m_cursor;
    7549  if (m_limit <= m_cursor)
    7550  {
    7551  yyfill(); // LCOV_EXCL_LINE;
    7552  }
    7553  yych = *m_cursor;
    7554 basic_json_parser_32:
    7555  if (yybm[0 + yych] & 128)
    7556  {
    7557  goto basic_json_parser_31;
    7558  }
    7559  if (yych <= 0x0F)
    7560  {
    7561  goto basic_json_parser_33;
    7562  }
    7563  if (yych <= '"')
    7564  {
    7565  goto basic_json_parser_34;
    7566  }
    7567  goto basic_json_parser_36;
    7568 basic_json_parser_33:
    7569  m_cursor = m_marker;
    7570  if (yyaccept == 0)
    7571  {
    7572  goto basic_json_parser_5;
    7573  }
    7574  else
    7575  {
    7576  goto basic_json_parser_14;
    7577  }
    7578 basic_json_parser_34:
    7579  ++m_cursor;
    7580  {
    7581  return token_type::value_string;
    7582  }
    7583 basic_json_parser_36:
    7584  ++m_cursor;
    7585  if (m_limit <= m_cursor)
    7586  {
    7587  yyfill(); // LCOV_EXCL_LINE;
    7588  }
    7589  yych = *m_cursor;
    7590  if (yych <= 'e')
    7591  {
    7592  if (yych <= '/')
    7593  {
    7594  if (yych == '"')
    7595  {
    7596  goto basic_json_parser_31;
    7597  }
    7598  if (yych <= '.')
    7599  {
    7600  goto basic_json_parser_33;
    7601  }
    7602  goto basic_json_parser_31;
    7603  }
    7604  else
    7605  {
    7606  if (yych <= '\\')
    7607  {
    7608  if (yych <= '[')
    7609  {
    7610  goto basic_json_parser_33;
    7611  }
    7612  goto basic_json_parser_31;
    7613  }
    7614  else
    7615  {
    7616  if (yych == 'b')
    7617  {
    7618  goto basic_json_parser_31;
    7619  }
    7620  goto basic_json_parser_33;
    7621  }
    7622  }
    7623  }
    7624  else
    7625  {
    7626  if (yych <= 'q')
    7627  {
    7628  if (yych <= 'f')
    7629  {
    7630  goto basic_json_parser_31;
    7631  }
    7632  if (yych == 'n')
    7633  {
    7634  goto basic_json_parser_31;
    7635  }
    7636  goto basic_json_parser_33;
    7637  }
    7638  else
    7639  {
    7640  if (yych <= 's')
    7641  {
    7642  if (yych <= 'r')
    7643  {
    7644  goto basic_json_parser_31;
    7645  }
    7646  goto basic_json_parser_33;
    7647  }
    7648  else
    7649  {
    7650  if (yych <= 't')
    7651  {
    7652  goto basic_json_parser_31;
    7653  }
    7654  if (yych <= 'u')
    7655  {
    7656  goto basic_json_parser_43;
    7657  }
    7658  goto basic_json_parser_33;
    7659  }
    7660  }
    7661  }
    7662 basic_json_parser_37:
    7663  yych = *++m_cursor;
    7664  if (yych <= '/')
    7665  {
    7666  goto basic_json_parser_33;
    7667  }
    7668  if (yych <= '9')
    7669  {
    7670  goto basic_json_parser_44;
    7671  }
    7672  goto basic_json_parser_33;
    7673 basic_json_parser_38:
    7674  yych = *++m_cursor;
    7675  if (yych <= ',')
    7676  {
    7677  if (yych == '+')
    7678  {
    7679  goto basic_json_parser_46;
    7680  }
    7681  goto basic_json_parser_33;
    7682  }
    7683  else
    7684  {
    7685  if (yych <= '-')
    7686  {
    7687  goto basic_json_parser_46;
    7688  }
    7689  if (yych <= '/')
    7690  {
    7691  goto basic_json_parser_33;
    7692  }
    7693  if (yych <= '9')
    7694  {
    7695  goto basic_json_parser_47;
    7696  }
    7697  goto basic_json_parser_33;
    7698  }
    7699 basic_json_parser_39:
    7700  yych = *++m_cursor;
    7701  if (yych == 'l')
    7702  {
    7703  goto basic_json_parser_49;
    7704  }
    7705  goto basic_json_parser_33;
    7706 basic_json_parser_40:
    7707  yych = *++m_cursor;
    7708  if (yych == 'l')
    7709  {
    7710  goto basic_json_parser_50;
    7711  }
    7712  goto basic_json_parser_33;
    7713 basic_json_parser_41:
    7714  yych = *++m_cursor;
    7715  if (yych == 'u')
    7716  {
    7717  goto basic_json_parser_51;
    7718  }
    7719  goto basic_json_parser_33;
    7720 basic_json_parser_42:
    7721  yych = *++m_cursor;
    7722  if (yych == 0xBF)
    7723  {
    7724  goto basic_json_parser_52;
    7725  }
    7726  goto basic_json_parser_33;
    7727 basic_json_parser_43:
    7728  ++m_cursor;
    7729  if (m_limit <= m_cursor)
    7730  {
    7731  yyfill(); // LCOV_EXCL_LINE;
    7732  }
    7733  yych = *m_cursor;
    7734  if (yych <= '@')
    7735  {
    7736  if (yych <= '/')
    7737  {
    7738  goto basic_json_parser_33;
    7739  }
    7740  if (yych <= '9')
    7741  {
    7742  goto basic_json_parser_54;
    7743  }
    7744  goto basic_json_parser_33;
    7745  }
    7746  else
    7747  {
    7748  if (yych <= 'F')
    7749  {
    7750  goto basic_json_parser_54;
    7751  }
    7752  if (yych <= '`')
    7753  {
    7754  goto basic_json_parser_33;
    7755  }
    7756  if (yych <= 'f')
    7757  {
    7758  goto basic_json_parser_54;
    7759  }
    7760  goto basic_json_parser_33;
    7761  }
    7762 basic_json_parser_44:
    7763  yyaccept = 1;
    7764  m_marker = ++m_cursor;
    7765  if ((m_limit - m_cursor) < 3)
    7766  {
    7767  yyfill(); // LCOV_EXCL_LINE;
    7768  }
    7769  yych = *m_cursor;
    7770  if (yych <= 'D')
    7771  {
    7772  if (yych <= '/')
    7773  {
    7774  goto basic_json_parser_14;
    7775  }
    7776  if (yych <= '9')
    7777  {
    7778  goto basic_json_parser_44;
    7779  }
    7780  goto basic_json_parser_14;
    7781  }
    7782  else
    7783  {
    7784  if (yych <= 'E')
    7785  {
    7786  goto basic_json_parser_38;
    7787  }
    7788  if (yych == 'e')
    7789  {
    7790  goto basic_json_parser_38;
    7791  }
    7792  goto basic_json_parser_14;
    7793  }
    7794 basic_json_parser_46:
    7795  yych = *++m_cursor;
    7796  if (yych <= '/')
    7797  {
    7798  goto basic_json_parser_33;
    7799  }
    7800  if (yych >= ':')
    7801  {
    7802  goto basic_json_parser_33;
    7803  }
    7804 basic_json_parser_47:
    7805  ++m_cursor;
    7806  if (m_limit <= m_cursor)
    7807  {
    7808  yyfill(); // LCOV_EXCL_LINE;
    7809  }
    7810  yych = *m_cursor;
    7811  if (yych <= '/')
    7812  {
    7813  goto basic_json_parser_14;
    7814  }
    7815  if (yych <= '9')
    7816  {
    7817  goto basic_json_parser_47;
    7818  }
    7819  goto basic_json_parser_14;
    7820 basic_json_parser_49:
    7821  yych = *++m_cursor;
    7822  if (yych == 's')
    7823  {
    7824  goto basic_json_parser_55;
    7825  }
    7826  goto basic_json_parser_33;
    7827 basic_json_parser_50:
    7828  yych = *++m_cursor;
    7829  if (yych == 'l')
    7830  {
    7831  goto basic_json_parser_56;
    7832  }
    7833  goto basic_json_parser_33;
    7834 basic_json_parser_51:
    7835  yych = *++m_cursor;
    7836  if (yych == 'e')
    7837  {
    7838  goto basic_json_parser_58;
    7839  }
    7840  goto basic_json_parser_33;
    7841 basic_json_parser_52:
    7842  ++m_cursor;
    7843  {
    7844  return scan();
    7845  }
    7846 basic_json_parser_54:
    7847  ++m_cursor;
    7848  if (m_limit <= m_cursor)
    7849  {
    7850  yyfill(); // LCOV_EXCL_LINE;
    7851  }
    7852  yych = *m_cursor;
    7853  if (yych <= '@')
    7854  {
    7855  if (yych <= '/')
    7856  {
    7857  goto basic_json_parser_33;
    7858  }
    7859  if (yych <= '9')
    7860  {
    7861  goto basic_json_parser_60;
    7862  }
    7863  goto basic_json_parser_33;
    7864  }
    7865  else
    7866  {
    7867  if (yych <= 'F')
    7868  {
    7869  goto basic_json_parser_60;
    7870  }
    7871  if (yych <= '`')
    7872  {
    7873  goto basic_json_parser_33;
    7874  }
    7875  if (yych <= 'f')
    7876  {
    7877  goto basic_json_parser_60;
    7878  }
    7879  goto basic_json_parser_33;
    7880  }
    7881 basic_json_parser_55:
    7882  yych = *++m_cursor;
    7883  if (yych == 'e')
    7884  {
    7885  goto basic_json_parser_61;
    7886  }
    7887  goto basic_json_parser_33;
    7888 basic_json_parser_56:
    7889  ++m_cursor;
    7890  {
    7891  return token_type::literal_null;
    7892  }
    7893 basic_json_parser_58:
    7894  ++m_cursor;
    7895  {
    7896  return token_type::literal_true;
    7897  }
    7898 basic_json_parser_60:
    7899  ++m_cursor;
    7900  if (m_limit <= m_cursor)
    7901  {
    7902  yyfill(); // LCOV_EXCL_LINE;
    7903  }
    7904  yych = *m_cursor;
    7905  if (yych <= '@')
    7906  {
    7907  if (yych <= '/')
    7908  {
    7909  goto basic_json_parser_33;
    7910  }
    7911  if (yych <= '9')
    7912  {
    7913  goto basic_json_parser_63;
    7914  }
    7915  goto basic_json_parser_33;
    7916  }
    7917  else
    7918  {
    7919  if (yych <= 'F')
    7920  {
    7921  goto basic_json_parser_63;
    7922  }
    7923  if (yych <= '`')
    7924  {
    7925  goto basic_json_parser_33;
    7926  }
    7927  if (yych <= 'f')
    7928  {
    7929  goto basic_json_parser_63;
    7930  }
    7931  goto basic_json_parser_33;
    7932  }
    7933 basic_json_parser_61:
    7934  ++m_cursor;
    7935  {
    7936  return token_type::literal_false;
    7937  }
    7938 basic_json_parser_63:
    7939  ++m_cursor;
    7940  if (m_limit <= m_cursor)
    7941  {
    7942  yyfill(); // LCOV_EXCL_LINE;
    7943  }
    7944  yych = *m_cursor;
    7945  if (yych <= '@')
    7946  {
    7947  if (yych <= '/')
    7948  {
    7949  goto basic_json_parser_33;
    7950  }
    7951  if (yych <= '9')
    7952  {
    7953  goto basic_json_parser_31;
    7954  }
    7955  goto basic_json_parser_33;
    7956  }
    7957  else
    7958  {
    7959  if (yych <= 'F')
    7960  {
    7961  goto basic_json_parser_31;
    7962  }
    7963  if (yych <= '`')
    7964  {
    7965  goto basic_json_parser_33;
    7966  }
    7967  if (yych <= 'f')
    7968  {
    7969  goto basic_json_parser_31;
    7970  }
    7971  goto basic_json_parser_33;
    7972  }
    7973  }
    7974 
    7975 
    7976  }
    7977 
    7979  void yyfill() noexcept
    7980  {
    7981  if (m_stream == nullptr or not * m_stream)
    7982  {
    7983  return;
    7984  }
    7985 
    7986  const ssize_t offset_start = m_start - m_content;
    7987  const ssize_t offset_marker = m_marker - m_start;
    7988  const ssize_t offset_cursor = m_cursor - m_start;
    7989 
    7990  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7991  std::string line;
    7992  assert(m_stream != nullptr);
    7993  std::getline(*m_stream, line);
    7994  m_buffer += "\n" + line; // add line with newline symbol
    7995 
    7996  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7997  assert(m_content != nullptr);
    7998  m_start = m_content;
    7999  m_marker = m_start + offset_marker;
    8000  m_cursor = m_start + offset_cursor;
    8001  m_limit = m_start + m_buffer.size() - 1;
    8002  }
    8003 
    8005  string_t get_token() const noexcept
    8006  {
    8007  assert(m_start != nullptr);
    8008  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    8009  static_cast<size_t>(m_cursor - m_start));
    8010  }
    8011 
    8033  string_t get_string() const
    8034  {
    8035  string_t result;
    8036  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    8037 
    8038  // iterate the result between the quotes
    8039  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    8040  {
    8041  // process escaped characters
    8042  if (*i == '\\')
    8043  {
    8044  // read next character
    8045  ++i;
    8046 
    8047  switch (*i)
    8048  {
    8049  // the default escapes
    8050  case 't':
    8051  {
    8052  result += "\t";
    8053  break;
    8054  }
    8055  case 'b':
    8056  {
    8057  result += "\b";
    8058  break;
    8059  }
    8060  case 'f':
    8061  {
    8062  result += "\f";
    8063  break;
    8064  }
    8065  case 'n':
    8066  {
    8067  result += "\n";
    8068  break;
    8069  }
    8070  case 'r':
    8071  {
    8072  result += "\r";
    8073  break;
    8074  }
    8075  case '\\':
    8076  {
    8077  result += "\\";
    8078  break;
    8079  }
    8080  case '/':
    8081  {
    8082  result += "/";
    8083  break;
    8084  }
    8085  case '"':
    8086  {
    8087  result += "\"";
    8088  break;
    8089  }
    8090 
    8091  // unicode
    8092  case 'u':
    8093  {
    8094  // get code xxxx from uxxxx
    8095  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    8096  4).c_str(), nullptr, 16);
    8097 
    8098  // check if codepoint is a high surrogate
    8099  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    8100  {
    8101  // make sure there is a subsequent unicode
    8102  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    8103  {
    8104  throw std::invalid_argument("missing low surrogate");
    8105  }
    8106 
    8107  // get code yyyy from uxxxx\uyyyy
    8108  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    8109  (i + 7), 4).c_str(), nullptr, 16);
    8110  result += to_unicode(codepoint, codepoint2);
    8111  // skip the next 10 characters (xxxx\uyyyy)
    8112  i += 10;
    8113  }
    8114  else
    8115  {
    8116  // add unicode character(s)
    8117  result += to_unicode(codepoint);
    8118  // skip the next four characters (xxxx)
    8119  i += 4;
    8120  }
    8121  break;
    8122  }
    8123  }
    8124  }
    8125  else
    8126  {
    8127  // all other characters are just copied to the end of the
    8128  // string
    8129  result.append(1, static_cast<typename string_t::value_type>(*i));
    8130  }
    8131  }
    8132 
    8133  return result;
    8134  }
    8135 
    8156  long double str_to_float_t(long double* /* type */, char** endptr) const
    8157  {
    8158  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8159  }
    8160 
    8176  double str_to_float_t(double* /* type */, char** endptr) const
    8177  {
    8178  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8179  }
    8180 
    8196  float str_to_float_t(float* /* type */, char** endptr) const
    8197  {
    8198  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8199  }
    8200 
    8213  template <typename T_A, typename T_B>
    8214  bool attempt_cast(T_A source, T_B& dest) const
    8215  {
    8216  dest = static_cast<T_B>(source);
    8217  return (source == static_cast<T_A>(dest));
    8218  }
    8219 
    8258  void get_number(basic_json& result) const
    8259  {
    8260  typename string_t::value_type* endptr;
    8261  assert(m_start != nullptr);
    8262  errno = 0;
    8263 
    8264  // attempt to parse it as an integer - first checking for a
    8265  // negative number
    8266  if (*reinterpret_cast<typename string_t::const_pointer>(m_start) != '-')
    8267  {
    8268  // positive, parse with strtoull and attempt cast to
    8269  // number_unsigned_t
    8270  if (attempt_cast(std::strtoull(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8271  10), result.m_value.number_unsigned))
    8272  {
    8273  result.m_type = value_t::number_unsigned;
    8274  }
    8275  else
    8276  {
    8277  // cast failed due to overflow - store as float
    8278  result.m_type = value_t::number_float;
    8279  }
    8280  }
    8281  else
    8282  {
    8283  // Negative, parse with strtoll and attempt cast to
    8284  // number_integer_t
    8285  if (attempt_cast(std::strtoll(reinterpret_cast<typename string_t::const_pointer>(m_start), &endptr,
    8286  10), result.m_value.number_integer))
    8287  {
    8288  result.m_type = value_t::number_integer;
    8289  }
    8290  else
    8291  {
    8292  // cast failed due to overflow - store as float
    8293  result.m_type = value_t::number_float;
    8294  }
    8295  }
    8296 
    8297  // check the end of the number was reached and no range error
    8298  // occurred
    8299  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor || errno == ERANGE)
    8300  {
    8301  result.m_type = value_t::number_float;
    8302  }
    8303 
    8304  if (result.m_type == value_t::number_float)
    8305  {
    8306  // either the number won't fit in an integer (range error from
    8307  // strtoull/strtoll or overflow on cast) or there was something
    8308  // else after the number, which could be an exponent
    8309 
    8310  // parse with strtod
    8311  result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), &endptr);
    8312 
    8313  // anything after the number is an error
    8314  if (reinterpret_cast<lexer_char_t*>(endptr) != m_cursor)
    8315  {
    8316  throw std::invalid_argument(std::string("parse error - ") + get_token() + " is not a number");
    8317  }
    8318  }
    8319  }
    8320 
    8321  private:
    8323  std::istream* m_stream = nullptr;
    8325  string_t m_buffer;
    8327  const lexer_char_t* m_content = nullptr;
    8329  const lexer_char_t* m_start = nullptr;
    8331  const lexer_char_t* m_marker = nullptr;
    8333  const lexer_char_t* m_cursor = nullptr;
    8335  const lexer_char_t* m_limit = nullptr;
    8336  };
    8337 
    8343  class parser
    8344  {
    8345  public:
    8347  parser(const string_t& s, parser_callback_t cb = nullptr)
    8348  : callback(cb), m_lexer(s)
    8349  {
    8350  // read first token
    8351  get_token();
    8352  }
    8353 
    8355  parser(std::istream& _is, parser_callback_t cb = nullptr)
    8356  : callback(cb), m_lexer(&_is)
    8357  {
    8358  // read first token
    8359  get_token();
    8360  }
    8361 
    8363  basic_json parse()
    8364  {
    8365  basic_json result = parse_internal(true);
    8366 
    8367  expect(lexer::token_type::end_of_input);
    8368 
    8369  // return parser result and replace it with null in case the
    8370  // top-level value was discarded by the callback function
    8371  return result.is_discarded() ? basic_json() : result;
    8372  }
    8373 
    8374  private:
    8376  basic_json parse_internal(bool keep)
    8377  {
    8378  auto result = basic_json(value_t::discarded);
    8379 
    8380  switch (last_token)
    8381  {
    8382  case lexer::token_type::begin_object:
    8383  {
    8384  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    8385  {
    8386  // explicitly set result to object to cope with {}
    8387  result.m_type = value_t::object;
    8388  result.m_value = json_value(value_t::object);
    8389  }
    8390 
    8391  // read next token
    8392  get_token();
    8393 
    8394  // closing } -> we are done
    8395  if (last_token == lexer::token_type::end_object)
    8396  {
    8397  get_token();
    8398  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8399  {
    8400  result = basic_json(value_t::discarded);
    8401  }
    8402  return result;
    8403  }
    8404 
    8405  // no comma is expected here
    8406  unexpect(lexer::token_type::value_separator);
    8407 
    8408  // otherwise: parse key-value pairs
    8409  do
    8410  {
    8411  // ugly, but could be fixed with loop reorganization
    8412  if (last_token == lexer::token_type::value_separator)
    8413  {
    8414  get_token();
    8415  }
    8416 
    8417  // store key
    8418  expect(lexer::token_type::value_string);
    8419  const auto key = m_lexer.get_string();
    8420 
    8421  bool keep_tag = false;
    8422  if (keep)
    8423  {
    8424  if (callback)
    8425  {
    8426  basic_json k(key);
    8427  keep_tag = callback(depth, parse_event_t::key, k);
    8428  }
    8429  else
    8430  {
    8431  keep_tag = true;
    8432  }
    8433  }
    8434 
    8435  // parse separator (:)
    8436  get_token();
    8437  expect(lexer::token_type::name_separator);
    8438 
    8439  // parse and add value
    8440  get_token();
    8441  auto value = parse_internal(keep);
    8442  if (keep and keep_tag and not value.is_discarded())
    8443  {
    8444  result[key] = std::move(value);
    8445  }
    8446  }
    8447  while (last_token == lexer::token_type::value_separator);
    8448 
    8449  // closing }
    8450  expect(lexer::token_type::end_object);
    8451  get_token();
    8452  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8453  {
    8454  result = basic_json(value_t::discarded);
    8455  }
    8456 
    8457  return result;
    8458  }
    8459 
    8460  case lexer::token_type::begin_array:
    8461  {
    8462  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    8463  {
    8464  // explicitly set result to object to cope with []
    8465  result.m_type = value_t::array;
    8466  result.m_value = json_value(value_t::array);
    8467  }
    8468 
    8469  // read next token
    8470  get_token();
    8471 
    8472  // closing ] -> we are done
    8473  if (last_token == lexer::token_type::end_array)
    8474  {
    8475  get_token();
    8476  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8477  {
    8478  result = basic_json(value_t::discarded);
    8479  }
    8480  return result;
    8481  }
    8482 
    8483  // no comma is expected here
    8484  unexpect(lexer::token_type::value_separator);
    8485 
    8486  // otherwise: parse values
    8487  do
    8488  {
    8489  // ugly, but could be fixed with loop reorganization
    8490  if (last_token == lexer::token_type::value_separator)
    8491  {
    8492  get_token();
    8493  }
    8494 
    8495  // parse value
    8496  auto value = parse_internal(keep);
    8497  if (keep and not value.is_discarded())
    8498  {
    8499  result.push_back(std::move(value));
    8500  }
    8501  }
    8502  while (last_token == lexer::token_type::value_separator);
    8503 
    8504  // closing ]
    8505  expect(lexer::token_type::end_array);
    8506  get_token();
    8507  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8508  {
    8509  result = basic_json(value_t::discarded);
    8510  }
    8511 
    8512  return result;
    8513  }
    8514 
    8515  case lexer::token_type::literal_null:
    8516  {
    8517  get_token();
    8518  result.m_type = value_t::null;
    8519  break;
    8520  }
    8521 
    8522  case lexer::token_type::value_string:
    8523  {
    8524  const auto s = m_lexer.get_string();
    8525  get_token();
    8526  result = basic_json(s);
    8527  break;
    8528  }
    8529 
    8530  case lexer::token_type::literal_true:
    8531  {
    8532  get_token();
    8533  result.m_type = value_t::boolean;
    8534  result.m_value = true;
    8535  break;
    8536  }
    8537 
    8538  case lexer::token_type::literal_false:
    8539  {
    8540  get_token();
    8541  result.m_type = value_t::boolean;
    8542  result.m_value = false;
    8543  break;
    8544  }
    8545 
    8546  case lexer::token_type::value_number:
    8547  {
    8548  m_lexer.get_number(result);
    8549  get_token();
    8550  break;
    8551  }
    8552 
    8553  default:
    8554  {
    8555  // the last token was unexpected
    8556  unexpect(last_token);
    8557  }
    8558  }
    8559 
    8560  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8561  {
    8562  result = basic_json(value_t::discarded);
    8563  }
    8564  return result;
    8565  }
    8566 
    8568  typename lexer::token_type get_token()
    8569  {
    8570  last_token = m_lexer.scan();
    8571  return last_token;
    8572  }
    8573 
    8574  void expect(typename lexer::token_type t) const
    8575  {
    8576  if (t != last_token)
    8577  {
    8578  std::string error_msg = "parse error - unexpected ";
    8579  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8580  lexer::token_type_name(last_token));
    8581  error_msg += "; expected " + lexer::token_type_name(t);
    8582  throw std::invalid_argument(error_msg);
    8583  }
    8584  }
    8585 
    8586  void unexpect(typename lexer::token_type t) const
    8587  {
    8588  if (t == last_token)
    8589  {
    8590  std::string error_msg = "parse error - unexpected ";
    8591  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8592  lexer::token_type_name(last_token));
    8593  throw std::invalid_argument(error_msg);
    8594  }
    8595  }
    8596 
    8597  private:
    8599  int depth = 0;
    8601  parser_callback_t callback;
    8603  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8605  lexer m_lexer;
    8606  };
    8607 };
    8608 
    8609 
    8611 // presets //
    8613 
    8623 }
    8624 
    8625 
    8627 // nonmember functions //
    8629 
    8630 // specialization of std::swap, and std::hash
    8631 namespace std
    8632 {
    8638 template <>
    8639 inline void swap(nlohmann::json& j1,
    8640  nlohmann::json& j2) noexcept(
    8641  is_nothrow_move_constructible<nlohmann::json>::value and
    8642  is_nothrow_move_assignable<nlohmann::json>::value
    8643  )
    8644 {
    8645  j1.swap(j2);
    8646 }
    8647 
    8649 template <>
    8650 struct hash<nlohmann::json>
    8651 {
    8657  std::size_t operator()(const nlohmann::json& j) const
    8658  {
    8659  // a naive hashing via the string representation
    8660  const auto& h = hash<nlohmann::json::string_t>();
    8661  return h(j.dump());
    8662  }
    8663 };
    8664 }
    8665 
    8678 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8679 {
    8680  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8681 }
    8682 
    8683 // restore GCC/clang diagnostic settings
    8684 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    8685  #pragma GCC diagnostic pop
    8686 #endif
    8687 
    8688 #endif
    bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:2169
    +
    reference operator*()
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6814
    +
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:4194
    +
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5452
    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:1076
    -
    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:3991
    +
    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:4012
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:2099
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2241
    -
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:3203
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6877
    -
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6939
    +
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:3204
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6898
    +
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6960
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:2188
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4541
    -
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6527
    -
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6933
    -
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3335
    -
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5644
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4562
    +
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6548
    +
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6954
    +
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3336
    +
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5665
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2215
    -
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6835
    +
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6856
    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:1656
    -
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6653
    +
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6674
    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:4727
    +
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4748
    bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2329
    basic_json(const typename string_t::value_type *val)
    create a string (explicit)
    Definition: json.hpp:1169
    basic_json(boolean_t val)
    create a boolean (explicit)
    Definition: json.hpp:1218
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6975
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3943
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6996
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3964
    basic_json(const number_unsigned_t val)
    create an unsigned integer number (explicit)
    Definition: json.hpp:1345
    -
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:5269
    +
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:5290
    basic_json(const string_t &val)
    create a string (explicit)
    Definition: json.hpp:1145
    -
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4653
    -
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3907
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:8601
    +
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4674
    +
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3918
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:8622
    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:2150
    -
    reference front()
    access the first element
    Definition: json.hpp:3574
    -
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:5025
    -
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:6961
    -
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6611
    +
    reference front()
    access the first element
    Definition: json.hpp:3575
    +
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:5046
    +
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:6982
    +
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6632
    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:1405
    -
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6799
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6988
    -
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:5248
    -
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4247
    +
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6820
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:7009
    +
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:5269
    +
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4268
    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:4811
    +
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4832
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:3111
    -
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6645
    -
    const_reverse_iterator rbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4181
    -
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6760
    -
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5606
    -
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6453
    +
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6666
    +
    const_reverse_iterator rbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:4202
    +
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6781
    +
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5627
    +
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6474
    bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2348
    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: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:1616
    -
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4305
    +
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4326
    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:1971
    -
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:6225
    +
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:6246
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2825
    -
    reference back()
    access the last element
    Definition: json.hpp:3612
    +
    reference back()
    access the last element
    Definition: json.hpp:3617
    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:6229
    +
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:6250
    bool is_number_unsigned() const noexcept
    return whether value is an unsigned integer number
    Definition: json.hpp:2266
    -
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4703
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:4103
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5569
    -
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3370
    -
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4864
    +
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4724
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:4124
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5590
    +
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3371
    +
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4885
    basic_json(std::nullptr_t) noexcept
    create a null object (explicitly)
    Definition: json.hpp:991
    basic_json(InputIT first, InputIT last)
    construct a JSON container given an iterator range
    Definition: json.hpp:1726
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6871
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6892
    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:3292
    -
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3452
    -
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6953
    -
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4353
    +
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3293
    +
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3453
    +
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6974
    +
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4374
    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:6981
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:7002
    basic_json(const CompatibleArrayType &val)
    create an array (implicit)
    Definition: json.hpp:1116
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:3015
    basic_json(size_type cnt, const basic_json &val)
    construct an array with count copies of given value
    Definition: json.hpp:1680
    -
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6905
    -
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4922
    -
    const_iterator(const iterator &other)
    copy constructor given a nonconst iterator
    Definition: json.hpp:6266
    +
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6926
    +
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4943
    +
    const_iterator(const iterator &other)
    copy constructor given a nonconst iterator
    Definition: json.hpp:6287
    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:4755
    -
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5475
    -
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:5330
    -
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6813
    -
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6563
    -
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6805
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4776
    +
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5496
    +
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:5351
    +
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6834
    +
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6584
    +
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6826
    basic_json(basic_json &&other) noexcept
    move constructor
    Definition: json.hpp:1939
    -
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6490
    +
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6511
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2372
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:3063
    -
    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:6781
    +
    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:6802
    object (unordered set of name/value pairs)
    -
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4482
    +
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4503
    ~basic_json()
    destructor
    Definition: json.hpp:1999
    -
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6820
    -
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6857
    -
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6498
    -
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4143
    +
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6841
    +
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6878
    +
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6519
    +
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4164
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:2068
    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:4677
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:4032
    -
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6661
    +
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4698
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:4053
    +
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6682
    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:4042
    -
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5530
    -
    difference_type operator-(const iterator &other) const
    return difference
    Definition: json.hpp:6865
    +
    const_iterator begin() const
    returns a const iterator to the first element
    Definition: json.hpp:4063
    +
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5551
    +
    difference_type operator-(const iterator &other) const
    return difference
    Definition: json.hpp:6886
    basic_json(const int val)
    create an integer number from an enum type (explicit)
    Definition: json.hpp:1280
    -
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6776
    +
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6797
    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:6227
    -
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:5059
    -
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6915
    +
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:6248
    +
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:5080
    +
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6936
    basic_json(const number_integer_t val)
    create an integer number (explicit)
    Definition: json.hpp:1251
    -
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:4210
    +
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:4231
    basic_json(const CompatibleNumberIntegerType val) noexcept
    create an integer number (implicit)
    Definition: json.hpp:1317
    -
    const_reference front() const
    access the first element
    Definition: json.hpp:3582
    -
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6599
    +
    const_reference front() const
    access the first element
    Definition: json.hpp:3583
    +
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6620
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2310
    -
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6418
    +
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6439
    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:4960
    +
    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:4981
    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:4218
    +
    const_reverse_iterator rend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4239
    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:2126
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2741
    -
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:4991
    -
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3785
    -
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3519
    -
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6907
    -
    const_reference back() const
    access the last element
    Definition: json.hpp:3622
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4617
    +
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:5012
    +
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3793
    +
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3520
    +
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6928
    +
    const_reference back() const
    access the last element
    Definition: json.hpp:3627
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4638
    array (ordered collection of values)
    -
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6926
    -
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5598
    -
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:5140
    -
    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:3545
    +
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6947
    +
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5619
    +
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:5161
    +
    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:3546
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2891
    basic_json(const CompatibleNumberUnsignedType val) noexcept
    create an unsigned number (implicit)
    Definition: json.hpp:1376
    -
    const_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:6239
    -
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6378
    +
    const_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:6260
    +
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6399
    -
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:5093
    +
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:5114
    const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2840
    -
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:5292
    -
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6849
    +
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:5313
    +
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6870
    basic_json(const CompatibleNumberFloatType val) noexcept
    create an floating-point number (implicit)
    Definition: json.hpp:1451
    -
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6593
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3679
    +
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6614
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3685
    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:1524
    -
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6771
    -
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:5301
    -
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6910
    -
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6461
    +
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6792
    +
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:5322
    +
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6931
    +
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6482
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2291
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6736
    -
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:6233
    -
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6969
    -
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:3960
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6757
    +
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:6254
    +
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6990
    +
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:3981
    basic_json(const CompatibleObjectType &val)
    create an object (implicit)
    Definition: json.hpp:1049
    -
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5453
    -
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6605
    -
    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:6298
    -
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3869
    -
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3244
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6721
    -
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4113
    -
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4643
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6685
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:6218
    +
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5474
    +
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6626
    +
    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:6319
    +
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3880
    +
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3245
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6742
    +
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:4134
    +
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4664
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6706
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:6239
    a template for a reverse iterator class
    Definition: json.hpp:212
    basic_json(std::istream &i, parser_callback_t cb=nullptr)
    construct a JSON value given an input stream
    Definition: json.hpp:1833
    -
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:6231
    -
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6920
    -
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:5239
    +
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:6252
    +
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6941
    +
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:5260
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:3158
    -
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6557
    -
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6946
    +
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6578
    +
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6967
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2971
    -
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4416
    -
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4297
    -
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:4072
    -
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6842
    -
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4276
    +
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4437
    +
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4318
    +
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:4093
    +
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6863
    +
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4297
    basic_json(const object_t &val)
    create an object (explicit)
    Definition: json.hpp:1014
    -
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5634
    -
    std::size_t operator()(const nlohmann::json &j) const
    return a hash value for a JSON object
    Definition: json.hpp:8636
    -
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5512
    -
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6293
    -
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6828
    -
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4782
    +
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5655
    +
    std::size_t operator()(const nlohmann::json &j) const
    return a hash value for a JSON object
    Definition: json.hpp:8657
    +
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5533
    +
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6314
    +
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6849
    +
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4803
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2876
    -
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6639
    +
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6660
    basic_json(const CompatibleStringType &val)
    create a string (implicit)
    Definition: json.hpp:1200
    basic_json(const basic_json &other)
    copy constructor
    Definition: json.hpp:1864
    -
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3403
    +
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3404
    parse_event_t
    JSON callback events.
    Definition: json.hpp:831
    diff --git a/mylayout.css b/mylayout.css index b4c849a32..fe20b82c5 100644 --- a/mylayout.css +++ b/mylayout.css @@ -15,4 +15,12 @@ pre.fragment { td.paramname { vertical-align: top; -} \ No newline at end of file +} + +.ok_green { + background-color: #89C35C; +} + +.nok_throws { + background-color: #ffa500; +} diff --git a/namespacemembers.html b/namespacemembers.html index 82368bb54..a71dad18f 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 9584fae03..5ca0b0d93 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 9ee57fafa..2f6ab45db 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 61ebeda48..8b4968b9f 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 17128a6ff..53402e3cf 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 8601 of file json.hpp.

    +

    Definition at line 8622 of file json.hpp.

    @@ -111,7 +111,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); 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 4fa6652df..879b1064c 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 52d2bc7d9..9d24a95c2 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 8629 of file json.hpp.

    +

    Definition at line 8650 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 a45626a57..bd7d43330 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 8636 of file json.hpp.

    +

    Definition at line 8657 of file json.hpp.

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