From c1acf1b68f0d16110877aeb5f29bb4b91a00e0ef Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 29 Jun 2016 17:03:07 +0200 Subject: [PATCH] Update --- Info.plist | 2 +- annotated.html | 4 +- classes.html | 4 +- classnlohmann_1_1basic__json-members.html | 4 +- classnlohmann_1_1basic__json.html | 4 +- ...asic__json_1_1const__iterator-members.html | 4 +- ...ann_1_1basic__json_1_1const__iterator.html | 6 +- ...tor_a0d5820d1dda9dea3bbeb029cacf68522.html | 6 +- ...tor_a18c35a6735d3da96b4fc026421c05dd8.html | 6 +- ...tor_a1da96fc3054d547e7706d3a2f073f389.html | 6 +- ...tor_a23de834b11bd895209aa65c100ab9ceb.html | 6 +- ...tor_a49d7c3e9ef3280df03052cce988b792f.html | 6 +- ...tor_a5521515067b6597cb0b55a9c547a7a2b.html | 6 +- ...tor_a5d4320e24fcb7df041ff2c95d976dba0.html | 6 +- ...tor_a5e4d98a8f95e2eccde8cd48c19efa196.html | 6 +- ...tor_a65f491b515e5967e9c0b40289e3c0ff3.html | 6 +- ...tor_a6b682f09787eff62f03493d45aa05902.html | 6 +- ...tor_a6b950c6bc081ac1ec1540ec05ceb2603.html | 6 +- ...tor_a6cab1c2ed7e2a014980e2a5717f43a64.html | 6 +- ...tor_a7a80257f2303210b0a5d056fc0b30b40.html | 6 +- ...tor_a7bd530bfbbc58ac77308c087120c21fa.html | 6 +- ...tor_a821560d64f50525162097f19b1392e7f.html | 6 +- ...tor_a8be837e4d902887676dd837abe9098d3.html | 6 +- ...tor_a8dbaec5bf8ccba3225520356629061cb.html | 6 +- ...tor_a8fbb15efd97599209a7def77af8e748e.html | 6 +- ...tor_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html | 6 +- ...tor_a9ea0497199b1e96ce9cadd1f202ec343.html | 6 +- ...tor_ab3029a1a83cf46dc28ad443bbad0c74d.html | 6 +- ...tor_ab4c0b9baaec9ebc4837158e272f6c803.html | 6 +- ...tor_abc4552ba2fe39e7901a83dd6d4dec151.html | 6 +- ...tor_ac6fdaff67857f82a623e5cc253917639.html | 4 +- ...tor_ac75e80d30b6169ee2a29ec93fb4d2acd.html | 6 +- ...tor_acb6cd0ff760933afeb7f93e5207f3646.html | 6 +- ...tor_ada3100cdb8700566051828f1355fa745.html | 6 +- ...tor_adeb2ff3fdf3cc301b72db109934c9199.html | 6 +- ...tor_aefac8f3e390ac917f021761f4a8f8e71.html | 6 +- ...tor_aefd248cac6493eed1e6ff53ba6a63eb2.html | 6 +- ...tor_af6941c3711dabb2e64960dd57e00d201.html | 6 +- ...nn_1_1basic__json_1_1iterator-members.html | 4 +- classnlohmann_1_1basic__json_1_1iterator.html | 6 +- ...tor_a050b7fa21051ea57e5b0cc03668b5d4a.html | 6 +- ...tor_a085fe0d8cf459b5b1ae7b518b933ae7d.html | 6 +- ...tor_a1de0975e812c83e74d118b3e1063f335.html | 6 +- ...tor_a2943e49b3d88e6ee5793c5923ab2ede9.html | 6 +- ...tor_a3aae1df93a78b201d98e178c1c7d02a7.html | 6 +- ...tor_a3db892729714c4e7eaf60c00ee96e2e9.html | 6 +- ...tor_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html | 4 +- ...tor_a56952f8d5702541f0d88e6a764d2ae36.html | 6 +- ...tor_a790f550ff168095c83c2e459c575916c.html | 6 +- ...tor_a7e01532727c10f87926dac4eb8e170f4.html | 6 +- ...tor_a8de46badb5b2177c85c672a71bcca017.html | 6 +- ...tor_a8ffbf287736048e683f58306fdb8701f.html | 6 +- ...tor_a97aff5d71246774267a81066460dd1cf.html | 6 +- ...tor_a9f3940ac5fb2c6ff8045ed59b8a0866f.html | 6 +- ...tor_ab3679dc63b3a59edb98b1c2b96d8683c.html | 6 +- ...tor_ab4f238aa5fcf452b1884b748b0395b1f.html | 6 +- ...tor_ac48754e4dc48d65d95294bd170dcd857.html | 6 +- ...tor_acbd82115f9232c3d3b5dacc78315b9da.html | 6 +- ...tor_ae0c848dbc0af1cde15771d45d775b27c.html | 6 +- ...tor_afe86d48d3e4e5ebdaaec162b3cf0e95c.html | 6 +- ...1basic__json_1_1json__pointer-members.html | 4 +- ...hmann_1_1basic__json_1_1json__pointer.html | 6 +- ...ter_a14fda25789660bdc3f2de652fec35f61.html | 8 +- ...ter_a344b49c70c83ff591be767072c87336e.html | 8 +- ...ter_ada3100cdb8700566051828f1355fa745.html | 6 +- ...ter_ae12db117a2742d826465080979d7c835.html | 8 +- ...on_1_1json__reverse__iterator-members.html | 4 +- ...asic__json_1_1json__reverse__iterator.html | 4 +- ...tor_a115fae3dd8ae02669fedae0545ce1cbc.html | 6 +- ...tor_a4aede52d6ee253a510897518b59e09c0.html | 6 +- ...tor_a530f042e2ab1c83dddfc344931b0375a.html | 6 +- ...tor_a545a8204cfd6836eb85abc3113a0bb28.html | 6 +- ...tor_a563a7bd281e9919798d18396107fb05c.html | 6 +- ...tor_a693439bffe56a9a8cf53bc4a06b911ff.html | 6 +- ...tor_a7265535f39299824f9712a2ca15013c3.html | 6 +- ...tor_a86c97bbb8ebe19aef4656cf796e30e99.html | 6 +- ...tor_a99ee137dab7e5c948457f6a5321b54b1.html | 6 +- ...tor_a9accc9dd9f9033f50c0ab6bcf337ffe0.html | 6 +- ...tor_a9ebc4c99e6fc90c965af0f39ad2ca70e.html | 6 +- ...tor_ac2634bee082633671125e909dffad40a.html | 6 +- ...tor_aca5116682e206dac48f8a56716a3280b.html | 6 +- ...tor_acecae6d237fcf14c909fb42b9d2e2955.html | 6 +- ...tor_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html | 6 +- ...son_a01833b332b68d9af1f7cd7a816c39e49.html | 8 +- ...son_a018ea61dbc973192d2ffc6bccc50696b.html | 8 +- ...son_a0389c5dd86adc512e5826d7ff610f776.html | 8 +- ...son_a06efb200b69942eacd1ea22d0f6ccebb.html | 4 +- ...son_a098482190447461f47f80b99bf2519f6.html | 8 +- ...son_a0a2cbbd95862a623e7dc5c37e67dead0.html | 8 +- ...son_a0ac9894c9de8dc551cf2e5f1c605537f.html | 4 +- ...son_a0d46dd5ef4992fb80f9f0d9f56f16eae.html | 8 +- ...son_a0d838bc7ffca6017f51167e0a8ffd9b6.html | 6 +- ...son_a0d96ff13001977a93d65f0a97279d316.html | 8 +- ...son_a101cd941eb8a5c299660449c71d0e75e.html | 8 +- ...son_a112a2d8e76345ea64f71e2985fee4c52.html | 6 +- ...son_a122640e7e2db1814fc7bbb3c122ec76e.html | 8 +- ...son_a12ccf14d39ddae52f6c7e126105a230b.html | 8 +- ...son_a13c4d2ab4e7ee2f92be785a7b12948ff.html | 10 +- ...son_a1407f91b4689bbc56d1a3c401a5bb649.html | 8 +- ...son_a140b8251f82e99ad279dcad5c977e26b.html | 8 +- ...son_a1579a8f72a230358d6cd1a6e8a62859b.html | 4 +- ...son_a19dfb04c297ffb5f0ef84abfa4a5a087.html | 8 +- ...son_a1a446a48beed4ea564addfd12d235793.html | 4 +- ...son_a1af360cb513cc32f28e80ddd0b9d7666.html | 8 +- ...son_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html | 8 +- ...son_a20bfb2ca6d4c421c74bb3e53328cd437.html | 8 +- ...son_a214a8c22d616fd3567b88932c07436c9.html | 10 +- ...son_a231b02148577b69a154b2ce2c87a5522.html | 4 +- ...son_a24d7df0b5b41319dbab2713d3641faf7.html | 6 +- ...son_a263a9ecde33a1f2ff63dcd15d5e42cb7.html | 8 +- ...son_a2badcf191deabf579abcf8d3654da26f.html | 6 +- ...son_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html | 8 +- ...son_a2f1f83aa187a56dc5ec7a7027065ac8a.html | 4 +- ...son_a34d6a60dd99e9f33b8273a1c8db5669b.html | 8 +- ...son_a35303ad045a06c2a79dc28ac29652e86.html | 10 +- ...son_a363da77bc39cae041d59ee334ac4f41b.html | 8 +- ...son_a3654da9a84deaf61899c4eee5b93c2c5.html | 6 +- ...son_a38ee0f09a318d003add75e0787040794.html | 8 +- ...son_a3aaf41d385f0d9a93deb92f9b14ae0cf.html | 6 +- ...son_a3da254c422ede5495f2815c5e48c00c5.html | 8 +- ...son_a3ec8e17be8732fe436e9d6733f52b7a3.html | 4 +- ...son_a43c08a393368eb674d0dcdbe301aafe3.html | 8 +- ...son_a45e789042a23138eba2b69f34df9fc45.html | 8 +- ...son_a4635e8c6d5a4599f12a76368e325acd8.html | 8 +- ...son_a486b96adbf4886c38e38c952394a220f.html | 8 +- ...son_a4ab93491f82545342562c7ee7e3166c7.html | 6 +- ...son_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html | 6 +- ...son_a4f332e90f3cae562d0c3fa6ba48f74f9.html | 8 +- ...son_a51b0036310d8aa5858fecc0d91127f27.html | 8 +- ...son_a5212588544f6d2266384c3be9bfda0c5.html | 8 +- ...son_a5327abb014dec211593b00959830650e.html | 8 +- ...son_a53771a7a4f2787125e55f64448f24ce6.html | 6 +- ...son_a558b345044c38a9f6ad522592cc700c8.html | 8 +- ...son_a5685815624b086caa532f41e853d4b0f.html | 6 +- ...son_a59732a1de287a7301cca19a7a7748159.html | 8 +- ...son_a5c8bb5200f5eac10d31e26be46e5b1ac.html | 8 +- ...son_a5e34c5435e557d0bf666bd7311211405.html | 8 +- ...son_a60a04166c122072ab11eaf9845d9cd1d.html | 4 +- ...son_a60ca396028b8d9714c6e10efbf475af6.html | 8 +- ...son_a618a5c5c9f8889032657370c8247a587.html | 12 +- ...son_a624025acfcf64364d98424402b837bc6.html | 8 +- ...son_a628733b45cd0e32bd59efea149f40b4b.html | 8 +- ...son_a62ccf5b9b3674aec2403fbc02da03db8.html | 8 +- ...son_a649aef71e5d952499da7ad3b8e7c9236.html | 8 +- ...son_a66c051561828b2c4eeaad896a72bec99.html | 8 +- ...son_a674de1ee73e6bf4843fc5dc1351fb726.html | 8 +- ...son_a685d9d6a8a45bfcb8455b147257cdffb.html | 8 +- ...son_a68a5f34b164a07b8ced13fcf2b7ec834.html | 4 +- ...son_a68f0a8c4618d57523384ec7ecd2f5819.html | 8 +- ...son_a693b411d9c5ad0d168a0013cfb80b8e5.html | 8 +- ...son_a6e2e21da48f5d9471716cd868a068327.html | 8 +- ...son_a6f3dfd3e83a1e907d7946b47fcd7ceba.html | 8 +- ...son_a70ae1f0747f5b7a89979512866474f1a.html | 6 +- ...son_a71b1d38ef402dfee58fba1fe01fa67f5.html | 8 +- ...son_a73e150cbcba5643cb89de8f515eb64e2.html | 6 +- ...son_a74a0013e847fdc574b48f931f0e757e1.html | 4 +- ...son_a74a943800c7f103d0990d7eef82c6453.html | 8 +- ...son_a7605b20debcc12fc44bd9f2075122a87.html | 8 +- ...son_a76347b37f07c75049f5164053a6cf81a.html | 8 +- ...son_a7ab11375ed2e29c2fcb6119386851445.html | 8 +- ...son_a7c3182cfabc0bdd9f3a14216fe0e8154.html | 6 +- ...son_a7c774ef0eceff6d06095f617e2dbd488.html | 8 +- ...son_a7ed92d56cb313b243c1917696ffdf074.html | 8 +- ...son_a7f7bbb3a9efef2e2442f538a24c1c47b.html | 8 +- ...son_a7f97a91ad8f1d5cf0b9213bd24f247c4.html | 8 +- ...son_a8032645ce3109a7a4899badd90fa3480.html | 8 +- ...son_a805e3f3a2f374da0e14942eec7400e40.html | 6 +- ...son_a80c21170db6b5ffd9274b3f351cebadc.html | 8 +- ...son_a81aaaab0f3b326afda2d226daab4f1e1.html | 6 +- ...son_a8209621de6184d9eabe136b7c8f61935.html | 8 +- ...son_a8468efcfcd95db15f46887b29924ed5c.html | 8 +- ...son_a848cbae3bd3502ffbf738320bf5eb3aa.html | 8 +- ...son_a85b09b03916d3d1e73373f49cdd4136d.html | 4 +- ...son_a86089c703a2e563b9f760c2f8408efa7.html | 8 +- ...son_a86a477c16dac3bdd4929fee2db394256.html | 8 +- ...son_a87499fdb56ca6f0df2242c3335c3dc9b.html | 8 +- ...son_a87db51b6b936fb2ea293cdbc8702dcb8.html | 8 +- ...son_a8f77085bd98c97a983d9ba12efbf6148.html | 6 +- ...son_a8f7e67d903f918cd08261219fb47a9f0.html | 8 +- ...son_a90239431815c94b0a334f7f4c55eb859.html | 8 +- ...son_a92fbb711a36b5ce78ee228b26787c034.html | 8 +- ...son_a947b5b2a832e490858dbdddfe7085831.html | 4 +- ...son_a9486a272e034c0548305d7a12f3045e6.html | 8 +- ...son_a9730b9f7bc2150e641fe20198d4477c7.html | 8 +- ...son_a9857835334d38ba04959e348ca6be208.html | 6 +- ...son_a98e05a2c9b8f74bd60442772cddeee52.html | 8 +- ...son_a99f2e765029e51dd0fff018650f92eea.html | 8 +- ...son_a9af5ea68c88f423ddf35216aff7f1813.html | 6 +- ...son_a9c9b4932b26a9630e1a3f25ea42a2c43.html | 8 +- ...son_a9d1b58099dc64695fcf2847ab0b2a7c7.html | 4 +- ...son_a9e35475e2027520a78e09f460dbe048a.html | 4 +- ...son_aa0033766b4d3134b9bb57d81762d75a2.html | 8 +- ...son_aa36e72ffc3241b960fe9186d19e03bc3.html | 8 +- ...son_aa41e1083435cf317a253947eb1ff318d.html | 8 +- ...son_aa44ce84b9ac506b905b8fb56c9a0989d.html | 4 +- ...son_aa45753034bea87f9d2c0c42ace9ff75c.html | 8 +- ...son_aa669d997ddc03566de5438781254b32b.html | 8 +- ...son_aa6fd72df1ce9f80e61012784c598456e.html | 8 +- ...son_aa7205e1926d3aea98adeced91b0ff5fb.html | 8 +- ...son_aaa160a960dd3dd90856a72b1d8dbe707.html | 8 +- ...son_aaa687595d7627925fbf6d6eb97e2021e.html | 8 +- ...son_aac36af84d907b5c3e469af889661620a.html | 6 +- ...son_aacd442b66140c764c594ac8ad7dfd5b3.html | 8 +- ...son_aad65e0bc388897192bf361c24c1d6dda.html | 8 +- ...son_aadb4e5be88221e5e28cdb752332f3d13.html | 8 +- ...son_aae7eb3b91d7f68e86396c5c6b683445f.html | 8 +- ...son_aaf363408931d76472ded14017e59c9e8.html | 8 +- ...son_ab00b882d39306d663c23dab110f5cae0.html | 4 +- ...son_ab22c8d61eca51f0308c263487bd35f03.html | 8 +- ...son_ab31368c0b67f8e4f291a45e6498018be.html | 8 +- ...son_ab63e618bbb0371042b1bec17f5891f42.html | 4 +- ...son_ab7be2bc58ae0c2c2c30d40f15d6399f8.html | 6 +- ...son_ab81f2801779e6cb9d98770860af2e39a.html | 10 +- ...son_ab8b43d92a042dde96c28aeea81dd52de.html | 6 +- ...son_ab936779c70bec68343ef440ed13251e5.html | 6 +- ...son_ac4b10b2364f26ce47bdb9a413ff04a59.html | 4 +- ...son_ac5693cff1df0775cd3fbe960412cde4b.html | 8 +- ...son_ac7c006e2345a76859c4802db7d130e0e.html | 8 +- ...son_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html | 4 +- ...son_ad25b2f8c21e241e2d63455537a9294ff.html | 6 +- ...son_ad2eddc2c13ab084f067eaba65d381ad2.html | 6 +- ...son_ad4e381c54039607be08d7af41a1f6ad1.html | 8 +- ...son_ad5514a7435f246fc5335856465022a7a.html | 8 +- ...son_ad6e51670e9c0052856f3fee01df5c44f.html | 8 +- ...son_ad9cd312208273fb3fb2adf1f6d8d34ae.html | 8 +- ...son_ade0e56c8c320d7f342e7a5697e6d6f7e.html | 6 +- ...son_ae336fff01f4b78e3e16e5008dc8dbc00.html | 4 +- ...son_ae347859ec88176ef76a0cbe5b4514fcf.html | 8 +- ...son_ae85d91b0620650bcd9993e09d0e287d9.html | 6 +- ...son_aea1c863b719b4ca5b77188c171bbfafe.html | 4 +- ...son_aeaa0644fd6b99af364e772092268dfd6.html | 8 +- ...son_aec316934a555dd1acdd3600e5d4a4cdf.html | 4 +- ...son_aef496a56163710084e13612ab73e6ed2.html | 8 +- ...son_af071057ebab57744f5767eb369e99d42.html | 8 +- ...son_af148cdab12df5bf86119fac735ccaac5.html | 6 +- ...son_af3bc3e83aa162d7ba4df16a949872723.html | 4 +- ...son_af677a29b0e66edc9f66e5167e4667071.html | 4 +- ...son_af77614992e38b355b9213940051cc582.html | 8 +- ...son_af7acf3838a79363356f24538941a559c.html | 6 +- ...son_afeb998aec45296bc2050bd1c41ef41eb.html | 6 +- ...son_affe7e160e7bb06eed83c8b437af4692f.html | 8 +- dir_68267d1309a1af8e8297ef4c3efbcdba.html | 4 +- functions.html | 4 +- functions_0x7e.html | 4 +- functions_b.html | 4 +- functions_c.html | 4 +- functions_d.html | 4 +- functions_e.html | 4 +- functions_enum.html | 4 +- functions_f.html | 4 +- functions_func.html | 4 +- functions_g.html | 4 +- functions_i.html | 4 +- functions_j.html | 4 +- functions_k.html | 4 +- functions_m.html | 4 +- functions_n.html | 4 +- functions_o.html | 4 +- functions_p.html | 4 +- functions_r.html | 4 +- functions_rela.html | 4 +- functions_s.html | 4 +- functions_t.html | 4 +- functions_type.html | 4 +- functions_u.html | 4 +- functions_v.html | 4 +- graph_legend.html | 4 +- hierarchy.html | 4 +- index.html | 4 +- index_8md_source.html | 4 +- json_8hpp_source.html | 324 +++++++++--------- namespacemembers.html | 4 +- namespacemembers_type.html | 4 +- namespacenlohmann.html | 4 +- ..._1anonymous__namespace_02json_8hpp_03.html | 4 +- ...ann_a2bfd99e845a2e5cd90aeaf1b1431f474.html | 6 +- ...ash_3_01nlohmann_1_1json_01_4-members.html | 4 +- ...std_1_1hash_3_01nlohmann_1_1json_01_4.html | 6 +- ...1_4_afd03f6ad53db22868ca4163a8200b2f9.html | 6 +- 279 files changed, 1039 insertions(+), 1039 deletions(-) diff --git a/Info.plist b/Info.plist index d6d543bc9..6f3b85366 100644 --- a/Info.plist +++ b/Info.plist @@ -8,7 +8,7 @@ CFBundleIdentifier me.nlohmann.json CFBundleVersion - 2.0.0 + 2.0.1 DocSetFeedName Doxygen generated docs DocSetPublisherIdentifier diff --git a/annotated.html b/annotated.html index 60ad083c2..91c5076b8 100644 --- a/annotated.html +++ b/annotated.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classes.html b/classes.html index e04e6f4b4..1b287640e 100644 --- a/classes.html +++ b/classes.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -106,7 +106,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 d1eefc9cb..ab04d1a79 100644 --- a/classnlohmann_1_1basic__json-members.html +++ b/classnlohmann_1_1basic__json-members.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -255,7 +255,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json.html b/classnlohmann_1_1basic__json.html index 7524be86b..00da73244 100644 --- a/classnlohmann_1_1basic__json.html +++ b/classnlohmann_1_1basic__json.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -740,7 +740,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 0282ddfdc..95d523855 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator-members.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1const__iterator.html b/classnlohmann_1_1basic__json_1_1const__iterator.html index 3ff839c7b..cd4e812f3 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -215,11 +215,11 @@ class nlohmann::basic_json::const_iterator
Since
version 1.0.0
-

Definition at line 6359 of file json.hpp.

+

Definition at line 6363 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 bfadbecff..324423bd2 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a0d5820d1dda9dea3bbeb029cacf68522.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a0d5820d1dda9dea3bbeb029cacf68522.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6754 of file json.hpp.

+

Definition at line 6758 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 b8b275235..1864a908e 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a18c35a6735d3da96b4fc026421c05dd8.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a18c35a6735d3da96b4fc026421c05dd8.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6436 of file json.hpp.

+

Definition at line 6440 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html b/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html index b2fede053..0d583fafb 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a1da96fc3054d547e7706d3a2f073f389.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6370 of file json.hpp.

+

Definition at line 6374 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_a23de834b11bd895209aa65c100ab9ceb.html b/classnlohmann_1_1basic__json_1_1const__iterator_a23de834b11bd895209aa65c100ab9ceb.html index 71100a254..a1a02911b 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a23de834b11bd895209aa65c100ab9ceb.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a23de834b11bd895209aa65c100ab9ceb.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6380 of file json.hpp.

+

Definition at line 6384 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_a49d7c3e9ef3280df03052cce988b792f.html b/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html index c548e4e28..34fa125b3 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a49d7c3e9ef3280df03052cce988b792f.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6368 of file json.hpp.

+

Definition at line 6372 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 fd01a429e..3ad6abc1e 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5521515067b6597cb0b55a9c547a7a2b.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5521515067b6597cb0b55a9c547a7a2b.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6441 of file json.hpp.

+

Definition at line 6445 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 7278b27ed..8000a5377 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5d4320e24fcb7df041ff2c95d976dba0.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5d4320e24fcb7df041ff2c95d976dba0.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6864 of file json.hpp.

+

Definition at line 6868 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 80c09d3a1..494bcd125 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5e4d98a8f95e2eccde8cd48c19efa196.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5e4d98a8f95e2eccde8cd48c19efa196.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6804 of file json.hpp.

+

Definition at line 6808 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 8c86cebf7..e13984950 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a65f491b515e5967e9c0b40289e3c0ff3.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a65f491b515e5967e9c0b40289e3c0ff3.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6706 of file json.hpp.

+

Definition at line 6710 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 b9ac2db2d..a906974e0 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a6b682f09787eff62f03493d45aa05902.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a6b682f09787eff62f03493d45aa05902.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6736 of file json.hpp.

+

Definition at line 6740 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_a6b950c6bc081ac1ec1540ec05ceb2603.html b/classnlohmann_1_1basic__json_1_1const__iterator_a6b950c6bc081ac1ec1540ec05ceb2603.html index 9c53630f3..d9a4af5ac 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a6b950c6bc081ac1ec1540ec05ceb2603.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a6b950c6bc081ac1ec1540ec05ceb2603.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6408 of file json.hpp.

+

Definition at line 6412 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 5d9b293bb..51d9c45a9 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a6cab1c2ed7e2a014980e2a5717f43a64.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a6cab1c2ed7e2a014980e2a5717f43a64.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6633 of file json.hpp.

+

Definition at line 6637 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 722df0f99..3dea27dae 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a7a80257f2303210b0a5d056fc0b30b40.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a7a80257f2303210b0a5d056fc0b30b40.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6788 of file json.hpp.

+

Definition at line 6792 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 d6ef1dbf8..a342eb4fe 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a7bd530bfbbc58ac77308c087120c21fa.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a7bd530bfbbc58ac77308c087120c21fa.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6828 of file json.hpp.

+

Definition at line 6832 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 8c23b47bf..fa3508908 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a821560d64f50525162097f19b1392e7f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a821560d64f50525162097f19b1392e7f.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6374 of file json.hpp.

+

Definition at line 6378 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 71f868ef0..cd11152c7 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8be837e4d902887676dd837abe9098d3.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8be837e4d902887676dd837abe9098d3.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6561 of file json.hpp.

+

Definition at line 6565 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 d6f40d975..0ed80eda0 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8dbaec5bf8ccba3225520356629061cb.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8dbaec5bf8ccba3225520356629061cb.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6596 of file json.hpp.

+

Definition at line 6600 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 8087966da..086f6c9d8 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8fbb15efd97599209a7def77af8e748e.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8fbb15efd97599209a7def77af8e748e.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6604 of file json.hpp.

+

Definition at line 6608 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 bff69ee5f..d73b6c96e 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a9e4c6e48e3c2f3ff357ef8215b8c8fca.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6700 of file json.hpp.

+

Definition at line 6704 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 47b3aa55e..d00be2dcb 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a9ea0497199b1e96ce9cadd1f202ec343.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a9ea0497199b1e96ce9cadd1f202ec343.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6366 of file json.hpp.

+

Definition at line 6370 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 0a62f4038..bf6e781c5 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab3029a1a83cf46dc28ad443bbad0c74d.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab3029a1a83cf46dc28ad443bbad0c74d.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6521 of file json.hpp.

+

Definition at line 6525 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 1dbc09c10..567214eff 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab4c0b9baaec9ebc4837158e272f6c803.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab4c0b9baaec9ebc4837158e272f6c803.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6670 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_abc4552ba2fe39e7901a83dd6d4dec151.html b/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html index 2f9f493f6..8db7cbfe4 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_abc4552ba2fe39e7901a83dd6d4dec151.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6796 of file json.hpp.

+

Definition at line 6800 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 77e774996..41d709746 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac6fdaff67857f82a623e5cc253917639.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac6fdaff67857f82a623e5cc253917639.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -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 768c9d86f..135c976c5 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac75e80d30b6169ee2a29ec93fb4d2acd.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac75e80d30b6169ee2a29ec93fb4d2acd.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6879 of file json.hpp.

+

Definition at line 6883 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 11c632a42..5b0f22e34 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_acb6cd0ff760933afeb7f93e5207f3646.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_acb6cd0ff760933afeb7f93e5207f3646.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6742 of file json.hpp.

+

Definition at line 6746 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 b6bb39ee3..d1f8581a7 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -139,7 +139,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6362 of file json.hpp.

+

Definition at line 6366 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 e8f0f3760..0f20fd902 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_adeb2ff3fdf3cc301b72db109934c9199.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_adeb2ff3fdf3cc301b72db109934c9199.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6641 of file json.hpp.

+

Definition at line 6645 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 ec33c924f..1af035e4c 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_aefac8f3e390ac917f021761f4a8f8e71.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_aefac8f3e390ac917f021761f4a8f8e71.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6782 of file json.hpp.

+

Definition at line 6786 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 baac9aaeb..02c6199ea 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_aefd248cac6493eed1e6ff53ba6a63eb2.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_aefd248cac6493eed1e6ff53ba6a63eb2.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6372 of file json.hpp.

+

Definition at line 6376 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 38756eb0e..ee08a01cf 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_af6941c3711dabb2e64960dd57e00d201.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_af6941c3711dabb2e64960dd57e00d201.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6748 of file json.hpp.

+

Definition at line 6752 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 197e528ab..35f0c6234 100644 --- a/classnlohmann_1_1basic__json_1_1iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1iterator-members.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -133,7 +133,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 3d2a672f0..8892e065e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator.html +++ b/classnlohmann_1_1basic__json_1_1iterator.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -267,11 +267,11 @@ class nlohmann::basic_json::iterator
Since
version 1.0.0
-

Definition at line 6903 of file json.hpp.

+

Definition at line 6907 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 4acd13f21..e77807bc5 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a050b7fa21051ea57e5b0cc03668b5d4a.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a050b7fa21051ea57e5b0cc03668b5d4a.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6956 of file json.hpp.

+

Definition at line 6960 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 f16d33dd8..0a29b480d 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a085fe0d8cf459b5b1ae7b518b933ae7d.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a085fe0d8cf459b5b1ae7b518b933ae7d.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6914 of file json.hpp.

+

Definition at line 6918 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 4ff06c0cb..5415f0691 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a1de0975e812c83e74d118b3e1063f335.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a1de0975e812c83e74d118b3e1063f335.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6919 of file json.hpp.

+

Definition at line 6923 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 a38b15321..fa8d0bdd6 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a2943e49b3d88e6ee5793c5923ab2ede9.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a2943e49b3d88e6ee5793c5923ab2ede9.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6948 of file json.hpp.

+

Definition at line 6952 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 cbea9e3cf..bc3030217 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a3aae1df93a78b201d98e178c1c7d02a7.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a3aae1df93a78b201d98e178c1c7d02a7.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6907 of file json.hpp.

+

Definition at line 6911 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 53c95d21f..9a6f5c784 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a3db892729714c4e7eaf60c00ee96e2e9.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a3db892729714c4e7eaf60c00ee96e2e9.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6924 of file json.hpp.

+

Definition at line 6928 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 74cb75ebc..2d9a437ed 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a47fb2dbbbfaf65c0ccfa99aeaed920a1.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -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 f4c941236..12b1060ad 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a56952f8d5702541f0d88e6a764d2ae36.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a56952f8d5702541f0d88e6a764d2ae36.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6992 of file json.hpp.

+

Definition at line 6996 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 663b79972..5f9d80ff0 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a790f550ff168095c83c2e459c575916c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a790f550ff168095c83c2e459c575916c.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 7000 of file json.hpp.

+

Definition at line 7004 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 4d2dcbe74..5b3f4b286 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a7e01532727c10f87926dac4eb8e170f4.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a7e01532727c10f87926dac4eb8e170f4.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 7014 of file json.hpp.

+

Definition at line 7018 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_a8de46badb5b2177c85c672a71bcca017.html b/classnlohmann_1_1basic__json_1_1iterator_a8de46badb5b2177c85c672a71bcca017.html index 2c4ea88af..fb562988e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a8de46badb5b2177c85c672a71bcca017.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a8de46badb5b2177c85c672a71bcca017.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6942 of file json.hpp.

+

Definition at line 6946 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_a8ffbf287736048e683f58306fdb8701f.html b/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html index 1856edf60..8660c3640 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a8ffbf287736048e683f58306fdb8701f.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 7020 of file json.hpp.

+

Definition at line 7024 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 6093d1291..a9ef09f04 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a97aff5d71246774267a81066460dd1cf.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a97aff5d71246774267a81066460dd1cf.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6908 of file json.hpp.

+

Definition at line 6912 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 749ac2541..750bcbe6e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a9f3940ac5fb2c6ff8045ed59b8a0866f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a9f3940ac5fb2c6ff8045ed59b8a0866f.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 7008 of file json.hpp.

+

Definition at line 7012 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_ab3679dc63b3a59edb98b1c2b96d8683c.html b/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html index eb4823cc3..090edf3b7 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab3679dc63b3a59edb98b1c2b96d8683c.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6971 of file json.hpp.

+

Definition at line 6975 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 b8fc90318..3dfffa26b 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab4f238aa5fcf452b1884b748b0395b1f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab4f238aa5fcf452b1884b748b0395b1f.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6963 of file json.hpp.

+

Definition at line 6967 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 26d5ffcaf..53e8a6c30 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ac48754e4dc48d65d95294bd170dcd857.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ac48754e4dc48d65d95294bd170dcd857.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6906 of file json.hpp.

+

Definition at line 6910 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_acbd82115f9232c3d3b5dacc78315b9da.html b/classnlohmann_1_1basic__json_1_1iterator_acbd82115f9232c3d3b5dacc78315b9da.html index fbc251af4..0c3ebe17b 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_acbd82115f9232c3d3b5dacc78315b9da.html +++ b/classnlohmann_1_1basic__json_1_1iterator_acbd82115f9232c3d3b5dacc78315b9da.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6936 of file json.hpp.

+

Definition at line 6940 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_ae0c848dbc0af1cde15771d45d775b27c.html b/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html index babbee6c1..94a6c48c9 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ae0c848dbc0af1cde15771d45d775b27c.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6978 of file json.hpp.

+

Definition at line 6982 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_afe86d48d3e4e5ebdaaec162b3cf0e95c.html b/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html index 3809229a7..0d6afe95e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html +++ b/classnlohmann_1_1basic__json_1_1iterator_afe86d48d3e4e5ebdaaec162b3cf0e95c.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6985 of file json.hpp.

+

Definition at line 6989 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__pointer-members.html b/classnlohmann_1_1basic__json_1_1json__pointer-members.html index ee66ae487..0a4334cd7 100644 --- a/classnlohmann_1_1basic__json_1_1json__pointer-members.html +++ b/classnlohmann_1_1basic__json_1_1json__pointer-members.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1json__pointer.html b/classnlohmann_1_1basic__json_1_1json__pointer.html index 891025cb5..3edd7e761 100644 --- a/classnlohmann_1_1basic__json_1_1json__pointer.html +++ b/classnlohmann_1_1basic__json_1_1json__pointer.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -127,11 +127,11 @@ class nlohmann::basic_json::json_pointer
See also
RFC 6901
Since
version 2.0.0
-

Definition at line 8728 of file json.hpp.

+

Definition at line 8732 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1json__pointer_a14fda25789660bdc3f2de652fec35f61.html b/classnlohmann_1_1basic__json_1_1json__pointer_a14fda25789660bdc3f2de652fec35f61.html index d8621e595..510821924 100644 --- a/classnlohmann_1_1basic__json_1_1json__pointer_a14fda25789660bdc3f2de652fec35f61.html +++ b/classnlohmann_1_1basic__json_1_1json__pointer_a14fda25789660bdc3f2de652fec35f61.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -116,7 +116,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Invariant
For each JSON pointer ptr, it holds:
ptr == json_pointer(ptr.to_string());
Returns
a string representation of the JSON pointer
-
Example
The example shows the result of to_string.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // different JSON Pointers
8  json::json_pointer ptr1("");
9  json::json_pointer ptr2("/foo");
10  json::json_pointer ptr3("/foo/0");
11  json::json_pointer ptr4("/");
12  json::json_pointer ptr5("/a~1b");
13  json::json_pointer ptr6("/c%d");
14  json::json_pointer ptr7("/e^f");
15  json::json_pointer ptr8("/g|h");
16  json::json_pointer ptr9("/i\\j");
17  json::json_pointer ptr10("/k\"l");
18  json::json_pointer ptr11("/ ");
19  json::json_pointer ptr12("/m~0n");
20 
21 
22  std::cout << ptr1.to_string() << '\n'
23  << ptr2.to_string() << '\n'
24  << ptr3.to_string() << '\n'
25  << ptr4.to_string() << '\n'
26  << ptr5.to_string() << '\n'
27  << ptr6.to_string() << '\n'
28  << ptr7.to_string() << '\n'
29  << ptr8.to_string() << '\n'
30  << ptr9.to_string() << '\n'
31  << ptr10.to_string() << '\n'
32  << ptr11.to_string() << '\n'
33  << ptr12.to_string() << std::endl;
34 }
basic_json<> json
default JSON class
Definition: json.hpp:9960
+
Example
The example shows the result of to_string.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // different JSON Pointers
8  json::json_pointer ptr1("");
9  json::json_pointer ptr2("/foo");
10  json::json_pointer ptr3("/foo/0");
11  json::json_pointer ptr4("/");
12  json::json_pointer ptr5("/a~1b");
13  json::json_pointer ptr6("/c%d");
14  json::json_pointer ptr7("/e^f");
15  json::json_pointer ptr8("/g|h");
16  json::json_pointer ptr9("/i\\j");
17  json::json_pointer ptr10("/k\"l");
18  json::json_pointer ptr11("/ ");
19  json::json_pointer ptr12("/m~0n");
20 
21 
22  std::cout << ptr1.to_string() << '\n'
23  << ptr2.to_string() << '\n'
24  << ptr3.to_string() << '\n'
25  << ptr4.to_string() << '\n'
26  << ptr5.to_string() << '\n'
27  << ptr6.to_string() << '\n'
28  << ptr7.to_string() << '\n'
29  << ptr8.to_string() << '\n'
30  << ptr9.to_string() << '\n'
31  << ptr10.to_string() << '\n'
32  << ptr11.to_string() << '\n'
33  << ptr12.to_string() << std::endl;
34 }
basic_json<> json
default JSON class
Definition: json.hpp:9964
Output (play with this example online):
 /foo
 /foo/0
@@ -134,7 +134,7 @@ json_pointer__to_string.cpp -o
 json_pointer__to_string 
Since
version 2.0.0
-

Definition at line 8779 of file json.hpp.

+

Definition at line 8783 of file json.hpp.

@@ -144,7 +144,7 @@ json_pointer__to_string diff --git a/classnlohmann_1_1basic__json_1_1json__pointer_a344b49c70c83ff591be767072c87336e.html b/classnlohmann_1_1basic__json_1_1json__pointer_a344b49c70c83ff591be767072c87336e.html index 4e8c13b58..34d282a31 100644 --- a/classnlohmann_1_1basic__json_1_1json__pointer_a344b49c70c83ff591be767072c87336e.html +++ b/classnlohmann_1_1basic__json_1_1json__pointer_a344b49c70c83ff591be767072c87336e.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -116,7 +116,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Invariant
For each JSON pointer ptr, it holds:
ptr == json_pointer(ptr.to_string());
Returns
a string representation of the JSON pointer
-
Example
The example shows the result of to_string.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // different JSON Pointers
8  json::json_pointer ptr1("");
9  json::json_pointer ptr2("/foo");
10  json::json_pointer ptr3("/foo/0");
11  json::json_pointer ptr4("/");
12  json::json_pointer ptr5("/a~1b");
13  json::json_pointer ptr6("/c%d");
14  json::json_pointer ptr7("/e^f");
15  json::json_pointer ptr8("/g|h");
16  json::json_pointer ptr9("/i\\j");
17  json::json_pointer ptr10("/k\"l");
18  json::json_pointer ptr11("/ ");
19  json::json_pointer ptr12("/m~0n");
20 
21 
22  std::cout << ptr1.to_string() << '\n'
23  << ptr2.to_string() << '\n'
24  << ptr3.to_string() << '\n'
25  << ptr4.to_string() << '\n'
26  << ptr5.to_string() << '\n'
27  << ptr6.to_string() << '\n'
28  << ptr7.to_string() << '\n'
29  << ptr8.to_string() << '\n'
30  << ptr9.to_string() << '\n'
31  << ptr10.to_string() << '\n'
32  << ptr11.to_string() << '\n'
33  << ptr12.to_string() << std::endl;
34 }
basic_json<> json
default JSON class
Definition: json.hpp:9960
+
Example
The example shows the result of to_string.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // different JSON Pointers
8  json::json_pointer ptr1("");
9  json::json_pointer ptr2("/foo");
10  json::json_pointer ptr3("/foo/0");
11  json::json_pointer ptr4("/");
12  json::json_pointer ptr5("/a~1b");
13  json::json_pointer ptr6("/c%d");
14  json::json_pointer ptr7("/e^f");
15  json::json_pointer ptr8("/g|h");
16  json::json_pointer ptr9("/i\\j");
17  json::json_pointer ptr10("/k\"l");
18  json::json_pointer ptr11("/ ");
19  json::json_pointer ptr12("/m~0n");
20 
21 
22  std::cout << ptr1.to_string() << '\n'
23  << ptr2.to_string() << '\n'
24  << ptr3.to_string() << '\n'
25  << ptr4.to_string() << '\n'
26  << ptr5.to_string() << '\n'
27  << ptr6.to_string() << '\n'
28  << ptr7.to_string() << '\n'
29  << ptr8.to_string() << '\n'
30  << ptr9.to_string() << '\n'
31  << ptr10.to_string() << '\n'
32  << ptr11.to_string() << '\n'
33  << ptr12.to_string() << std::endl;
34 }
basic_json<> json
default JSON class
Definition: json.hpp:9964
Output (play with this example online):
 /foo
 /foo/0
@@ -134,7 +134,7 @@ json_pointer__to_string.cpp -o
 json_pointer__to_string 
Since
version 2.0.0
-

Definition at line 8792 of file json.hpp.

+

Definition at line 8796 of file json.hpp.

@@ -144,7 +144,7 @@ json_pointer__to_string diff --git a/classnlohmann_1_1basic__json_1_1json__pointer_ada3100cdb8700566051828f1355fa745.html b/classnlohmann_1_1basic__json_1_1json__pointer_ada3100cdb8700566051828f1355fa745.html index 4b1a5f20a..5ab2b2a51 100644 --- a/classnlohmann_1_1basic__json_1_1json__pointer_ada3100cdb8700566051828f1355fa745.html +++ b/classnlohmann_1_1basic__json_1_1json__pointer_ada3100cdb8700566051828f1355fa745.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -112,7 +112,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 8731 of file json.hpp.

+

Definition at line 8735 of file json.hpp.

@@ -122,7 +122,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1json__pointer_ae12db117a2742d826465080979d7c835.html b/classnlohmann_1_1basic__json_1_1json__pointer_ae12db117a2742d826465080979d7c835.html index 3549aff7d..1586568ec 100644 --- a/classnlohmann_1_1basic__json_1_1json__pointer_ae12db117a2742d826465080979d7c835.html +++ b/classnlohmann_1_1basic__json_1_1json__pointer_ae12db117a2742d826465080979d7c835.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -131,14 +131,14 @@ begin with /" -
Example
The example shows the construction several valid JSON pointers as well as the exceptional behavior.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // correct JSON pointers
8  json::json_pointer p1;
9  json::json_pointer p2("");
10  json::json_pointer p3("/");
11  json::json_pointer p4("//");
12  json::json_pointer p5("/foo/bar");
13  json::json_pointer p6("/foo/bar/-");
14  json::json_pointer p7("/foo/~0");
15  json::json_pointer p8("/foo/~1");
16 
17  // error: JSON pointer does not begin with a slash
18  try
19  {
20  json::json_pointer p9("foo");
21  }
22  catch (std::domain_error& e)
23  {
24  std::cout << "domain_error: " << e.what() << '\n';
25  }
26 
27  // error: JSON pointer uses escape symbol ~ not followed by 0 or 1
28  try
29  {
30  json::json_pointer p10("/foo/~");
31  }
32  catch (std::domain_error& e)
33  {
34  std::cout << "domain_error: " << e.what() << '\n';
35  }
36 
37  // error: JSON pointer uses escape symbol ~ not followed by 0 or 1
38  try
39  {
40  json::json_pointer p11("/foo/~3");
41  }
42  catch (std::domain_error& e)
43  {
44  std::cout << "domain_error: " << e.what() << '\n';
45  }
46 }
basic_json<> json
default JSON class
Definition: json.hpp:9960
+
Example
The example shows the construction several valid JSON pointers as well as the exceptional behavior.
1 #include <json.hpp>
2 
3 using json = nlohmann::json;
4 
5 int main()
6 {
7  // correct JSON pointers
8  json::json_pointer p1;
9  json::json_pointer p2("");
10  json::json_pointer p3("/");
11  json::json_pointer p4("//");
12  json::json_pointer p5("/foo/bar");
13  json::json_pointer p6("/foo/bar/-");
14  json::json_pointer p7("/foo/~0");
15  json::json_pointer p8("/foo/~1");
16 
17  // error: JSON pointer does not begin with a slash
18  try
19  {
20  json::json_pointer p9("foo");
21  }
22  catch (std::domain_error& e)
23  {
24  std::cout << "domain_error: " << e.what() << '\n';
25  }
26 
27  // error: JSON pointer uses escape symbol ~ not followed by 0 or 1
28  try
29  {
30  json::json_pointer p10("/foo/~");
31  }
32  catch (std::domain_error& e)
33  {
34  std::cout << "domain_error: " << e.what() << '\n';
35  }
36 
37  // error: JSON pointer uses escape symbol ~ not followed by 0 or 1
38  try
39  {
40  json::json_pointer p11("/foo/~3");
41  }
42  catch (std::domain_error& e)
43  {
44  std::cout << "domain_error: " << e.what() << '\n';
45  }
46 }
basic_json<> json
default JSON class
Definition: json.hpp:9964
Output (play with this example online):
domain_error: JSON pointer must be empty or begin with '/'
 domain_error: escape error: '~' must be followed with '0' or '1'
 domain_error: escape error: '~' must be followed with '0' or '1'
 
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/json_pointer.cpp -o json_pointer 
Since
version 2.0.0
-

Definition at line 8756 of file json.hpp.

+

Definition at line 8760 of file json.hpp.

@@ -148,7 +148,7 @@ domain_error: escape error: '~' must be followed with '0' or '1' 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 a56ec809f..fa4d2da72 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -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 5d0372e58..e95b01163 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -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 fc0079a90..7897f00b1 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a115fae3dd8ae02669fedae0545ce1cbc.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a115fae3dd8ae02669fedae0545ce1cbc.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7112 of file json.hpp.

+

Definition at line 7116 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 f91ec2777..03a376e3c 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a4aede52d6ee253a510897518b59e09c0.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a4aede52d6ee253a510897518b59e09c0.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 7069 of file json.hpp.

+

Definition at line 7073 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a530f042e2ab1c83dddfc344931b0375a.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a530f042e2ab1c83dddfc344931b0375a.html index 1deb34290..dce0572c2 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a530f042e2ab1c83dddfc344931b0375a.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a530f042e2ab1c83dddfc344931b0375a.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7058 of file json.hpp.

+

Definition at line 7062 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 e16b45725..bf18863c1 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a545a8204cfd6836eb85abc3113a0bb28.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a545a8204cfd6836eb85abc3113a0bb28.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7063 of file json.hpp.

+

Definition at line 7067 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 32fa58a14..1454153be 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a563a7bd281e9919798d18396107fb05c.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a563a7bd281e9919798d18396107fb05c.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 7082 of file json.hpp.

+

Definition at line 7086 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 cb71948d0..96f2fb69c 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a693439bffe56a9a8cf53bc4a06b911ff.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a693439bffe56a9a8cf53bc4a06b911ff.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7076 of file json.hpp.

+

Definition at line 7080 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 60d456075..361523814 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7265535f39299824f9712a2ca15013c3.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a7265535f39299824f9712a2ca15013c3.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -117,7 +117,7 @@ template<typename Base >
-

Definition at line 7050 of file json.hpp.

+

Definition at line 7054 of file json.hpp.

@@ -127,7 +127,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a86c97bbb8ebe19aef4656cf796e30e99.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a86c97bbb8ebe19aef4656cf796e30e99.html index 010260c65..c042a7f96 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a86c97bbb8ebe19aef4656cf796e30e99.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a86c97bbb8ebe19aef4656cf796e30e99.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7053 of file json.hpp.

+

Definition at line 7057 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 569ffc765..4a46e47fc 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a99ee137dab7e5c948457f6a5321b54b1.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a99ee137dab7e5c948457f6a5321b54b1.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7096 of file json.hpp.

+

Definition at line 7100 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 2ad307a04..f3d679d8e 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9accc9dd9f9033f50c0ab6bcf337ffe0.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9accc9dd9f9033f50c0ab6bcf337ffe0.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7089 of file json.hpp.

+

Definition at line 7093 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 5bacf0517..875532805 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9ebc4c99e6fc90c965af0f39ad2ca70e.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a9ebc4c99e6fc90c965af0f39ad2ca70e.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -117,7 +117,7 @@ template<typename Base >
-

Definition at line 7048 of file json.hpp.

+

Definition at line 7052 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 a588165e5..fb67fa78c 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac2634bee082633671125e909dffad40a.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac2634bee082633671125e909dffad40a.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7104 of file json.hpp.

+

Definition at line 7108 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 8d6d2e612..36e329c68 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aca5116682e206dac48f8a56716a3280b.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aca5116682e206dac48f8a56716a3280b.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 7131 of file json.hpp.

+

Definition at line 7135 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 9b8c13333..0bb2b6bf0 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_acecae6d237fcf14c909fb42b9d2e2955.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_acecae6d237fcf14c909fb42b9d2e2955.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 7124 of file json.hpp.

+

Definition at line 7128 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 c78436fb5..8e0af9c67 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad4ec2bbb8347e7aa3b58e616fd6c7f40.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 7118 of file json.hpp.

+

Definition at line 7122 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 e680d7d33..af6ec77d4 100644 --- a/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html +++ b/classnlohmann_1_1basic__json_a01833b332b68d9af1f7cd7a816c39e49.html @@ -25,7 +25,7 @@
JSON for Modern C++ -  2.0.0 +  2.0.1
@@ -292,7 +292,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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    0
    @@ -310,7 +310,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 4505 of file json.hpp.

    +

    Definition at line 4507 of file json.hpp.

    @@ -320,7 +320,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a018ea61dbc973192d2ffc6bccc50696b.html b/classnlohmann_1_1basic__json_a018ea61dbc973192d2ffc6bccc50696b.html index 235d4acc6..9420b2da5 100644 --- a/classnlohmann_1_1basic__json_a018ea61dbc973192d2ffc6bccc50696b.html +++ b/classnlohmann_1_1basic__json_a018ea61dbc973192d2ffc6bccc50696b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:240
    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 
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    crbegin() – returns a const reverse iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4306 of file json.hpp.

    +

    Definition at line 4308 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a0389c5dd86adc512e5826d7ff610f776.html b/classnlohmann_1_1basic__json_a0389c5dd86adc512e5826d7ff610f776.html index e3412e494..8e769b6b7 100644 --- a/classnlohmann_1_1basic__json_a0389c5dd86adc512e5826d7ff610f776.html +++ b/classnlohmann_1_1basic__json_a0389c5dd86adc512e5826d7ff610f776.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -276,7 +276,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    the original JSON from a flattened version
    Note
    Empty objects and arrays are flattened by flatten() to null values and can not unflattened to their original type. Apart from this example, for a JSON value j, the following is always true: j == j.flatten().unflatten().
    Complexity
    Linear in the size the JSON value.
    -
    Example
    The following code shows how a flattened JSON object is unflattened into the original nested JSON object.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON value
    8  json j_flattened =
    9  {
    10  {"/answer/everything", 42},
    11  {"/happy", true},
    12  {"/list/0", 1},
    13  {"/list/1", 0},
    14  {"/list/2", 2},
    15  {"/name", "Niels"},
    16  {"/nothing", nullptr},
    17  {"/object/currency", "USD"},
    18  {"/object/value", 42.99},
    19  {"/pi", 3.141}
    20  };
    21 
    22  // call unflatten()
    23  std::cout << std::setw(4) << j_flattened.unflatten() << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The following code shows how a flattened JSON object is unflattened into the original nested JSON object.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON value
    8  json j_flattened =
    9  {
    10  {"/answer/everything", 42},
    11  {"/happy", true},
    12  {"/list/0", 1},
    13  {"/list/1", 0},
    14  {"/list/2", 2},
    15  {"/name", "Niels"},
    16  {"/nothing", nullptr},
    17  {"/object/currency", "USD"},
    18  {"/object/value", 42.99},
    19  {"/pi", 3.141}
    20  };
    21 
    22  // call unflatten()
    23  std::cout << std::setw(4) << j_flattened.unflatten() << '\n';
    24 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    {
         "answer": {
             "everything": 42
    @@ -299,7 +299,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    flatten() for the reverse function
    Since
    version 2.0.0
    -

    Definition at line 9469 of file json.hpp.

    +

    Definition at line 9473 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_a06efb200b69942eacd1ea22d0f6ccebb.html b/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html index f5124b597..5685b572a 100644 --- a/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html +++ b/classnlohmann_1_1basic__json_a06efb200b69942eacd1ea22d0f6ccebb.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html b/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html index 00392248c..d130fc0f0 100644 --- a/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html +++ b/classnlohmann_1_1basic__json_a098482190447461f47f80b99bf2519f6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for back().
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // 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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -291,7 +291,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 3693 of file json.hpp.

    +

    Definition at line 3695 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_a0a2cbbd95862a623e7dc5c37e67dead0.html b/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html index 5daef45d5..1f837774b 100644 --- a/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html +++ b/classnlohmann_1_1basic__json_a0a2cbbd95862a623e7dc5c37e67dead0.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -307,7 +307,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:9960
    +
    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:9964
    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
    @@ -315,7 +315,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3586 of file json.hpp.

    +

    Definition at line 3588 of file json.hpp.

    @@ -325,7 +325,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html b/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html index 6a873d601..258425759 100644 --- a/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html +++ b/classnlohmann_1_1basic__json_a0ac9894c9de8dc551cf2e5f1c605537f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a0d46dd5ef4992fb80f9f0d9f56f16eae.html b/classnlohmann_1_1basic__json_a0d46dd5ef4992fb80f9f0d9f56f16eae.html index 7ac561892..80f07ac41 100644 --- a/classnlohmann_1_1basic__json_a0d46dd5ef4992fb80f9f0d9f56f16eae.html +++ b/classnlohmann_1_1basic__json_a0d46dd5ef4992fb80f9f0d9f56f16eae.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje -
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j.at("/number"_json_pointer) << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j.at("/string"_json_pointer) << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j.at("/array"_json_pointer) << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j.at("/array/1"_json_pointer) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j.at("/number"_json_pointer) << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j.at("/string"_json_pointer) << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j.at("/array"_json_pointer) << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j.at("/array/1"_json_pointer) << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    1
     "foo"
     [1,2]
    @@ -294,7 +294,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/at_json_pointer_const.cpp -o at_json_pointer_const 
    Since
    version 2.0.0
    -

    Definition at line 9408 of file json.hpp.

    +

    Definition at line 9412 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_a0d838bc7ffca6017f51167e0a8ffd9b6.html b/classnlohmann_1_1basic__json_a0d838bc7ffca6017f51167e0a8ffd9b6.html index 82ebcd0bf..da5d05d5b 100644 --- a/classnlohmann_1_1basic__json_a0d838bc7ffca6017f51167e0a8ffd9b6.html +++ b/classnlohmann_1_1basic__json_a0d838bc7ffca6017f51167e0a8ffd9b6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    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 
    @@ -304,7 +304,7 @@ template<typename T , typename std::enable_if<
    diff --git a/classnlohmann_1_1basic__json_a0d96ff13001977a93d65f0a97279d316.html b/classnlohmann_1_1basic__json_a0d96ff13001977a93d65f0a97279d316.html index 3d47a59a0..3904b9656 100644 --- a/classnlohmann_1_1basic__json_a0d96ff13001977a93d65f0a97279d316.html +++ b/classnlohmann_1_1basic__json_a0d96ff13001977a93d65f0a97279d316.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is object, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -284,7 +284,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_object.cpp -o is_object 
    Since
    version 1.0.0
    -

    Definition at line 2369 of file json.hpp.

    +

    Definition at line 2371 of file json.hpp.

    @@ -294,7 +294,7 @@ false diff --git a/classnlohmann_1_1basic__json_a101cd941eb8a5c299660449c71d0e75e.html b/classnlohmann_1_1basic__json_a101cd941eb8a5c299660449c71d0e75e.html index cf454d9b0..d83c46918 100644 --- a/classnlohmann_1_1basic__json_a101cd941eb8a5c299660449c71d0e75e.html +++ b/classnlohmann_1_1basic__json_a101cd941eb8a5c299660449c71d0e75e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    the type of the JSON value
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    value_t
    the JSON type enumeration
    Definition: json.hpp:698
    @@ -291,7 +291,7 @@ true The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__value_t.cpp -o operator__value_t 
    Since
    version 1.0.0
    -

    Definition at line 2463 of file json.hpp.

    +

    Definition at line 2465 of file json.hpp.

    @@ -301,7 +301,7 @@ true diff --git a/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html b/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html index 970e3418e..b0ee9926f 100644 --- a/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html +++ b/classnlohmann_1_1basic__json_a112a2d8e76345ea64f71e2985fee4c52.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -288,7 +288,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:9960
    +
    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:9964
    Output (play with this example online):
    []
     ["Hello"]
     ["Hello","Hello","Hello","Hello","Hello"]
    @@ -305,7 +305,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 8ba08304a..40afcaf05 100644 --- a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html +++ b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -293,7 +293,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3] == [1,2,4] false
     {"A":"a","B":"b"} == {"A":"a","B":"b"} true
     17 == 17 true
    @@ -301,7 +301,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 5278 of file json.hpp.

    +

    Definition at line 5280 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_a12ccf14d39ddae52f6c7e126105a230b.html b/classnlohmann_1_1basic__json_a12ccf14d39ddae52f6c7e126105a230b.html index 8b8eef111..20c1b64eb 100644 --- a/classnlohmann_1_1basic__json_a12ccf14d39ddae52f6c7e126105a230b.html +++ b/classnlohmann_1_1basic__json_a12ccf14d39ddae52f6c7e126105a230b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    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
    @@ -289,7 +289,7 @@ Illustration from cppreference.com
    cbegin() – returns a const iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4191 of file json.hpp.

    +

    Definition at line 4193 of file json.hpp.

    @@ -299,7 +299,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html b/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html index 0016deff5..0d272494d 100644 --- a/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html +++ b/classnlohmann_1_1basic__json_a13c4d2ab4e7ee2f92be785a7b12948ff.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,8 +289,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:9960
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5707
    +
    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:9964
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5714
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:918
    the parser read a key of a value in an object
    parse_event_t
    JSON callback events.
    Definition: json.hpp:853
    @@ -332,7 +332,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 5736 of file json.hpp.

    +

    Definition at line 5743 of file json.hpp.

    @@ -342,7 +342,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a1407f91b4689bbc56d1a3c401a5bb649.html b/classnlohmann_1_1basic__json_a1407f91b4689bbc56d1a3c401a5bb649.html index 62a62d05c..ad8e35b24 100644 --- a/classnlohmann_1_1basic__json_a1407f91b4689bbc56d1a3c401a5bb649.html +++ b/classnlohmann_1_1basic__json_a1407f91b4689bbc56d1a3c401a5bb649.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is number (regardless whether integer, unsigned integer or floating-type), false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     true
    @@ -289,7 +289,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 1.0.0
    -

    Definition at line 2262 of file json.hpp.

    +

    Definition at line 2264 of file json.hpp.

    @@ -299,7 +299,7 @@ false diff --git a/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html b/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html index bbef90c19..4bbdd6f75 100644 --- a/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html +++ b/classnlohmann_1_1basic__json_a140b8251f82e99ad279dcad5c977e26b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -287,7 +287,7 @@ template<typename T , std::size_t n>
    Complexity
    Logarithmic in the size of the container.
    -
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON object
    8  json object =
    9  {
    10  {"one", 1}, {"two", 2}, {"three", 2.9}
    11  };
    12 
    13  // output element with key "two"
    14  std::cout << object["two"] << "\n\n";
    15 
    16  // change element with key "three"
    17  object["three"] = 3;
    18 
    19  // output changed array
    20  std::cout << std::setw(4) << object << "\n\n";
    21 
    22  // mention nonexisting key
    23  object["four"];
    24 
    25  // write to nonexisting key
    26  object["five"]["really"]["nested"] = true;
    27 
    28  // output changed object
    29  std::cout << std::setw(4) << object << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    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:9964
    Output (play with this example online):
    2
     
     {
    @@ -313,7 +313,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 3402 of file json.hpp.

    +

    Definition at line 3404 of file json.hpp.

    @@ -323,7 +323,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 ba3b815da..3e2bb2123 100644 --- a/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html +++ b/classnlohmann_1_1basic__json_a1579a8f72a230358d6cd1a6e8a62859b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a19dfb04c297ffb5f0ef84abfa4a5a087.html b/classnlohmann_1_1basic__json_a19dfb04c297ffb5f0ef84abfa4a5a087.html index a8dc00fb8..b841cd585 100644 --- a/classnlohmann_1_1basic__json_a19dfb04c297ffb5f0ef84abfa4a5a087.html +++ b/classnlohmann_1_1basic__json_a19dfb04c297ffb5f0ef84abfa4a5a087.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    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
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    cbegin() – returns a const iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4231 of file json.hpp.

    +

    Definition at line 4233 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html b/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html index 4a28973ee..2822b23f1 100644 --- a/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html +++ b/classnlohmann_1_1basic__json_a1a446a48beed4ea564addfd12d235793.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a1af360cb513cc32f28e80ddd0b9d7666.html b/classnlohmann_1_1basic__json_a1af360cb513cc32f28e80ddd0b9d7666.html index 78432db85..1c1f9934a 100644 --- a/classnlohmann_1_1basic__json_a1af360cb513cc32f28e80ddd0b9d7666.html +++ b/classnlohmann_1_1basic__json_a1af360cb513cc32f28e80ddd0b9d7666.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is array, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -284,7 +284,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_array.cpp -o is_array 
    Since
    version 1.0.0
    -

    Definition at line 2391 of file json.hpp.

    +

    Definition at line 2393 of file json.hpp.

    @@ -294,7 +294,7 @@ false diff --git a/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html b/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html index ad7816d69..26fd8da36 100644 --- a/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html +++ b/classnlohmann_1_1basic__json_a1c1aa2d148a3e4ce0d4e50cf5b894f41.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -291,7 +291,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 4732 of file json.hpp.

    +

    Definition at line 4734 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html b/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html index 2fc7a1ed9..855cc904c 100644 --- a/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html +++ b/classnlohmann_1_1basic__json_a20bfb2ca6d4c421c74bb3e53328cd437.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -303,7 +303,7 @@ array: [1,2,3,4,5]
     get() for pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2807 of file json.hpp.

    +

    Definition at line 2809 of file json.hpp.

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

    Definition at line 3037 of file json.hpp.

    +

    Definition at line 3039 of file json.hpp.

    @@ -304,7 +304,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 dd1843179..4dcab0990 100644 --- a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html +++ b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -307,7 +307,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a24d7df0b5b41319dbab2713d3641faf7.html b/classnlohmann_1_1basic__json_a24d7df0b5b41319dbab2713d3641faf7.html index ac7894ee9..b6acadf1d 100644 --- a/classnlohmann_1_1basic__json_a24d7df0b5b41319dbab2713d3641faf7.html +++ b/classnlohmann_1_1basic__json_a24d7df0b5b41319dbab2713d3641faf7.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    -

    Definition at line 5231 of file json.hpp.

    +

    Definition at line 5233 of file json.hpp.

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

    Definition at line 3859 of file json.hpp.

    +

    Definition at line 3861 of file json.hpp.

    @@ -339,7 +339,7 @@ null diff --git a/classnlohmann_1_1basic__json_a2badcf191deabf579abcf8d3654da26f.html b/classnlohmann_1_1basic__json_a2badcf191deabf579abcf8d3654da26f.html index e09a99083..e9cf4e7f5 100644 --- a/classnlohmann_1_1basic__json_a2badcf191deabf579abcf8d3654da26f.html +++ b/classnlohmann_1_1basic__json_a2badcf191deabf579abcf8d3654da26f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -281,7 +281,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:9960
    +
    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:9964
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    3.14159265358979
     null
    @@ -300,7 +300,7 @@ null
     
    diff --git a/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html b/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html index 4f38d4293..4be51eb7d 100644 --- a/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html +++ b/classnlohmann_1_1basic__json_a2e26bd0b0168abb61f67ad5bcd5b9fa1.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,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:9960
    +
    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:9964
    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
    @@ -294,7 +294,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3359 of file json.hpp.

    +

    Definition at line 3361 of file json.hpp.

    @@ -304,7 +304,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html b/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html index eabc39e51..f7991a419 100644 --- a/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html +++ b/classnlohmann_1_1basic__json_a2f1f83aa187a56dc5ec7a7027065ac8a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,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 abcd4c82e..21ad5a9e7 100644 --- a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html +++ b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -310,7 +310,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 5668 of file json.hpp.

    +

    Definition at line 5675 of file json.hpp.

    @@ -320,7 +320,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 9b6817d69..de8e33e32 100644 --- a/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html +++ b/classnlohmann_1_1basic__json_a35303ad045a06c2a79dc28ac29652e86.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,8 +289,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:9960
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5707
    +
    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:9964
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5714
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:918
    the parser read a key of a value in an object
    parse_event_t
    JSON callback events.
    Definition: json.hpp:853
    @@ -332,7 +332,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 5707 of file json.hpp.

    +

    Definition at line 5714 of file json.hpp.

    @@ -342,7 +342,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a363da77bc39cae041d59ee334ac4f41b.html b/classnlohmann_1_1basic__json_a363da77bc39cae041d59ee334ac4f41b.html index c816d6b87..443197054 100644 --- a/classnlohmann_1_1basic__json_a363da77bc39cae041d59ee334ac4f41b.html +++ b/classnlohmann_1_1basic__json_a363da77bc39cae041d59ee334ac4f41b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    17 17 17 17
    @@ -289,7 +289,7 @@ true
     
    See also
    get_ptr() for explicit pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2856 of file json.hpp.

    +

    Definition at line 2858 of file json.hpp.

    @@ -299,7 +299,7 @@ true diff --git a/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html b/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html index 68d1949f4..148296a65 100644 --- a/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html +++ b/classnlohmann_1_1basic__json_a3654da9a84deaf61899c4eee5b93c2c5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows the constructor with string literal parameter.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON string directly from a string literal
    8  json j("The quick brown fox jumps over the lazy doc");
    9 
    10  // serialize the JSON array
    11  std::cout << j << '\n';
    12 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    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:9964
    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
    @@ -301,7 +301,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 b1c9bded2..f405a87c7 100644 --- a/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html +++ b/classnlohmann_1_1basic__json_a38ee0f09a318d003add75e0787040794.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,14 +283,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:9960
    +
    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:9964
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:348
    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 5163 of file json.hpp.

    +

    Definition at line 5165 of file json.hpp.

    @@ -300,7 +300,7 @@ object = {"one":"eins","two":"zwei"} diff --git a/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html b/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html index a51b84a34..22203b605 100644 --- a/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html +++ b/classnlohmann_1_1basic__json_a3aaf41d385f0d9a93deb92f9b14ae0cf.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:394
    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 
    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html b/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html index 7bd918804..98a93e131 100644 --- a/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html +++ b/classnlohmann_1_1basic__json_a3da254c422ede5495f2815c5e48c00c5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,7 @@ is out of 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:9960
    +
    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:9964
    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
    @@ -295,7 +295,7 @@ is out of 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 3984 of file json.hpp.

    +

    Definition at line 3986 of file json.hpp.

    @@ -305,7 +305,7 @@ is out of range" diff --git a/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html b/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html index a915c55fc..234fd45fc 100644 --- a/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html +++ b/classnlohmann_1_1basic__json_a3ec8e17be8732fe436e9d6733f52b7a3.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a43c08a393368eb674d0dcdbe301aafe3.html b/classnlohmann_1_1basic__json_a43c08a393368eb674d0dcdbe301aafe3.html index 77b8df5ea..46d73b194 100644 --- a/classnlohmann_1_1basic__json_a43c08a393368eb674d0dcdbe301aafe3.html +++ b/classnlohmann_1_1basic__json_a43c08a393368eb674d0dcdbe301aafe3.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:240
    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 
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    crend() – returns a const reverse iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4335 of file json.hpp.

    +

    Definition at line 4337 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html b/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html index f5abe777f..ae92c4b95 100644 --- a/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html +++ b/classnlohmann_1_1basic__json_a45e789042a23138eba2b69f34df9fc45.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -304,7 +304,7 @@ out 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:9960
    +
    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:9964
    Output (play with this example online):
    null
     null
     null
    @@ -319,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 3751 of file json.hpp.

    +

    Definition at line 3753 of file json.hpp.

    @@ -329,7 +329,7 @@ null diff --git a/classnlohmann_1_1basic__json_a4635e8c6d5a4599f12a76368e325acd8.html b/classnlohmann_1_1basic__json_a4635e8c6d5a4599f12a76368e325acd8.html index 3f448a849..a89763a44 100644 --- a/classnlohmann_1_1basic__json_a4635e8c6d5a4599f12a76368e325acd8.html +++ b/classnlohmann_1_1basic__json_a4635e8c6d5a4599f12a76368e325acd8.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:240
    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 
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    crend() – returns a const reverse iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4269 of file json.hpp.

    +

    Definition at line 4271 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html b/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html index a6690c3f5..7c89eb1d6 100644 --- a/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html +++ b/classnlohmann_1_1basic__json_a486b96adbf4886c38e38c952394a220f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -291,7 +291,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 4706 of file json.hpp.

    +

    Definition at line 4708 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html b/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html index c54f056d4..465602de7 100644 --- a/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html +++ b/classnlohmann_1_1basic__json_a4ab93491f82545342562c7ee7e3166c7.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -288,7 +288,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:9960
    +
    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:9964
    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 
    @@ -304,7 +304,7 @@ true
    diff --git a/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html b/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html index 58473b436..8e70e3555 100644 --- a/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html +++ b/classnlohmann_1_1basic__json_a4bbdfd6dd8d2e6fc9ac5d81ef61ba3fe.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    Output (play with this example online):
    42.2299995422363
     null
     23.42
    @@ -307,7 +307,7 @@ null
     
    diff --git a/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html b/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html index a3fe44222..88afa0183 100644 --- a/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html +++ b/classnlohmann_1_1basic__json_a4f332e90f3cae562d0c3fa6ba48f74f9.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    17 17
    @@ -294,7 +294,7 @@ incompatible ReferenceType for get_ref, actual type is number
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ref.cpp -o get_ref 
    Since
    version 1.1.0
    -

    Definition at line 2942 of file json.hpp.

    +

    Definition at line 2944 of file json.hpp.

    @@ -304,7 +304,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 be23ef369..082e6fabf 100644 --- a/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html +++ b/classnlohmann_1_1basic__json_a51b0036310d8aa5858fecc0d91127f27.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,13 +278,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:9960
    +
    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:9964
    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 4079 of file json.hpp.

    +

    Definition at line 4081 of file json.hpp.

    @@ -294,7 +294,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 553ced895..eb32bdb24 100644 --- a/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html +++ b/classnlohmann_1_1basic__json_a5212588544f6d2266384c3be9bfda0c5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -291,7 +291,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 4792 of file json.hpp.

    +

    Definition at line 4794 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a5327abb014dec211593b00959830650e.html b/classnlohmann_1_1basic__json_a5327abb014dec211593b00959830650e.html index ff89f4046..df788f594 100644 --- a/classnlohmann_1_1basic__json_a5327abb014dec211593b00959830650e.html +++ b/classnlohmann_1_1basic__json_a5327abb014dec211593b00959830650e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    an object that maps JSON pointers to primitve values
    Note
    Empty objects and arrays are flattened to null and will not be reconstructed correctly by the unflatten() function.
    Complexity
    Linear in the size the JSON value.
    -
    Example
    The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON value
    8  json j =
    9  {
    10  {"pi", 3.141},
    11  {"happy", true},
    12  {"name", "Niels"},
    13  {"nothing", nullptr},
    14  {
    15  "answer", {
    16  {"everything", 42}
    17  }
    18  },
    19  {"list", {1, 0, 2}},
    20  {
    21  "object", {
    22  {"currency", "USD"},
    23  {"value", 42.99}
    24  }
    25  }
    26  };
    27 
    28  // call flatten()
    29  std::cout << std::setw(4) << j.flatten() << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON value
    8  json j =
    9  {
    10  {"pi", 3.141},
    11  {"happy", true},
    12  {"name", "Niels"},
    13  {"nothing", nullptr},
    14  {
    15  "answer", {
    16  {"everything", 42}
    17  }
    18  },
    19  {"list", {1, 0, 2}},
    20  {
    21  "object", {
    22  {"currency", "USD"},
    23  {"value", 42.99}
    24  }
    25  }
    26  };
    27 
    28  // call flatten()
    29  std::cout << std::setw(4) << j.flatten() << '\n';
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    {
         "/answer/everything": 42,
         "/happy": true,
    @@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    unflatten() for the reverse function
    Since
    version 2.0.0
    -

    Definition at line 9435 of file json.hpp.

    +

    Definition at line 9439 of file json.hpp.

    @@ -299,7 +299,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a53771a7a4f2787125e55f64448f24ce6.html b/classnlohmann_1_1basic__json_a53771a7a4f2787125e55f64448f24ce6.html index 136797153..e3e260034 100644 --- a/classnlohmann_1_1basic__json_a53771a7a4f2787125e55f64448f24ce6.html +++ b/classnlohmann_1_1basic__json_a53771a7a4f2787125e55f64448f24ce6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -276,7 +276,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:9960
    +
    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:9964
    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
    @@ -290,7 +290,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_a558b345044c38a9f6ad522592cc700c8.html b/classnlohmann_1_1basic__json_a558b345044c38a9f6ad522592cc700c8.html index ae9eafd5f..f93347e20 100644 --- a/classnlohmann_1_1basic__json_a558b345044c38a9f6ad522592cc700c8.html +++ b/classnlohmann_1_1basic__json_a558b345044c38a9f6ad522592cc700c8.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is structured (array or object), false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -289,7 +289,7 @@ false
     is_object() – returns whether value is an object
    Since
    version 1.0.0
    -

    Definition at line 2188 of file json.hpp.

    +

    Definition at line 2190 of file json.hpp.

    @@ -299,7 +299,7 @@ false diff --git a/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html b/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html index 4042e2023..8b10e56d2 100644 --- a/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html +++ b/classnlohmann_1_1basic__json_a5685815624b086caa532f41e853d4b0f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    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:1645
    Output (play with this example online):
    []
     []
    @@ -305,7 +305,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    diff --git a/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html b/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html index dd2cad57b..3be34943c 100644 --- a/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html +++ b/classnlohmann_1_1basic__json_a59732a1de287a7301cca19a7a7748159.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,14 +285,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    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:9960
    +
    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:9964
    Output (play with this example online):
    4
     [1,2,3,4,6]
     [1,2,3,4,6,null,null,null,null,null,11]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__size_type.cpp -o operatorarray__size_type 
    Since
    version 1.0.0
    -

    Definition at line 3224 of file json.hpp.

    +

    Definition at line 3226 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_a5c8bb5200f5eac10d31e26be46e5b1ac.html b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html index 506d4cd35..c78841930 100644 --- a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html +++ b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    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
    @@ -297,7 +297,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 5569 of file json.hpp.

    +

    Definition at line 5571 of file json.hpp.

    @@ -307,7 +307,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html index 2599fea95..6dcb99c81 100644 --- a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html +++ b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -310,7 +310,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 5650 of file json.hpp.

    +

    Definition at line 5652 of file json.hpp.

    @@ -320,7 +320,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html b/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html index 749193448..394c97d70 100644 --- a/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html +++ b/classnlohmann_1_1basic__json_a60a04166c122072ab11eaf9845d9cd1d.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -295,7 +295,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 fae5ebefc..43a9e0574 100644 --- a/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html +++ b/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -295,7 +295,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:9960
    +
    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:9964
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -313,7 +313,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 5772 of file json.hpp.

    +

    Definition at line 5779 of file json.hpp.

    @@ -323,7 +323,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a618a5c5c9f8889032657370c8247a587.html b/classnlohmann_1_1basic__json_a618a5c5c9f8889032657370c8247a587.html index d570c8c73..36c8354f4 100644 --- a/classnlohmann_1_1basic__json_a618a5c5c9f8889032657370c8247a587.html +++ b/classnlohmann_1_1basic__json_a618a5c5c9f8889032657370c8247a587.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -298,9 +298,9 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    a JSON patch to convert the source to target
    Complexity
    Linear in the lengths of source and target.
    -
    Example
    The following code shows how a JSON patch is created as a diff for two JSON values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // the source document
    8  json source = R"(
    9  {
    10  "baz": "qux",
    11  "foo": "bar"
    12  }
    13  )"_json;
    14 
    15  // the target document
    16  json target = R"(
    17  {
    18  "baz": "boo",
    19  "hello": [
    20  "world"
    21  ]
    22  }
    23  )"_json;
    24 
    25  // create the patch
    26  json patch = json::diff(source, target);
    27 
    28  // roundtrip
    29  json patched_source = source.patch(patch);
    30 
    31  // output patch and roundtrip result
    32  std::cout << std::setw(4) << patch << "\n\n"
    33  << std::setw(4) << patched_source << std::endl;
    34 }
    static basic_json diff(const basic_json &source, const basic_json &target, std::string path="")
    creates a diff as a JSON patch
    Definition: json.hpp:9812
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    -
    basic_json patch(const basic_json &json_patch) const
    applies a JSON patch
    Definition: json.hpp:9519
    +
    Example
    The following code shows how a JSON patch is created as a diff for two JSON values.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // the source document
    8  json source = R"(
    9  {
    10  "baz": "qux",
    11  "foo": "bar"
    12  }
    13  )"_json;
    14 
    15  // the target document
    16  json target = R"(
    17  {
    18  "baz": "boo",
    19  "hello": [
    20  "world"
    21  ]
    22  }
    23  )"_json;
    24 
    25  // create the patch
    26  json patch = json::diff(source, target);
    27 
    28  // roundtrip
    29  json patched_source = source.patch(patch);
    30 
    31  // output patch and roundtrip result
    32  std::cout << std::setw(4) << patch << "\n\n"
    33  << std::setw(4) << patched_source << std::endl;
    34 }
    static basic_json diff(const basic_json &source, const basic_json &target, std::string path="")
    creates a diff as a JSON patch
    Definition: json.hpp:9816
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    +
    basic_json patch(const basic_json &json_patch) const
    applies a JSON patch
    Definition: json.hpp:9523
    Output (play with this example online):
    [
         {
             "op": "replace",
    @@ -332,7 +332,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     RFC 6902 (JSON Patch)
    Since
    version 2.0.0
    -

    Definition at line 9812 of file json.hpp.

    +

    Definition at line 9816 of file json.hpp.

    @@ -342,7 +342,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html b/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html index c484d7466..559a17c4c 100644 --- a/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html +++ b/classnlohmann_1_1basic__json_a624025acfcf64364d98424402b837bc6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -303,13 +303,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:9960
    +
    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:9964
    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 4948 of file json.hpp.

    +

    Definition at line 4950 of file json.hpp.

    @@ -319,7 +319,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a628733b45cd0e32bd59efea149f40b4b.html b/classnlohmann_1_1basic__json_a628733b45cd0e32bd59efea149f40b4b.html index 09708f823..9902ff44c 100644 --- a/classnlohmann_1_1basic__json_a628733b45cd0e32bd59efea149f40b4b.html +++ b/classnlohmann_1_1basic__json_a628733b45cd0e32bd59efea149f40b4b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is a floating-point number, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -289,7 +289,7 @@ false
     is_number_unsigned() – check if value is an unsigned integer number
    Since
    version 1.0.0
    -

    Definition at line 2347 of file json.hpp.

    +

    Definition at line 2349 of file json.hpp.

    @@ -299,7 +299,7 @@ false diff --git a/classnlohmann_1_1basic__json_a62ccf5b9b3674aec2403fbc02da03db8.html b/classnlohmann_1_1basic__json_a62ccf5b9b3674aec2403fbc02da03db8.html index 12f7a9133..c7594b6e1 100644 --- a/classnlohmann_1_1basic__json_a62ccf5b9b3674aec2403fbc02da03db8.html +++ b/classnlohmann_1_1basic__json_a62ccf5b9b3674aec2403fbc02da03db8.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    json_reverse_iterator< typename basic_json::iterator > reverse_iterator
    a reverse iterator for a basic_json container
    Definition: json.hpp:238
    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 
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    crend() – returns a const reverse iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4261 of file json.hpp.

    +

    Definition at line 4263 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a649aef71e5d952499da7ad3b8e7c9236.html b/classnlohmann_1_1basic__json_a649aef71e5d952499da7ad3b8e7c9236.html index 1074f5484..da4773b99 100644 --- a/classnlohmann_1_1basic__json_a649aef71e5d952499da7ad3b8e7c9236.html +++ b/classnlohmann_1_1basic__json_a649aef71e5d952499da7ad3b8e7c9236.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j.at("/number"_json_pointer) << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j.at("/string"_json_pointer) << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j.at("/array"_json_pointer) << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j.at("/array/1"_json_pointer) << '\n';
    23 
    24  // writing access
    25 
    26  // change the string
    27  j.at("/string"_json_pointer) = "bar";
    28  // output the changed string
    29  std::cout << j["string"] << '\n';
    30 
    31  // change an array element
    32  j.at("/array/1"_json_pointer) = 21;
    33  // output the changed array
    34  std::cout << j["array"] << '\n';
    35 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j.at("/number"_json_pointer) << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j.at("/string"_json_pointer) << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j.at("/array"_json_pointer) << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j.at("/array/1"_json_pointer) << '\n';
    23 
    24  // writing access
    25 
    26  // change the string
    27  j.at("/string"_json_pointer) = "bar";
    28  // output the changed string
    29  std::cout << j["string"] << '\n';
    30 
    31  // change an array element
    32  j.at("/array/1"_json_pointer) = 21;
    33  // output the changed array
    34  std::cout << j["array"] << '\n';
    35 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    1
     "foo"
     [1,2]
    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/at_json_pointer.cpp -o at_json_pointer 
    Since
    version 2.0.0
    -

    Definition at line 9383 of file json.hpp.

    +

    Definition at line 9387 of file json.hpp.

    @@ -306,7 +306,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a66c051561828b2c4eeaad896a72bec99.html b/classnlohmann_1_1basic__json_a66c051561828b2c4eeaad896a72bec99.html index 45d8d5cd3..251d095a7 100644 --- a/classnlohmann_1_1basic__json_a66c051561828b2c4eeaad896a72bec99.html +++ b/classnlohmann_1_1basic__json_a66c051561828b2c4eeaad896a72bec99.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -273,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is discarded, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -285,7 +285,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_discarded.cpp -o is_discarded 
    Since
    version 1.0.0
    -

    Definition at line 2440 of file json.hpp.

    +

    Definition at line 2442 of file json.hpp.

    @@ -295,7 +295,7 @@ false diff --git a/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html b/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html index 950c3e896..d6804ae3a 100644 --- a/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html +++ b/classnlohmann_1_1basic__json_a674de1ee73e6bf4843fc5dc1351fb726.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    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 value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3177 of file json.hpp.

    +

    Definition at line 3179 of file json.hpp.

    @@ -304,7 +304,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_a685d9d6a8a45bfcb8455b147257cdffb.html b/classnlohmann_1_1basic__json_a685d9d6a8a45bfcb8455b147257cdffb.html index be78d9e40..eb53a0cdd 100644 --- a/classnlohmann_1_1basic__json_a685d9d6a8a45bfcb8455b147257cdffb.html +++ b/classnlohmann_1_1basic__json_a685d9d6a8a45bfcb8455b147257cdffb.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is null, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    true
     false
     false
    @@ -284,7 +284,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_null.cpp -o is_null 
    Since
    version 1.0.0
    -

    Definition at line 2210 of file json.hpp.

    +

    Definition at line 2212 of file json.hpp.

    @@ -294,7 +294,7 @@ false diff --git a/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html b/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html index 59c03a356..697103799 100644 --- a/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html +++ b/classnlohmann_1_1basic__json_a68a5f34b164a07b8ced13fcf2b7ec834.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -298,7 +298,7 @@ template<typename CompatibleNumberUnsignedType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a68f0a8c4618d57523384ec7ecd2f5819.html b/classnlohmann_1_1basic__json_a68f0a8c4618d57523384ec7ecd2f5819.html index 6b2e2259b..a9379e7fb 100644 --- a/classnlohmann_1_1basic__json_a68f0a8c4618d57523384ec7ecd2f5819.html +++ b/classnlohmann_1_1basic__json_a68f0a8c4618d57523384ec7ecd2f5819.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    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
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    cbegin() – returns a const iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4201 of file json.hpp.

    +

    Definition at line 4203 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a693b411d9c5ad0d168a0013cfb80b8e5.html b/classnlohmann_1_1basic__json_a693b411d9c5ad0d168a0013cfb80b8e5.html index 351daaebe..20d5bc097 100644 --- a/classnlohmann_1_1basic__json_a693b411d9c5ad0d168a0013cfb80b8e5.html +++ b/classnlohmann_1_1basic__json_a693b411d9c5ad0d168a0013cfb80b8e5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is an unsigned integer number, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -289,7 +289,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 2.0.0
    -

    Definition at line 2319 of file json.hpp.

    +

    Definition at line 2321 of file json.hpp.

    @@ -299,7 +299,7 @@ false diff --git a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html index 0de7fcbeb..839f858c2 100644 --- a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html +++ b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3] == [1,2,4] true
     {"A":"a","B":"b"} == {"A":"a","B":"b"} false
     17 == 17 false
    @@ -297,7 +297,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 5407 of file json.hpp.

    +

    Definition at line 5409 of file json.hpp.

    @@ -307,7 +307,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 1e4c7d6a7..4f4771770 100644 --- a/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html +++ b/classnlohmann_1_1basic__json_a6f3dfd3e83a1e907d7946b47fcd7ceba.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -291,7 +291,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 4742 of file json.hpp.

    +

    Definition at line 4744 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a70ae1f0747f5b7a89979512866474f1a.html b/classnlohmann_1_1basic__json_a70ae1f0747f5b7a89979512866474f1a.html index e29bb7d37..525ab6c30 100644 --- a/classnlohmann_1_1basic__json_a70ae1f0747f5b7a89979512866474f1a.html +++ b/classnlohmann_1_1basic__json_a70ae1f0747f5b7a89979512866474f1a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,7 +278,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:9960
    +
    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:9964
    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)
    @@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html b/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html index aad15a583..ebda0a77f 100644 --- a/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html +++ b/classnlohmann_1_1basic__json_a71b1d38ef402dfee58fba1fe01fa67f5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The following code shows an example for back().
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // 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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -291,7 +291,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 3683 of file json.hpp.

    +

    Definition at line 3685 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_a73e150cbcba5643cb89de8f515eb64e2.html b/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html index 4beaffc90..4b3d4b6e1 100644 --- a/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html +++ b/classnlohmann_1_1basic__json_a73e150cbcba5643cb89de8f515eb64e2.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,7 +278,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:9960
    +
    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:9964
    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 
    @@ -294,7 +294,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 75e413b01..f0a854e65 100644 --- a/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html +++ b/classnlohmann_1_1basic__json_a74a0013e847fdc574b48f931f0e757e1.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -291,7 +291,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 232ca9a5b..d6f6d2d73 100644 --- a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html +++ b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    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
    @@ -297,7 +297,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 5613 of file json.hpp.

    +

    Definition at line 5615 of file json.hpp.

    @@ -307,7 +307,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a7605b20debcc12fc44bd9f2075122a87.html b/classnlohmann_1_1basic__json_a7605b20debcc12fc44bd9f2075122a87.html index a1cbd2f7b..b9495ec14 100644 --- a/classnlohmann_1_1basic__json_a7605b20debcc12fc44bd9f2075122a87.html +++ b/classnlohmann_1_1basic__json_a7605b20debcc12fc44bd9f2075122a87.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -291,7 +291,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j["/number"_json_pointer] << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j["/string"_json_pointer] << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j["/array"_json_pointer] << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j["/array/1"_json_pointer] << '\n';
    23 
    24  // writing access
    25 
    26  // change the string
    27  j["/string"_json_pointer] = "bar";
    28  // output the changed string
    29  std::cout << j["string"] << '\n';
    30 
    31  // "change" a nonexisting object entry
    32  j["/boolean"_json_pointer] = true;
    33  // output the changed object
    34  std::cout << j << '\n';
    35 
    36  // change an array element
    37  j["/array/1"_json_pointer] = 21;
    38  // "change" an array element with nonexisting index
    39  j["/array/4"_json_pointer] = 44;
    40  // output the changed array
    41  std::cout << j["array"] << '\n';
    42 
    43  // "change" the arry element past the end
    44  j["/array/-"_json_pointer] = 55;
    45  // output the changed array
    46  std::cout << j["array"] << '\n';
    47 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j["/number"_json_pointer] << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j["/string"_json_pointer] << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j["/array"_json_pointer] << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j["/array/1"_json_pointer] << '\n';
    23 
    24  // writing access
    25 
    26  // change the string
    27  j["/string"_json_pointer] = "bar";
    28  // output the changed string
    29  std::cout << j["string"] << '\n';
    30 
    31  // "change" a nonexisting object entry
    32  j["/boolean"_json_pointer] = true;
    33  // output the changed object
    34  std::cout << j << '\n';
    35 
    36  // change an array element
    37  j["/array/1"_json_pointer] = 21;
    38  // "change" an array element with nonexisting index
    39  j["/array/4"_json_pointer] = 44;
    40  // output the changed array
    41  std::cout << j["array"] << '\n';
    42 
    43  // "change" the arry element past the end
    44  j["/array/-"_json_pointer] = 55;
    45  // output the changed array
    46  std::cout << j["array"] << '\n';
    47 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    1
     "foo"
     [1,2]
    @@ -303,7 +303,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/operatorjson_pointer.cpp -o operatorjson_pointer 
    Since
    version 2.0.0
    -

    Definition at line 9331 of file json.hpp.

    +

    Definition at line 9335 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_a76347b37f07c75049f5164053a6cf81a.html b/classnlohmann_1_1basic__json_a76347b37f07c75049f5164053a6cf81a.html index c24909d12..d82a4d936 100644 --- a/classnlohmann_1_1basic__json_a76347b37f07c75049f5164053a6cf81a.html +++ b/classnlohmann_1_1basic__json_a76347b37f07c75049f5164053a6cf81a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  const json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j["/number"_json_pointer] << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j["/string"_json_pointer] << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j["/array"_json_pointer] << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j["/array/1"_json_pointer] << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The behavior is shown in the example.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // create a JSON value
    8  const json j =
    9  {
    10  {"number", 1}, {"string", "foo"}, {"array", {1, 2}}
    11  };
    12 
    13  // read-only access
    14 
    15  // output element with JSON pointer "/number"
    16  std::cout << j["/number"_json_pointer] << '\n';
    17  // output element with JSON pointer "/string"
    18  std::cout << j["/string"_json_pointer] << '\n';
    19  // output element with JSON pointer "/array"
    20  std::cout << j["/array"_json_pointer] << '\n';
    21  // output element with JSON pointer "/array/1"
    22  std::cout << j["/array/1"_json_pointer] << '\n';
    23 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    1
     "foo"
     [1,2]
    @@ -294,7 +294,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/operatorjson_pointer_const.cpp -o operatorjson_pointer_const 
    Since
    version 2.0.0
    -

    Definition at line 9358 of file json.hpp.

    +

    Definition at line 9362 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_a7ab11375ed2e29c2fcb6119386851445.html b/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html index 0ac88ff8e..4ebcf79cb 100644 --- a/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html +++ b/classnlohmann_1_1basic__json_a7ab11375ed2e29c2fcb6119386851445.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    17 17 17 17
    @@ -288,7 +288,7 @@ true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr 
    Since
    version 1.0.0
    -

    Definition at line 2891 of file json.hpp.

    +

    Definition at line 2893 of file json.hpp.

    @@ -298,7 +298,7 @@ true diff --git a/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html b/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html index 20b09300d..b4042c1b8 100644 --- a/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html +++ b/classnlohmann_1_1basic__json_a7c3182cfabc0bdd9f3a14216fe0e8154.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -281,7 +281,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:9960
    +
    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:9964
    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 
    @@ -297,7 +297,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_a7c774ef0eceff6d06095f617e2dbd488.html b/classnlohmann_1_1basic__json_a7c774ef0eceff6d06095f617e2dbd488.html index 5a37ef9f9..7b1076b42 100644 --- a/classnlohmann_1_1basic__json_a7c774ef0eceff6d06095f617e2dbd488.html +++ b/classnlohmann_1_1basic__json_a7c774ef0eceff6d06095f617e2dbd488.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is primitive (string, number, boolean, or null), false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    true
     true
     true
    @@ -293,7 +293,7 @@ true
     is_number() – returns whether JSON value is a number
    Since
    version 1.0.0
    -

    Definition at line 2161 of file json.hpp.

    +

    Definition at line 2163 of file json.hpp.

    @@ -303,7 +303,7 @@ true diff --git a/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html b/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html index d038935b7..1ef78b412 100644 --- a/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html +++ b/classnlohmann_1_1basic__json_a7ed92d56cb313b243c1917696ffdf074.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    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
     value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3129 of file json.hpp.

    +

    Definition at line 3131 of file json.hpp.

    @@ -305,7 +305,7 @@ out of range: key 'the fast' not found diff --git a/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html b/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html index c377a4c40..cf9470743 100644 --- a/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html +++ b/classnlohmann_1_1basic__json_a7f7bbb3a9efef2e2442f538a24c1c47b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -296,13 +296,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:9960
    +
    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:9964
    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 4892 of file json.hpp.

    +

    Definition at line 4894 of file json.hpp.

    @@ -312,7 +312,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html index 156f1df8d..775765bba 100644 --- a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html +++ b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964

    Output (play with this example online):

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

    +

    Definition at line 5441 of file json.hpp.

    @@ -307,7 +307,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html b/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html index 91daf5996..99cf1b9fa 100644 --- a/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html +++ b/classnlohmann_1_1basic__json_a8032645ce3109a7a4899badd90fa3480.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -292,7 +292,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 3649 of file json.hpp.

    +

    Definition at line 3651 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_a805e3f3a2f374da0e14942eec7400e40.html b/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html index d87aa68e1..5b826e42a 100644 --- a/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html +++ b/classnlohmann_1_1basic__json_a805e3f3a2f374da0e14942eec7400e40.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,7 +278,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:9960
    +
    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:9964
    Output (play with this example online):
    {"one":1,"two":2}
     
     {"one":1,"two":2}
    @@ -327,7 +327,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 a36193b20..4358789a8 100644 --- a/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html +++ b/classnlohmann_1_1basic__json_a80c21170db6b5ffd9274b3f351cebadc.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -291,7 +291,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 4766 of file json.hpp.

    +

    Definition at line 4768 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html b/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html index 89fe7906a..76d6e3c2c 100644 --- a/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html +++ b/classnlohmann_1_1basic__json_a81aaaab0f3b326afda2d226daab4f1e1.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -291,7 +291,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:9960
    +
    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:9964
    Output (play with this example online):
    [1,2,3,4]
     [1.2,2.3,3.4,5.6]
     [true,true,false,true]
    @@ -315,7 +315,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 bd6de1fee..bd696dc97 100644 --- a/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html +++ b/classnlohmann_1_1basic__json_a8209621de6184d9eabe136b7c8f61935.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -284,14 +284,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:9960
    +
    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:9964
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:394
    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 5129 of file json.hpp.

    +

    Definition at line 5131 of file json.hpp.

    @@ -301,7 +301,7 @@ array = [1,2,3,4] diff --git a/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html b/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html index 9efd5e0de..4cfc807d7 100644 --- a/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html +++ b/classnlohmann_1_1basic__json_a8468efcfcd95db15f46887b29924ed5c.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -296,13 +296,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:9960
    +
    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:9964
    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 4919 of file json.hpp.

    +

    Definition at line 4921 of file json.hpp.

    @@ -312,7 +312,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a848cbae3bd3502ffbf738320bf5eb3aa.html b/classnlohmann_1_1basic__json_a848cbae3bd3502ffbf738320bf5eb3aa.html index 7aec57607..1b6aba87d 100644 --- a/classnlohmann_1_1basic__json_a848cbae3bd3502ffbf738320bf5eb3aa.html +++ b/classnlohmann_1_1basic__json_a848cbae3bd3502ffbf738320bf5eb3aa.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    the type of the JSON value
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    @@ -290,7 +290,7 @@ true The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/type.cpp -o type 
    Since
    version 1.0.0
    -

    Definition at line 2131 of file json.hpp.

    +

    Definition at line 2133 of file json.hpp.

    @@ -300,7 +300,7 @@ true diff --git a/classnlohmann_1_1basic__json_a85b09b03916d3d1e73373f49cdd4136d.html b/classnlohmann_1_1basic__json_a85b09b03916d3d1e73373f49cdd4136d.html index de6d8a192..4091f18e6 100644 --- a/classnlohmann_1_1basic__json_a85b09b03916d3d1e73373f49cdd4136d.html +++ b/classnlohmann_1_1basic__json_a85b09b03916d3d1e73373f49cdd4136d.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -298,7 +298,7 @@ template<typename T , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html b/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html index 42ab64c9b..b5a331ff0 100644 --- a/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html +++ b/classnlohmann_1_1basic__json_a86089c703a2e563b9f760c2f8408efa7.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -284,14 +284,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:9960
    +
    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:9964
    StringType string_t
    a type for a string
    Definition: json.hpp:441
    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 5197 of file json.hpp.

    +

    Definition at line 5199 of file json.hpp.

    @@ -301,7 +301,7 @@ string = the bad diff --git a/classnlohmann_1_1basic__json_a86a477c16dac3bdd4929fee2db394256.html b/classnlohmann_1_1basic__json_a86a477c16dac3bdd4929fee2db394256.html index ed09aac67..c6746ed03 100644 --- a/classnlohmann_1_1basic__json_a86a477c16dac3bdd4929fee2db394256.html +++ b/classnlohmann_1_1basic__json_a86a477c16dac3bdd4929fee2db394256.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    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
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    cend() – returns a const iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4130 of file json.hpp.

    +

    Definition at line 4132 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a87499fdb56ca6f0df2242c3335c3dc9b.html b/classnlohmann_1_1basic__json_a87499fdb56ca6f0df2242c3335c3dc9b.html index 2711ae806..46a1fa9da 100644 --- a/classnlohmann_1_1basic__json_a87499fdb56ca6f0df2242c3335c3dc9b.html +++ b/classnlohmann_1_1basic__json_a87499fdb56ca6f0df2242c3335c3dc9b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is an integer or unsigned integer number, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     true
    @@ -289,7 +289,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 1.0.0
    -

    Definition at line 2291 of file json.hpp.

    +

    Definition at line 2293 of file json.hpp.

    @@ -299,7 +299,7 @@ false diff --git a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html index 3dd670936..82aa39f9f 100644 --- a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html +++ b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    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
    @@ -297,7 +297,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 5591 of file json.hpp.

    +

    Definition at line 5593 of file json.hpp.

    @@ -307,7 +307,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html b/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html index 86be43ccf..4d1067251 100644 --- a/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html +++ b/classnlohmann_1_1basic__json_a8f77085bd98c97a983d9ba12efbf6148.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -299,7 +299,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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    @@ -342,7 +342,7 @@ false
    diff --git a/classnlohmann_1_1basic__json_a8f7e67d903f918cd08261219fb47a9f0.html b/classnlohmann_1_1basic__json_a8f7e67d903f918cd08261219fb47a9f0.html index 57c854e0e..09ff3bd28 100644 --- a/classnlohmann_1_1basic__json_a8f7e67d903f918cd08261219fb47a9f0.html +++ b/classnlohmann_1_1basic__json_a8f7e67d903f918cd08261219fb47a9f0.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is boolean, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     true
     false
    @@ -284,7 +284,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_boolean.cpp -o is_boolean 
    Since
    version 1.0.0
    -

    Definition at line 2232 of file json.hpp.

    +

    Definition at line 2234 of file json.hpp.

    @@ -294,7 +294,7 @@ false diff --git a/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html b/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html index 9ad5b6198..587d222aa 100644 --- a/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html +++ b/classnlohmann_1_1basic__json_a90239431815c94b0a334f7f4c55eb859.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -292,7 +292,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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -308,7 +308,7 @@ false
     
    See also
    size() – returns the number of elements
    Since
    version 1.0.0
    -

    Definition at line 4441 of file json.hpp.

    +

    Definition at line 4443 of file json.hpp.

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

    +

    Definition at line 3313 of file json.hpp.

    @@ -321,7 +321,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 f2a960502..9796b4036 100644 --- a/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html +++ b/classnlohmann_1_1basic__json_a947b5b2a832e490858dbdddfe7085831.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -287,7 +287,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 9ee20bec5..3e1db15c0 100644 --- a/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html +++ b/classnlohmann_1_1basic__json_a9486a272e034c0548305d7a12f3045e6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -291,7 +291,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 4816 of file json.hpp.

    +

    Definition at line 4818 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html index 216a73f99..8428ab5a1 100644 --- a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html +++ b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964

    Output (play with this example online):

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

    +

    Definition at line 5379 of file json.hpp.

    @@ -307,7 +307,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html b/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html index 34b7c5a98..f87814b10 100644 --- a/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html +++ b/classnlohmann_1_1basic__json_a9857835334d38ba04959e348ca6be208.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -288,7 +288,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:9960
    +
    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:9964
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:918
    the parser read a key of a value in an object
    parse_event_t
    JSON callback events.
    Definition: json.hpp:853
    @@ -339,7 +339,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 2f3fa5a13..c5b337cce 100644 --- a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html +++ b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964

    Output (play with this example online):

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

    +

    Definition at line 5388 of file json.hpp.

    @@ -307,7 +307,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html b/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html index 3ff45d1eb..13c3de359 100644 --- a/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html +++ b/classnlohmann_1_1basic__json_a99f2e765029e51dd0fff018650f92eea.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,12 +285,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:9960
    +
    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:9964
    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 3270 of file json.hpp.

    +

    Definition at line 3272 of file json.hpp.

    @@ -300,7 +300,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html b/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html index 889b5b82a..d267f7f9d 100644 --- a/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html +++ b/classnlohmann_1_1basic__json_a9af5ea68c88f423ddf35216aff7f1813.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:348
    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 
    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_a9c9b4932b26a9630e1a3f25ea42a2c43.html b/classnlohmann_1_1basic__json_a9c9b4932b26a9630e1a3f25ea42a2c43.html index 12ad3e734..aaf61a3cf 100644 --- a/classnlohmann_1_1basic__json_a9c9b4932b26a9630e1a3f25ea42a2c43.html +++ b/classnlohmann_1_1basic__json_a9c9b4932b26a9630e1a3f25ea42a2c43.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -284,14 +284,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in the size of the initializer list init.
    Note
    This function is required to resolve an ambiguous overload error, because pairs like {"key", "value"} can be both interpreted as object_t::value_type or std::initializer_list<basic_json>, see https://github.com/nlohmann/json/issues/235 for more information.
    -
    Example
    The example shows how initializer lists are treated as objects when possible.
    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({"three", 3}); // object is extended
    17  object += {"four", 4}; // object is extended
    18  null.push_back({"five", 5}); // null is converted to array
    19 
    20  // print values
    21  std::cout << object << '\n';
    22  std::cout << null << '\n';
    23 
    24  // would throw:
    25  //object.push_back({1, 2, 3});
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The example shows how initializer lists are treated as objects when possible.
    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({"three", 3}); // object is extended
    17  object += {"four", 4}; // object is extended
    18  null.push_back({"five", 5}); // null is converted to array
    19 
    20  // print values
    21  std::cout << object << '\n';
    22  std::cout << null << '\n';
    23 
    24  // would throw:
    25  //object.push_back({1, 2, 3});
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
     [["five",5]]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back__initializer_list.cpp -o push_back__initializer_list 
    -

    Definition at line 4847 of file json.hpp.

    +

    Definition at line 4849 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html b/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html index 035aa20ec..7235860c3 100644 --- a/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html +++ b/classnlohmann_1_1basic__json_a9d1b58099dc64695fcf2847ab0b2a7c7.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,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 7792104e5..4934cc571 100644 --- a/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html +++ b/classnlohmann_1_1basic__json_a9e35475e2027520a78e09f460dbe048a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -302,7 +302,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa0033766b4d3134b9bb57d81762d75a2.html b/classnlohmann_1_1basic__json_aa0033766b4d3134b9bb57d81762d75a2.html index 783b9afd4..eb76242f1 100644 --- a/classnlohmann_1_1basic__json_aa0033766b4d3134b9bb57d81762d75a2.html +++ b/classnlohmann_1_1basic__json_aa0033766b4d3134b9bb57d81762d75a2.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -284,14 +284,14 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Linear in the size of the initializer list init.
    Note
    This function is required to resolve an ambiguous overload error, because pairs like {"key", "value"} can be both interpreted as object_t::value_type or std::initializer_list<basic_json>, see https://github.com/nlohmann/json/issues/235 for more information.
    -
    Example
    The example shows how initializer lists are treated as objects when possible.
    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({"three", 3}); // object is extended
    17  object += {"four", 4}; // object is extended
    18  null.push_back({"five", 5}); // null is converted to array
    19 
    20  // print values
    21  std::cout << object << '\n';
    22  std::cout << null << '\n';
    23 
    24  // would throw:
    25  //object.push_back({1, 2, 3});
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The example shows how initializer lists are treated as objects when possible.
    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({"three", 3}); // object is extended
    17  object += {"four", 4}; // object is extended
    18  null.push_back({"five", 5}); // null is converted to array
    19 
    20  // print values
    21  std::cout << object << '\n';
    22  std::cout << null << '\n';
    23 
    24  // would throw:
    25  //object.push_back({1, 2, 3});
    26 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
     [["five",5]]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/push_back__initializer_list.cpp -o push_back__initializer_list 
    -

    Definition at line 4864 of file json.hpp.

    +

    Definition at line 4866 of file json.hpp.

    @@ -301,7 +301,7 @@ null diff --git a/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html b/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html index 9eb91adc5..5faab6863 100644 --- a/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html +++ b/classnlohmann_1_1basic__json_aa36e72ffc3241b960fe9186d19e03bc3.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    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 
    @@ -296,7 +296,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 3946 of file json.hpp.

    +

    Definition at line 3948 of file json.hpp.

    @@ -306,7 +306,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa41e1083435cf317a253947eb1ff318d.html b/classnlohmann_1_1basic__json_aa41e1083435cf317a253947eb1ff318d.html index 27483d08d..6e9a88666 100644 --- a/classnlohmann_1_1basic__json_aa41e1083435cf317a253947eb1ff318d.html +++ b/classnlohmann_1_1basic__json_aa41e1083435cf317a253947eb1ff318d.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -287,7 +287,7 @@ not found"
    Complexity
    Linear in the size of the JSON value and the length of the JSON patch. As usually only a fraction of the JSON value is affected by the patch, the complexity can usually be neglected.
    -
    Example
    The following code shows how a JSON patch is applied to a value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // the original document
    8  json doc = R"(
    9  {
    10  "baz": "qux",
    11  "foo": "bar"
    12  }
    13  )"_json;
    14 
    15  // the patch
    16  json patch = R"(
    17  [
    18  { "op": "replace", "path": "/baz", "value": "boo" },
    19  { "op": "add", "path": "/hello", "value": ["world"] },
    20  { "op": "remove", "path": "/foo"}
    21  ]
    22  )"_json;
    23 
    24  // apply the patch
    25  json patched_doc = doc.patch(patch);
    26 
    27  // output original and patched document
    28  std::cout << std::setw(4) << doc << "\n\n"
    29  << std::setw(4) << patched_doc << std::endl;
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    Example
    The following code shows how a JSON patch is applied to a value.
    1 #include <json.hpp>
    2 
    3 using json = nlohmann::json;
    4 
    5 int main()
    6 {
    7  // the original document
    8  json doc = R"(
    9  {
    10  "baz": "qux",
    11  "foo": "bar"
    12  }
    13  )"_json;
    14 
    15  // the patch
    16  json patch = R"(
    17  [
    18  { "op": "replace", "path": "/baz", "value": "boo" },
    19  { "op": "add", "path": "/hello", "value": ["world"] },
    20  { "op": "remove", "path": "/foo"}
    21  ]
    22  )"_json;
    23 
    24  // apply the patch
    25  json patched_doc = doc.patch(patch);
    26 
    27  // output original and patched document
    28  std::cout << std::setw(4) << doc << "\n\n"
    29  << std::setw(4) << patched_doc << std::endl;
    30 }
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    {
         "baz": "qux",
         "foo": "bar"
    @@ -307,7 +307,7 @@ not found" 
     RFC 6901 (JSON Pointer)
    Since
    version 2.0.0
    -

    Definition at line 9519 of file json.hpp.

    +

    Definition at line 9523 of file json.hpp.

    @@ -317,7 +317,7 @@ not found" diff --git a/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html b/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html index 356338d22..0512ec33e 100644 --- a/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html +++ b/classnlohmann_1_1basic__json_aa44ce84b9ac506b905b8fb56c9a0989d.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,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 93cea53a8..e6ce1c648 100644 --- a/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html +++ b/classnlohmann_1_1basic__json_aa45753034bea87f9d2c0c42ace9ff75c.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    object (unordered set of name/value pairs)
    array (ordered collection of values)
    Output (play with this example online):
    true
    @@ -292,7 +292,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 3641 of file json.hpp.

    +

    Definition at line 3643 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_aa669d997ddc03566de5438781254b32b.html b/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html index cb2754598..68ceade03 100644 --- a/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html +++ b/classnlohmann_1_1basic__json_aa669d997ddc03566de5438781254b32b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    17 17
    @@ -294,7 +294,7 @@ incompatible ReferenceType for get_ref, actual type is number
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ref.cpp -o get_ref 
    Since
    version 1.1.0
    -

    Definition at line 2957 of file json.hpp.

    +

    Definition at line 2959 of file json.hpp.

    @@ -304,7 +304,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 ca81c514d..28c8be5be 100644 --- a/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html +++ b/classnlohmann_1_1basic__json_aa6fd72df1ce9f80e61012784c598456e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -288,7 +288,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:9960
    +
    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:9964
    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
    @@ -296,7 +296,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.1.0
    -

    Definition at line 3519 of file json.hpp.

    +

    Definition at line 3521 of file json.hpp.

    @@ -306,7 +306,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_aa7205e1926d3aea98adeced91b0ff5fb.html b/classnlohmann_1_1basic__json_aa7205e1926d3aea98adeced91b0ff5fb.html index 9e2c3eb42..d8446f559 100644 --- a/classnlohmann_1_1basic__json_aa7205e1926d3aea98adeced91b0ff5fb.html +++ b/classnlohmann_1_1basic__json_aa7205e1926d3aea98adeced91b0ff5fb.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    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
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    cend() – returns a const iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4160 of file json.hpp.

    +

    Definition at line 4162 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_aaa160a960dd3dd90856a72b1d8dbe707.html b/classnlohmann_1_1basic__json_aaa160a960dd3dd90856a72b1d8dbe707.html index b0517c6ea..2a0d43898 100644 --- a/classnlohmann_1_1basic__json_aaa160a960dd3dd90856a72b1d8dbe707.html +++ b/classnlohmann_1_1basic__json_aaa160a960dd3dd90856a72b1d8dbe707.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    json_reverse_iterator< typename basic_json::iterator > reverse_iterator
    a reverse iterator for a basic_json container
    Definition: json.hpp:238
    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 
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    crbegin() – returns a const reverse iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4298 of file json.hpp.

    +

    Definition at line 4300 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html b/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html index 5520e5e2b..0a6f04f10 100644 --- a/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html +++ b/classnlohmann_1_1basic__json_aaa687595d7627925fbf6d6eb97e2021e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,14 +278,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:9960
    +
    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:9964
    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 4048 of file json.hpp.

    +

    Definition at line 4050 of file json.hpp.

    @@ -295,7 +295,7 @@ value at key "two": 2 diff --git a/classnlohmann_1_1basic__json_aac36af84d907b5c3e469af889661620a.html b/classnlohmann_1_1basic__json_aac36af84d907b5c3e469af889661620a.html index 4f3d524b7..de9fd5e78 100644 --- a/classnlohmann_1_1basic__json_aac36af84d907b5c3e469af889661620a.html +++ b/classnlohmann_1_1basic__json_aac36af84d907b5c3e469af889661620a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -277,7 +277,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:9960
    +
    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:9964
    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 
    @@ -293,7 +293,7 @@ false
    diff --git a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html index 07227e618..19713fd98 100644 --- a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html +++ b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -293,7 +293,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:9960
    +
    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:9964
    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
    @@ -301,7 +301,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 5468 of file json.hpp.

    +

    Definition at line 5470 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_aad65e0bc388897192bf361c24c1d6dda.html b/classnlohmann_1_1basic__json_aad65e0bc388897192bf361c24c1d6dda.html index ee7caa03c..cb2edb2f6 100644 --- a/classnlohmann_1_1basic__json_aad65e0bc388897192bf361c24c1d6dda.html +++ b/classnlohmann_1_1basic__json_aad65e0bc388897192bf361c24c1d6dda.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    17 17 17 17
    @@ -288,7 +288,7 @@ true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr 
    Since
    version 1.0.0
    -

    Definition at line 2906 of file json.hpp.

    +

    Definition at line 2908 of file json.hpp.

    @@ -298,7 +298,7 @@ true diff --git a/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html b/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html index 4035fa9f9..f957a7dc7 100644 --- a/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html +++ b/classnlohmann_1_1basic__json_aadb4e5be88221e5e28cdb752332f3d13.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -296,13 +296,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:9960
    +
    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:9964
    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 5060 of file json.hpp.

    +

    Definition at line 5062 of file json.hpp.

    @@ -312,7 +312,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aae7eb3b91d7f68e86396c5c6b683445f.html b/classnlohmann_1_1basic__json_aae7eb3b91d7f68e86396c5c6b683445f.html index 0a1459332..15fdf7e3c 100644 --- a/classnlohmann_1_1basic__json_aae7eb3b91d7f68e86396c5c6b683445f.html +++ b/classnlohmann_1_1basic__json_aae7eb3b91d7f68e86396c5c6b683445f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
    a const reverse iterator for a basic_json container
    Definition: json.hpp:240
    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 
    @@ -290,7 +290,7 @@ Illustration from cppreference.com
    crbegin() – returns a const reverse iterator to the beginning
    Since
    version 1.0.0
    -

    Definition at line 4364 of file json.hpp.

    +

    Definition at line 4366 of file json.hpp.

    @@ -300,7 +300,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html index ed8b131a2..36c719fb8 100644 --- a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html +++ b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -295,7 +295,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:9960
    +
    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:9964
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -313,7 +313,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 5782 of file json.hpp.

    +

    Definition at line 5789 of file json.hpp.

    @@ -323,7 +323,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 601803936..c7791cfdf 100644 --- a/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html +++ b/classnlohmann_1_1basic__json_ab00b882d39306d663c23dab110f5cae0.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -290,7 +290,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab22c8d61eca51f0308c263487bd35f03.html b/classnlohmann_1_1basic__json_ab22c8d61eca51f0308c263487bd35f03.html index c1002e11b..58762be86 100644 --- a/classnlohmann_1_1basic__json_ab22c8d61eca51f0308c263487bd35f03.html +++ b/classnlohmann_1_1basic__json_ab22c8d61eca51f0308c263487bd35f03.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Returns
    true if type is string, false otherwise.
    Complexity
    Constant.
    Exception safety
    No-throw guarantee: this member function never throws exceptions.
    -
    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:9960
    +
    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:9964
    Output (play with this example online):
    false
     false
     false
    @@ -284,7 +284,7 @@ true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_string.cpp -o is_string 
    Since
    version 1.0.0
    -

    Definition at line 2413 of file json.hpp.

    +

    Definition at line 2415 of file json.hpp.

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

    Definition at line 3081 of file json.hpp.

    +

    Definition at line 3083 of file json.hpp.

    @@ -301,7 +301,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html b/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html index fc33237ca..b2ef1e939 100644 --- a/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html +++ b/classnlohmann_1_1basic__json_ab63e618bbb0371042b1bec17f5891f42.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -288,7 +288,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html b/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html index 198ad5db6..cfd90be52 100644 --- a/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html +++ b/classnlohmann_1_1basic__json_ab7be2bc58ae0c2c2c30d40f15d6399f8.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -291,7 +291,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:9960
    +
    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:9964
    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}
    @@ -310,7 +310,7 @@ template<class CompatibleObjectType , typename std::enable_if<
     
    diff --git a/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html b/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html index 114ee2920..719cdb42f 100644 --- a/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html +++ b/classnlohmann_1_1basic__json_ab81f2801779e6cb9d98770860af2e39a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,8 +289,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:9960
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5707
    +
    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:9964
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5714
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:918
    the parser read a key of a value in an object
    parse_event_t
    JSON callback events.
    Definition: json.hpp:853
    @@ -332,7 +332,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 5744 of file json.hpp.

    +

    Definition at line 5751 of file json.hpp.

    @@ -342,7 +342,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html b/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html index 900e88c25..7b1cab748 100644 --- a/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html +++ b/classnlohmann_1_1basic__json_ab8b43d92a042dde96c28aeea81dd52de.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -283,7 +283,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:9960
    +
    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:9964
    StringType string_t
    a type for a string
    Definition: json.hpp:441
    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 
    @@ -302,7 +302,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 014c7aa0c..a53463770 100644 --- a/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html +++ b/classnlohmann_1_1basic__json_ab936779c70bec68343ef440ed13251e5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,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 4385 of file json.hpp.

    +

    Definition at line 4387 of file json.hpp.

    @@ -282,7 +282,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html b/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html index 0521f2e0e..6d66e12ab 100644 --- a/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html +++ b/classnlohmann_1_1basic__json_ac4b10b2364f26ce47bdb9a413ff04a59.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -295,7 +295,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 dddbdcaf6..4459f1e3e 100644 --- a/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html +++ b/classnlohmann_1_1basic__json_ac5693cff1df0775cd3fbe960412cde4b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -280,7 +280,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:9960
    +
    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:9964
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    Output (play with this example online):
    17 17 17 17
    @@ -289,7 +289,7 @@ true
     
    See also
    get_ptr() for explicit pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2842 of file json.hpp.

    +

    Definition at line 2844 of file json.hpp.

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

    Definition at line 3470 of file json.hpp.

    +

    Definition at line 3472 of file json.hpp.

    @@ -323,7 +323,7 @@ template<typename T > diff --git a/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html b/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html index 65b6d9208..4044377fb 100644 --- a/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html +++ b/classnlohmann_1_1basic__json_ac8d45b57874b4a6e9c07f7d3b5daa1f9.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html b/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html index fc603494f..ea5f97cf8 100644 --- a/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html +++ b/classnlohmann_1_1basic__json_ad25b2f8c21e241e2d63455537a9294ff.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -286,7 +286,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:1685
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:9960
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:9964
    Output (play with this example online):
    {}
     {}
     {"one":1,"two":2}
    @@ -306,7 +306,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 091ee0dd9..4aa3db8b9 100644
    --- a/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html
    +++ b/classnlohmann_1_1basic__json_ad2eddc2c13ab084f067eaba65d381ad2.html
    @@ -25,7 +25,7 @@
      
       
        
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    Output (play with this example online):
    42
     23
     1024
    @@ -307,7 +307,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if<
     
    diff --git a/classnlohmann_1_1basic__json_ad4e381c54039607be08d7af41a1f6ad1.html b/classnlohmann_1_1basic__json_ad4e381c54039607be08d7af41a1f6ad1.html index 41b2b1040..b3c28d3ba 100644 --- a/classnlohmann_1_1basic__json_ad4e381c54039607be08d7af41a1f6ad1.html +++ b/classnlohmann_1_1basic__json_ad4e381c54039607be08d7af41a1f6ad1.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -279,7 +279,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:9960
    +
    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:9964
    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
    @@ -289,7 +289,7 @@ Illustration from cppreference.com
    cend() – returns a const iterator to the end
    Since
    version 1.0.0
    -

    Definition at line 4120 of file json.hpp.

    +

    Definition at line 4122 of file json.hpp.

    @@ -299,7 +299,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html b/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html index f3bb683f4..19a1fe409 100644 --- a/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html +++ b/classnlohmann_1_1basic__json_ad5514a7435f246fc5335856465022a7a.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -292,7 +292,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:9960
    +
    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:9964
    Output (play with this example online):
    0
     1
     1
    @@ -304,7 +304,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 4571 of file json.hpp.

    +

    Definition at line 4573 of file json.hpp.

    @@ -314,7 +314,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 12b44afc9..339e25317 100644 --- a/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html +++ b/classnlohmann_1_1basic__json_ad6e51670e9c0052856f3fee01df5c44f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -287,7 +287,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:9960
    +
    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:9964
    Output (play with this example online):
    null
     false
     0
    @@ -298,7 +298,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 4630 of file json.hpp.

    +

    Definition at line 4632 of file json.hpp.

    @@ -308,7 +308,7 @@ false diff --git a/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html b/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html index 39f5f555b..f0b9a96ab 100644 --- a/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html +++ b/classnlohmann_1_1basic__json_ad9cd312208273fb3fb2adf1f6d8d34ae.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964
    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
    @@ -297,7 +297,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3437 of file json.hpp.

    +

    Definition at line 3439 of file json.hpp.

    @@ -307,7 +307,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html b/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html index c461e5cb5..6a0e20d3e 100644 --- a/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html +++ b/classnlohmann_1_1basic__json_ade0e56c8c320d7f342e7a5697e6d6f7e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,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.
    Exception safety
    No-throw guarantee: this constructor never throws exceptions.
    -
    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:9960
    +
    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:9964
    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)
    @@ -288,7 +288,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    diff --git a/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html b/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html index 461637773..6c4514bcd 100644 --- a/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html +++ b/classnlohmann_1_1basic__json_ae336fff01f4b78e3e16e5008dc8dbc00.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,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 cc1800135..de5c2e495 100644 --- a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html +++ b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -289,7 +289,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:9960
    +
    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:9964

    Output (play with this example online):

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

    +

    Definition at line 5432 of file json.hpp.

    @@ -307,7 +307,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html b/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html index eacd51a7f..7671ed4d7 100644 --- a/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html +++ b/classnlohmann_1_1basic__json_ae85d91b0620650bcd9993e09d0e287d9.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -291,7 +291,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:9960
    +
    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:9964
    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
    @@ -309,7 +309,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 2a6c6e12a..ffdde158f 100644 --- a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html +++ b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -298,7 +298,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 11be49621..74487a51a 100644 --- a/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html +++ b/classnlohmann_1_1basic__json_aeaa0644fd6b99af364e772092268dfd6.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -306,13 +306,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:9960
    +
    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:9964
    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 5001 of file json.hpp.

    +

    Definition at line 5003 of file json.hpp.

    @@ -322,7 +322,7 @@ belong to container" diff --git a/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html b/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html index 01fa8736d..d2abe07bf 100644 --- a/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html +++ b/classnlohmann_1_1basic__json_aec316934a555dd1acdd3600e5d4a4cdf.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,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 2b12e916c..b78ed7ab4 100644 --- a/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html +++ b/classnlohmann_1_1basic__json_aef496a56163710084e13612ab73e6ed2.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -285,7 +285,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:9960
    +
    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:9964
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -300,7 +300,7 @@ array: [1,2,3,4,5]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__ValueType.cpp -o operator__ValueType 
    Since
    version 1.0.0
    -

    Definition at line 2999 of file json.hpp.

    +

    Definition at line 3001 of file json.hpp.

    @@ -310,7 +310,7 @@ array: [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html b/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html index 457024342..bd7e79b28 100644 --- a/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html +++ b/classnlohmann_1_1basic__json_af071057ebab57744f5767eb369e99d42.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -305,7 +305,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:9960
    +
    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:9964
    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
    @@ -313,7 +313,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3612 of file json.hpp.

    +

    Definition at line 3614 of file json.hpp.

    @@ -323,7 +323,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html b/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html index 51a62c53a..28bb6f280 100644 --- a/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html +++ b/classnlohmann_1_1basic__json_af148cdab12df5bf86119fac735ccaac5.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -272,7 +272,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 4393 of file json.hpp.

    +

    Definition at line 4395 of file json.hpp.

    @@ -282,7 +282,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 cccb16742..5274cd3e2 100644 --- a/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html +++ b/classnlohmann_1_1basic__json_af3bc3e83aa162d7ba4df16a949872723.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -275,7 +275,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 7ccba1c6d..8843ab9c9 100644 --- a/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html +++ b/classnlohmann_1_1basic__json_af677a29b0e66edc9f66e5167e4667071.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -268,7 +268,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 a5bd7b3ed..7ad77ac9f 100644 --- a/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html +++ b/classnlohmann_1_1basic__json_af77614992e38b355b9213940051cc582.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -277,13 +277,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:9960
    +
    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:9964
    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 5098 of file json.hpp.

    +

    Definition at line 5100 of file json.hpp.

    @@ -293,7 +293,7 @@ j2 = [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html b/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html index cbaf6beb8..84cac355b 100644 --- a/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html +++ b/classnlohmann_1_1basic__json_af7acf3838a79363356f24538941a559c.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -310,7 +310,7 @@ use 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:9960
    +
    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:9964
    Output (play with this example online):
    ["bravo","charly"]
     42
     {"one":"eins"}
    @@ -327,7 +327,7 @@ use construct with iterators from null"
     
    diff --git a/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html b/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html index 42bc9bbc5..697e3db90 100644 --- a/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html +++ b/classnlohmann_1_1basic__json_afeb998aec45296bc2050bd1c41ef41eb.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -319,7 +319,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:9960
    +
    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:9964
    Output (play with this example online):
    {}
     {"one":1,"two":2}
     [1,2,3,4]
    @@ -341,7 +341,7 @@ initializer list"
     
    diff --git a/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html b/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html index 44fcd426d..f28fdeb9c 100644 --- a/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html +++ b/classnlohmann_1_1basic__json_affe7e160e7bb06eed83c8b437af4692f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -278,14 +278,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:9960
    +
    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:9964
    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 4031 of file json.hpp.

    +

    Definition at line 4033 of file json.hpp.

    @@ -295,7 +295,7 @@ value at key "two": 2 diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 46df6ef9a..4831a5a17 100644 --- a/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -92,7 +92,7 @@ Files diff --git a/functions.html b/functions.html index e67b2028b..47214b462 100644 --- a/functions.html +++ b/functions.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_0x7e.html b/functions_0x7e.html index da253e652..a927e9e22 100644 --- a/functions_0x7e.html +++ b/functions_0x7e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_b.html b/functions_b.html index 514d8af83..5276738d0 100644 --- a/functions_b.html +++ b/functions_b.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -141,7 +141,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_c.html b/functions_c.html index 6080d244c..28fe3f8c0 100644 --- a/functions_c.html +++ b/functions_c.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -153,7 +153,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_d.html b/functions_d.html index ae579bd67..22b048a94 100644 --- a/functions_d.html +++ b/functions_d.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -133,7 +133,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_e.html b/functions_e.html index 81ad5b507..0e41cc98a 100644 --- a/functions_e.html +++ b/functions_e.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_enum.html b/functions_enum.html index ec2c29752..9c2a4daa2 100644 --- a/functions_enum.html +++ b/functions_enum.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_f.html b/functions_f.html index 2a743f2a6..47617d31e 100644 --- a/functions_f.html +++ b/functions_f.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func.html b/functions_func.html index 60e6c4895..35aee88cc 100644 --- a/functions_func.html +++ b/functions_func.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -445,7 +445,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_g.html b/functions_g.html index 385f13f04..ed066bd9a 100644 --- a/functions_g.html +++ b/functions_g.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_i.html b/functions_i.html index 8ddc93c76..c55b00598 100644 --- a/functions_i.html +++ b/functions_i.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -171,7 +171,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_j.html b/functions_j.html index 85728f473..cbf4b7c45 100644 --- a/functions_j.html +++ b/functions_j.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -129,7 +129,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_k.html b/functions_k.html index 381d2b8b6..00b376be5 100644 --- a/functions_k.html +++ b/functions_k.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -127,7 +127,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_m.html b/functions_m.html index 14a43d297..489119795 100644 --- a/functions_m.html +++ b/functions_m.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_n.html b/functions_n.html index 84687d581..902aea722 100644 --- a/functions_n.html +++ b/functions_n.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_o.html b/functions_o.html index 066fd545a..e22adbf93 100644 --- a/functions_o.html +++ b/functions_o.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -220,7 +220,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_p.html b/functions_p.html index 79ae51cfe..72e31f820 100644 --- a/functions_p.html +++ b/functions_p.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -143,7 +143,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_r.html b/functions_r.html index 74c2d3a4f..92fd8b1ee 100644 --- a/functions_r.html +++ b/functions_r.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -138,7 +138,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_rela.html b/functions_rela.html index 919319c88..f2354851b 100644 --- a/functions_rela.html +++ b/functions_rela.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_s.html b/functions_s.html index 1e9524eb0..061c572a5 100644 --- a/functions_s.html +++ b/functions_s.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_t.html b/functions_t.html index 645cd1b0d..38b3d5cd3 100644 --- a/functions_t.html +++ b/functions_t.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -129,7 +129,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_type.html b/functions_type.html index 84747c8d2..882b215b6 100644 --- a/functions_type.html +++ b/functions_type.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -165,7 +165,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_u.html b/functions_u.html index fd0822172..51631aa9d 100644 --- a/functions_u.html +++ b/functions_u.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_v.html b/functions_v.html index a36746f61..022125572 100644 --- a/functions_v.html +++ b/functions_v.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -136,7 +136,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/graph_legend.html b/graph_legend.html index 98dc519a9..13f46ee3c 100644 --- a/graph_legend.html +++ b/graph_legend.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -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 4f5662e5b..4d0ff268c 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/index.html b/index.html index 594e76dbe..8a6828571 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -179,7 +179,7 @@ access at diff --git a/index_8md_source.html b/index_8md_source.html index 6863a6178..e8fcf14c2 100644 --- a/index_8md_source.html +++ b/index_8md_source.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    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 8dee196c0..e75420a31 100644 --- a/json_8hpp_source.html +++ b/json_8hpp_source.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -83,224 +83,224 @@ 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 Licensed under the MIT License <http://opensource.org/licenses/MIT>.
    8 Copyright (c) 2013-2016 Niels Lohmann <http://nlohmann.me>.
    9 
    10 Permission is hereby granted, free of charge, to any person obtaining a copy
    11 of this software and associated documentation files (the "Software"), to deal
    12 in the Software without restriction, including without limitation the rights
    13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    14 copies of the Software, and to permit persons to whom the Software is
    15 furnished to do so, subject to the following conditions:
    16 
    17 The above copyright notice and this permission notice shall be included in all
    18 copies or substantial portions of the Software.
    19 
    20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    26 SOFTWARE.
    27 */
    28 
    29 #ifndef NLOHMANN_JSON_HPP
    30 #define NLOHMANN_JSON_HPP
    31 
    32 #include <algorithm>
    33 #include <array>
    34 #include <cassert>
    35 #include <cerrno>
    36 #include <ciso646>
    37 #include <cmath>
    38 #include <cstddef>
    39 #include <cstdio>
    40 #include <cstdlib>
    41 #include <functional>
    42 #include <initializer_list>
    43 #include <iomanip>
    44 #include <iostream>
    45 #include <iterator>
    46 #include <limits>
    47 #include <map>
    48 #include <memory>
    49 #include <sstream>
    50 #include <stdexcept>
    51 #include <string>
    52 #include <type_traits>
    53 #include <utility>
    54 #include <vector>
    55 
    56 // disable float-equal warnings on GCC/clang
    57 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    58  #pragma GCC diagnostic push
    59  #pragma GCC diagnostic ignored "-Wfloat-equal"
    60 #endif
    61 
    67 namespace nlohmann
    68 {
    69 
    70 
    75 namespace
    76 {
    81 template<typename T>
    82 struct has_mapped_type
    83 {
    84  private:
    85  template<typename C> static char test(typename C::mapped_type*);
    86  template<typename C> static char (&test(...))[2];
    87  public:
    88  static constexpr bool value = sizeof(test<T>(0)) == 1;
    89 };
    90 
    95 class DecimalSeparator : public std::numpunct<char>
    96 {
    97  protected:
    98  char do_decimal_point() const
    99  {
    100  return '.';
    101  }
    102 };
    103 
    104 }
    105 
    177 template <
    178  template<typename U, typename V, typename... Args> class ObjectType = std::map,
    179  template<typename U, typename... Args> class ArrayType = std::vector,
    180  class StringType = std::string,
    181  class BooleanType = bool,
    182  class NumberIntegerType = std::int64_t,
    183  class NumberUnsignedType = std::uint64_t,
    184  class NumberFloatType = double,
    185  template<typename U> class AllocatorType = std::allocator
    186  >
    188 {
    189  private:
    191  using basic_json_t = basic_json<ObjectType,
    192  ArrayType,
    193  StringType,
    194  BooleanType,
    195  NumberIntegerType,
    196  NumberUnsignedType,
    197  NumberFloatType,
    198  AllocatorType>;
    199 
    200  public:
    201  // forward declarations
    202  template<typename Base> class json_reverse_iterator;
    203  class json_pointer;
    204 
    206  // container types //
    208 
    211 
    214 
    218  using const_reference = const value_type&;
    219 
    221  using difference_type = std::ptrdiff_t;
    223  using size_type = std::size_t;
    224 
    226  using allocator_type = AllocatorType<basic_json>;
    227 
    229  using pointer = typename std::allocator_traits<allocator_type>::pointer;
    231  using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
    232 
    234  class iterator;
    236  class const_iterator;
    241 
    243 
    244 
    249  {
    250  return allocator_type();
    251  }
    252 
    253 
    255  // JSON value data types //
    257 
    260 
    344  using object_t = ObjectType<StringType,
    345  basic_json,
    346  std::less<StringType>,
    347  AllocatorType<std::pair<const StringType,
    348  basic_json>>>;
    349 
    394  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
    395 
    441  using string_t = StringType;
    442 
    467  using boolean_t = BooleanType;
    468 
    539  using number_integer_t = NumberIntegerType;
    540 
    611  using number_unsigned_t = NumberUnsignedType;
    612 
    679  using number_float_t = NumberFloatType;
    680 
    682 
    683 
    685  // JSON type enumeration //
    687 
    698  enum class value_t : uint8_t
    699  {
    700  null,
    701  object,
    702  array,
    703  string,
    704  boolean,
    705  number_integer,
    706  number_unsigned,
    707  number_float,
    708  discarded
    709  };
    710 
    711 
    712  private:
    713 
    715  template<typename T, typename... Args>
    716  static T* create(Args&& ... args)
    717  {
    718  AllocatorType<T> alloc;
    719  auto deleter = [&](T * object)
    720  {
    721  alloc.deallocate(object, 1);
    722  };
    723  std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
    724  alloc.construct(object.get(), std::forward<Args>(args)...);
    725  return object.release();
    726  }
    727 
    729  // JSON value storage //
    731 
    739  union json_value
    740  {
    742  object_t* object;
    744  array_t* array;
    746  string_t* string;
    748  boolean_t boolean;
    750  number_integer_t number_integer;
    752  number_unsigned_t number_unsigned;
    754  number_float_t number_float;
    755 
    757  json_value() = default;
    759  json_value(boolean_t v) noexcept : boolean(v) {}
    761  json_value(number_integer_t v) noexcept : number_integer(v) {}
    763  json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
    765  json_value(number_float_t v) noexcept : number_float(v) {}
    767  json_value(value_t t)
    768  {
    769  switch (t)
    770  {
    771  case value_t::object:
    772  {
    773  object = create<object_t>();
    774  break;
    775  }
    776 
    777  case value_t::array:
    778  {
    779  array = create<array_t>();
    780  break;
    781  }
    782 
    783  case value_t::string:
    784  {
    785  string = create<string_t>("");
    786  break;
    787  }
    788 
    789  case value_t::boolean:
    790  {
    791  boolean = boolean_t(false);
    792  break;
    793  }
    794 
    795  case value_t::number_integer:
    796  {
    797  number_integer = number_integer_t(0);
    798  break;
    799  }
    800 
    801  case value_t::number_unsigned:
    802  {
    803  number_unsigned = number_unsigned_t(0);
    804  break;
    805  }
    806 
    807  case value_t::number_float:
    808  {
    809  number_float = number_float_t(0.0);
    810  break;
    811  }
    812 
    813  default:
    814  {
    815  break;
    816  }
    817  }
    818  }
    819 
    821  json_value(const string_t& value)
    822  {
    823  string = create<string_t>(value);
    824  }
    825 
    827  json_value(const object_t& value)
    828  {
    829  object = create<object_t>(value);
    830  }
    831 
    833  json_value(const array_t& value)
    834  {
    835  array = create<array_t>(value);
    836  }
    837  };
    838 
    839 
    840  public:
    842  // JSON parser callback //
    844 
    853  enum class parse_event_t : uint8_t
    854  {
    856  object_start,
    858  object_end,
    860  array_start,
    862  array_end,
    864  key,
    866  value
    867  };
    868 
    918  using parser_callback_t = std::function<bool(int depth, parse_event_t event, basic_json& parsed)>;
    919 
    920 
    922  // constructors //
    924 
    927 
    968  : m_type(value_type), m_value(value_type)
    969  {}
    970 
    995  basic_json() = default;
    996 
    1019  basic_json(std::nullptr_t) noexcept
    1020  : basic_json(value_t::null)
    1021  {}
    1022 
    1042  basic_json(const object_t& val)
    1043  : m_type(value_t::object), m_value(val)
    1044  {}
    1045 
    1072  template <class CompatibleObjectType, typename
    1073  std::enable_if<
    1074  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    1075  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    1076  = 0>
    1077  basic_json(const CompatibleObjectType& val)
    1078  : m_type(value_t::object)
    1079  {
    1080  using std::begin;
    1081  using std::end;
    1082  m_value.object = create<object_t>(begin(val), end(val));
    1083  }
    1084 
    1104  basic_json(const array_t& val)
    1105  : m_type(value_t::array), m_value(val)
    1106  {}
    1107 
    1134  template <class CompatibleArrayType, typename
    1135  std::enable_if<
    1136  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1137  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1138  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1139  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1140  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1141  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1142  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1143  = 0>
    1144  basic_json(const CompatibleArrayType& val)
    1145  : m_type(value_t::array)
    1146  {
    1147  using std::begin;
    1148  using std::end;
    1149  m_value.array = create<array_t>(begin(val), end(val));
    1150  }
    1151 
    1173  basic_json(const string_t& val)
    1174  : m_type(value_t::string), m_value(val)
    1175  {}
    1176 
    1197  basic_json(const typename string_t::value_type* val)
    1198  : basic_json(string_t(val))
    1199  {}
    1200 
    1224  template <class CompatibleStringType, typename
    1225  std::enable_if<
    1226  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1227  = 0>
    1228  basic_json(const CompatibleStringType& val)
    1229  : basic_json(string_t(val))
    1230  {}
    1231 
    1246  basic_json(boolean_t val) noexcept
    1247  : m_type(value_t::boolean), m_value(val)
    1248  {}
    1249 
    1273  template<typename T,
    1274  typename std::enable_if<
    1275  not (std::is_same<T, int>::value)
    1276  and std::is_same<T, number_integer_t>::value
    1277  , int>::type
    1278  = 0>
    1279  basic_json(const number_integer_t val) noexcept
    1280  : m_type(value_t::number_integer), m_value(val)
    1281  {}
    1282 
    1308  basic_json(const int val) noexcept
    1309  : m_type(value_t::number_integer),
    1310  m_value(static_cast<number_integer_t>(val))
    1311  {}
    1312 
    1338  template<typename CompatibleNumberIntegerType, typename
    1339  std::enable_if<
    1340  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1341  std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
    1342  std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
    1343  CompatibleNumberIntegerType>::type
    1344  = 0>
    1345  basic_json(const CompatibleNumberIntegerType val) noexcept
    1346  : m_type(value_t::number_integer),
    1347  m_value(static_cast<number_integer_t>(val))
    1348  {}
    1349 
    1367  template<typename T,
    1368  typename std::enable_if<
    1369  not (std::is_same<T, int>::value)
    1370  and std::is_same<T, number_unsigned_t>::value
    1371  , int>::type
    1372  = 0>
    1373  basic_json(const number_unsigned_t val) noexcept
    1374  : m_type(value_t::number_unsigned), m_value(val)
    1375  {}
    1376 
    1397  template <typename CompatibleNumberUnsignedType, typename
    1398  std::enable_if <
    1399  std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
    1400  std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
    1401  not std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
    1402  CompatibleNumberUnsignedType>::type
    1403  = 0>
    1404  basic_json(const CompatibleNumberUnsignedType val) noexcept
    1405  : m_type(value_t::number_unsigned),
    1406  m_value(static_cast<number_unsigned_t>(val))
    1407  {}
    1408 
    1433  basic_json(const number_float_t val) noexcept
    1434  : m_type(value_t::number_float), m_value(val)
    1435  {
    1436  // replace infinity and NAN by null
    1437  if (not std::isfinite(val))
    1438  {
    1439  m_type = value_t::null;
    1440  m_value = json_value();
    1441  }
    1442  }
    1443 
    1475  template<typename CompatibleNumberFloatType, typename = typename
    1476  std::enable_if<
    1477  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1478  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1479  >
    1480  basic_json(const CompatibleNumberFloatType val) noexcept
    1481  : basic_json(number_float_t(val))
    1482  {}
    1483 
    1553  basic_json(std::initializer_list<basic_json> init,
    1554  bool type_deduction = true,
    1555  value_t manual_type = value_t::array)
    1556  {
    1557  // the initializer list could describe an object
    1558  bool is_an_object = true;
    1559 
    1560  // check if each element is an array with two elements whose first
    1561  // element is a string
    1562  for (const auto& element : init)
    1563  {
    1564  if (not element.is_array() or element.size() != 2
    1565  or not element[0].is_string())
    1566  {
    1567  // we found an element that makes it impossible to use the
    1568  // initializer list as object
    1569  is_an_object = false;
    1570  break;
    1571  }
    1572  }
    1573 
    1574  // adjust type if type deduction is not wanted
    1575  if (not type_deduction)
    1576  {
    1577  // if array is wanted, do not create an object though possible
    1578  if (manual_type == value_t::array)
    1579  {
    1580  is_an_object = false;
    1581  }
    1582 
    1583  // if object is wanted but impossible, throw an exception
    1584  if (manual_type == value_t::object and not is_an_object)
    1585  {
    1586  throw std::domain_error("cannot create object from initializer list");
    1587  }
    1588  }
    1589 
    1590  if (is_an_object)
    1591  {
    1592  // the initializer list is a list of pairs -> create object
    1593  m_type = value_t::object;
    1594  m_value = value_t::object;
    1595 
    1596  assert(m_value.object != nullptr);
    1597 
    1598  for (auto& element : init)
    1599  {
    1600  m_value.object->emplace(*(element[0].m_value.string), element[1]);
    1601  }
    1602  }
    1603  else
    1604  {
    1605  // the initializer list describes an array -> create array
    1606  m_type = value_t::array;
    1607  m_value.array = create<array_t>(init);
    1608  }
    1609  }
    1610 
    1645  static basic_json array(std::initializer_list<basic_json> init =
    1646  std::initializer_list<basic_json>())
    1647  {
    1648  return basic_json(init, false, value_t::array);
    1649  }
    1650 
    1685  static basic_json object(std::initializer_list<basic_json> init =
    1686  std::initializer_list<basic_json>())
    1687  {
    1688  return basic_json(init, false, value_t::object);
    1689  }
    1690 
    1709  basic_json(size_type cnt, const basic_json& val)
    1710  : m_type(value_t::array)
    1711  {
    1712  m_value.array = create<array_t>(cnt, val);
    1713  }
    1714 
    1749  template <class InputIT, typename
    1750  std::enable_if<
    1751  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1752  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1753  , int>::type
    1754  = 0>
    1755  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1756  {
    1757  // make sure iterator fits the current value
    1758  if (first.m_object != last.m_object)
    1759  {
    1760  throw std::domain_error("iterators are not compatible");
    1761  }
    1762 
    1763  // check if iterator range is complete for primitive values
    1764  switch (m_type)
    1765  {
    1766  case value_t::boolean:
    1767  case value_t::number_float:
    1768  case value_t::number_integer:
    1769  case value_t::number_unsigned:
    1770  case value_t::string:
    1771  {
    1772  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1773  {
    1774  throw std::out_of_range("iterators out of range");
    1775  }
    1776  break;
    1777  }
    1778 
    1779  default:
    1780  {
    1781  break;
    1782  }
    1783  }
    1784 
    1785  switch (m_type)
    1786  {
    1787  case value_t::number_integer:
    1788  {
    1789  assert(first.m_object != nullptr);
    1790  m_value.number_integer = first.m_object->m_value.number_integer;
    1791  break;
    1792  }
    1793 
    1794  case value_t::number_unsigned:
    1795  {
    1796  assert(first.m_object != nullptr);
    1797  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
    1798  break;
    1799  }
    1800 
    1801  case value_t::number_float:
    1802  {
    1803  assert(first.m_object != nullptr);
    1804  m_value.number_float = first.m_object->m_value.number_float;
    1805  break;
    1806  }
    1807 
    1808  case value_t::boolean:
    1809  {
    1810  assert(first.m_object != nullptr);
    1811  m_value.boolean = first.m_object->m_value.boolean;
    1812  break;
    1813  }
    1814 
    1815  case value_t::string:
    1816  {
    1817  assert(first.m_object != nullptr);
    1818  m_value = *first.m_object->m_value.string;
    1819  break;
    1820  }
    1821 
    1822  case value_t::object:
    1823  {
    1824  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1825  break;
    1826  }
    1827 
    1828  case value_t::array:
    1829  {
    1830  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1831  break;
    1832  }
    1833 
    1834  default:
    1835  {
    1836  assert(first.m_object != nullptr);
    1837  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1838  }
    1839  }
    1840  }
    1841 
    1862  explicit basic_json(std::istream& i, parser_callback_t cb = nullptr)
    1863  {
    1864  *this = parser(i, cb).parse();
    1865  }
    1866 
    1868  // other constructors and destructor //
    1870 
    1893  basic_json(const basic_json& other)
    1894  : m_type(other.m_type)
    1895  {
    1896  switch (m_type)
    1897  {
    1898  case value_t::object:
    1899  {
    1900  assert(other.m_value.object != nullptr);
    1901  m_value = *other.m_value.object;
    1902  break;
    1903  }
    1904 
    1905  case value_t::array:
    1906  {
    1907  assert(other.m_value.array != nullptr);
    1908  m_value = *other.m_value.array;
    1909  break;
    1910  }
    1911 
    1912  case value_t::string:
    1913  {
    1914  assert(other.m_value.string != nullptr);
    1915  m_value = *other.m_value.string;
    1916  break;
    1917  }
    1918 
    1919  case value_t::boolean:
    1920  {
    1921  m_value = other.m_value.boolean;
    1922  break;
    1923  }
    1924 
    1925  case value_t::number_integer:
    1926  {
    1927  m_value = other.m_value.number_integer;
    1928  break;
    1929  }
    1930 
    1931  case value_t::number_unsigned:
    1932  {
    1933  m_value = other.m_value.number_unsigned;
    1934  break;
    1935  }
    1936 
    1937  case value_t::number_float:
    1938  {
    1939  m_value = other.m_value.number_float;
    1940  break;
    1941  }
    1942 
    1943  default:
    1944  {
    1945  break;
    1946  }
    1947  }
    1948  }
    1949 
    1968  basic_json(basic_json&& other) noexcept
    1969  : m_type(std::move(other.m_type)),
    1970  m_value(std::move(other.m_value))
    1971  {
    1972  // invalidate payload
    1973  other.m_type = value_t::null;
    1974  other.m_value = {};
    1975  }
    1976 
    2000  reference& operator=(basic_json other) noexcept (
    2001  std::is_nothrow_move_constructible<value_t>::value and
    2002  std::is_nothrow_move_assignable<value_t>::value and
    2003  std::is_nothrow_move_constructible<json_value>::value and
    2004  std::is_nothrow_move_assignable<json_value>::value
    2005  )
    2006  {
    2007  using std::swap;
    2008  swap(m_type, other.m_type);
    2009  swap(m_value, other.m_value);
    2010  return *this;
    2011  }
    2012 
    2029  {
    2030  switch (m_type)
    2031  {
    2032  case value_t::object:
    2033  {
    2034  AllocatorType<object_t> alloc;
    2035  alloc.destroy(m_value.object);
    2036  alloc.deallocate(m_value.object, 1);
    2037  break;
    2038  }
    2039 
    2040  case value_t::array:
    2041  {
    2042  AllocatorType<array_t> alloc;
    2043  alloc.destroy(m_value.array);
    2044  alloc.deallocate(m_value.array, 1);
    2045  break;
    2046  }
    2047 
    2048  case value_t::string:
    2049  {
    2050  AllocatorType<string_t> alloc;
    2051  alloc.destroy(m_value.string);
    2052  alloc.deallocate(m_value.string, 1);
    2053  break;
    2054  }
    2055 
    2056  default:
    2057  {
    2058  // all other types need no specific destructor
    2059  break;
    2060  }
    2061  }
    2062  }
    2063 
    2065 
    2066  public:
    2068  // object inspection //
    2070 
    2073 
    2097  string_t dump(const int indent = -1) const
    2098  {
    2099  std::stringstream ss;
    2100 
    2101  if (indent >= 0)
    2102  {
    2103  dump(ss, true, static_cast<unsigned int>(indent));
    2104  }
    2105  else
    2106  {
    2107  dump(ss, false, 0);
    2108  }
    2109 
    2110  return ss.str();
    2111  }
    2112 
    2131  constexpr value_t type() const noexcept
    2132  {
    2133  return m_type;
    2134  }
    2135 
    2161  constexpr bool is_primitive() const noexcept
    2162  {
    2163  return is_null() or is_string() or is_boolean() or is_number();
    2164  }
    2165 
    2188  constexpr bool is_structured() const noexcept
    2189  {
    2190  return is_array() or is_object();
    2191  }
    2192 
    2210  constexpr bool is_null() const noexcept
    2211  {
    2212  return m_type == value_t::null;
    2213  }
    2214 
    2232  constexpr bool is_boolean() const noexcept
    2233  {
    2234  return m_type == value_t::boolean;
    2235  }
    2236 
    2262  constexpr bool is_number() const noexcept
    2263  {
    2264  return is_number_integer() or is_number_float();
    2265  }
    2266 
    2291  constexpr bool is_number_integer() const noexcept
    2292  {
    2293  return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
    2294  }
    2295 
    2319  constexpr bool is_number_unsigned() const noexcept
    2320  {
    2321  return m_type == value_t::number_unsigned;
    2322  }
    2323 
    2347  constexpr bool is_number_float() const noexcept
    2348  {
    2349  return m_type == value_t::number_float;
    2350  }
    2351 
    2369  constexpr bool is_object() const noexcept
    2370  {
    2371  return m_type == value_t::object;
    2372  }
    2373 
    2391  constexpr bool is_array() const noexcept
    2392  {
    2393  return m_type == value_t::array;
    2394  }
    2395 
    2413  constexpr bool is_string() const noexcept
    2414  {
    2415  return m_type == value_t::string;
    2416  }
    2417 
    2440  constexpr bool is_discarded() const noexcept
    2441  {
    2442  return m_type == value_t::discarded;
    2443  }
    2444 
    2463  constexpr operator value_t() const noexcept
    2464  {
    2465  return m_type;
    2466  }
    2467 
    2469 
    2470  private:
    2472  // value access //
    2474 
    2476  template <class T, typename
    2477  std::enable_if<
    2478  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2479  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2480  , int>::type = 0>
    2481  T get_impl(T*) const
    2482  {
    2483  if (is_object())
    2484  {
    2485  assert(m_value.object != nullptr);
    2486  return T(m_value.object->begin(), m_value.object->end());
    2487  }
    2488  else
    2489  {
    2490  throw std::domain_error("type must be object, but is " + type_name());
    2491  }
    2492  }
    2493 
    2495  object_t get_impl(object_t*) const
    2496  {
    2497  if (is_object())
    2498  {
    2499  assert(m_value.object != nullptr);
    2500  return *(m_value.object);
    2501  }
    2502  else
    2503  {
    2504  throw std::domain_error("type must be object, but is " + type_name());
    2505  }
    2506  }
    2507 
    2509  template <class T, typename
    2510  std::enable_if<
    2511  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2512  not std::is_same<basic_json_t, typename T::value_type>::value and
    2513  not std::is_arithmetic<T>::value and
    2514  not std::is_convertible<std::string, T>::value and
    2515  not has_mapped_type<T>::value
    2516  , int>::type = 0>
    2517  T get_impl(T*) const
    2518  {
    2519  if (is_array())
    2520  {
    2521  T to_vector;
    2522  assert(m_value.array != nullptr);
    2523  std::transform(m_value.array->begin(), m_value.array->end(),
    2524  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2525  {
    2526  return i.get<typename T::value_type>();
    2527  });
    2528  return to_vector;
    2529  }
    2530  else
    2531  {
    2532  throw std::domain_error("type must be array, but is " + type_name());
    2533  }
    2534  }
    2535 
    2537  template <class T, typename
    2538  std::enable_if<
    2539  std::is_convertible<basic_json_t, T>::value and
    2540  not std::is_same<basic_json_t, T>::value
    2541  , int>::type = 0>
    2542  std::vector<T> get_impl(std::vector<T>*) const
    2543  {
    2544  if (is_array())
    2545  {
    2546  std::vector<T> to_vector;
    2547  assert(m_value.array != nullptr);
    2548  to_vector.reserve(m_value.array->size());
    2549  std::transform(m_value.array->begin(), m_value.array->end(),
    2550  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2551  {
    2552  return i.get<T>();
    2553  });
    2554  return to_vector;
    2555  }
    2556  else
    2557  {
    2558  throw std::domain_error("type must be array, but is " + type_name());
    2559  }
    2560  }
    2561 
    2563  template <class T, typename
    2564  std::enable_if<
    2565  std::is_same<basic_json, typename T::value_type>::value and
    2566  not has_mapped_type<T>::value
    2567  , int>::type = 0>
    2568  T get_impl(T*) const
    2569  {
    2570  if (is_array())
    2571  {
    2572  assert(m_value.array != nullptr);
    2573  return T(m_value.array->begin(), m_value.array->end());
    2574  }
    2575  else
    2576  {
    2577  throw std::domain_error("type must be array, but is " + type_name());
    2578  }
    2579  }
    2580 
    2582  array_t get_impl(array_t*) const
    2583  {
    2584  if (is_array())
    2585  {
    2586  assert(m_value.array != nullptr);
    2587  return *(m_value.array);
    2588  }
    2589  else
    2590  {
    2591  throw std::domain_error("type must be array, but is " + type_name());
    2592  }
    2593  }
    2594 
    2596  template <typename T, typename
    2597  std::enable_if<
    2598  std::is_convertible<string_t, T>::value
    2599  , int>::type = 0>
    2600  T get_impl(T*) const
    2601  {
    2602  if (is_string())
    2603  {
    2604  assert(m_value.string != nullptr);
    2605  return *m_value.string;
    2606  }
    2607  else
    2608  {
    2609  throw std::domain_error("type must be string, but is " + type_name());
    2610  }
    2611  }
    2612 
    2614  template<typename T, typename
    2615  std::enable_if<
    2616  std::is_arithmetic<T>::value
    2617  , int>::type = 0>
    2618  T get_impl(T*) const
    2619  {
    2620  switch (m_type)
    2621  {
    2622  case value_t::number_integer:
    2623  {
    2624  return static_cast<T>(m_value.number_integer);
    2625  }
    2626 
    2627  case value_t::number_unsigned:
    2628  {
    2629  return static_cast<T>(m_value.number_unsigned);
    2630  }
    2631 
    2632  case value_t::number_float:
    2633  {
    2634  return static_cast<T>(m_value.number_float);
    2635  }
    2636 
    2637  default:
    2638  {
    2639  throw std::domain_error("type must be number, but is " + type_name());
    2640  }
    2641  }
    2642  }
    2643 
    2645  constexpr boolean_t get_impl(boolean_t*) const
    2646  {
    2647  return is_boolean()
    2648  ? m_value.boolean
    2649  : throw std::domain_error("type must be boolean, but is " + type_name());
    2650  }
    2651 
    2653  object_t* get_impl_ptr(object_t*) noexcept
    2654  {
    2655  return is_object() ? m_value.object : nullptr;
    2656  }
    2657 
    2659  constexpr const object_t* get_impl_ptr(const object_t*) const noexcept
    2660  {
    2661  return is_object() ? m_value.object : nullptr;
    2662  }
    2663 
    2665  array_t* get_impl_ptr(array_t*) noexcept
    2666  {
    2667  return is_array() ? m_value.array : nullptr;
    2668  }
    2669 
    2671  constexpr const array_t* get_impl_ptr(const array_t*) const noexcept
    2672  {
    2673  return is_array() ? m_value.array : nullptr;
    2674  }
    2675 
    2677  string_t* get_impl_ptr(string_t*) noexcept
    2678  {
    2679  return is_string() ? m_value.string : nullptr;
    2680  }
    2681 
    2683  constexpr const string_t* get_impl_ptr(const string_t*) const noexcept
    2684  {
    2685  return is_string() ? m_value.string : nullptr;
    2686  }
    2687 
    2689  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2690  {
    2691  return is_boolean() ? &m_value.boolean : nullptr;
    2692  }
    2693 
    2695  constexpr const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2696  {
    2697  return is_boolean() ? &m_value.boolean : nullptr;
    2698  }
    2699 
    2701  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2702  {
    2703  return is_number_integer() ? &m_value.number_integer : nullptr;
    2704  }
    2705 
    2707  constexpr const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2708  {
    2709  return is_number_integer() ? &m_value.number_integer : nullptr;
    2710  }
    2711 
    2713  number_unsigned_t* get_impl_ptr(number_unsigned_t*) noexcept
    2714  {
    2715  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2716  }
    2717 
    2719  constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t*) const noexcept
    2720  {
    2721  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2722  }
    2723 
    2725  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2726  {
    2727  return is_number_float() ? &m_value.number_float : nullptr;
    2728  }
    2729 
    2731  constexpr const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2732  {
    2733  return is_number_float() ? &m_value.number_float : nullptr;
    2734  }
    2735 
    2747  template<typename ReferenceType, typename ThisType>
    2748  static ReferenceType get_ref_impl(ThisType& obj)
    2749  {
    2750  // delegate the call to get_ptr<>()
    2751  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2752  auto ptr = obj.template get_ptr<PointerType>();
    2753 
    2754  if (ptr != nullptr)
    2755  {
    2756  return *ptr;
    2757  }
    2758  else
    2759  {
    2760  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2761  obj.type_name());
    2762  }
    2763  }
    2764 
    2765  public:
    2766 
    2769 
    2803  template<typename ValueType, typename
    2804  std::enable_if<
    2805  not std::is_pointer<ValueType>::value
    2806  , int>::type = 0>
    2807  ValueType get() const
    2808  {
    2809  return get_impl(static_cast<ValueType*>(nullptr));
    2810  }
    2811 
    2838  template<typename PointerType, typename
    2839  std::enable_if<
    2840  std::is_pointer<PointerType>::value
    2841  , int>::type = 0>
    2842  PointerType get() noexcept
    2843  {
    2844  // delegate the call to get_ptr
    2845  return get_ptr<PointerType>();
    2846  }
    2847 
    2852  template<typename PointerType, typename
    2853  std::enable_if<
    2854  std::is_pointer<PointerType>::value
    2855  , int>::type = 0>
    2856  constexpr const PointerType get() const noexcept
    2857  {
    2858  // delegate the call to get_ptr
    2859  return get_ptr<PointerType>();
    2860  }
    2861 
    2887  template<typename PointerType, typename
    2888  std::enable_if<
    2889  std::is_pointer<PointerType>::value
    2890  , int>::type = 0>
    2891  PointerType get_ptr() noexcept
    2892  {
    2893  // delegate the call to get_impl_ptr<>()
    2894  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2895  }
    2896 
    2901  template<typename PointerType, typename
    2902  std::enable_if<
    2903  std::is_pointer<PointerType>::value
    2904  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2905  , int>::type = 0>
    2906  constexpr const PointerType get_ptr() const noexcept
    2907  {
    2908  // delegate the call to get_impl_ptr<>() const
    2909  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2910  }
    2911 
    2938  template<typename ReferenceType, typename
    2939  std::enable_if<
    2940  std::is_reference<ReferenceType>::value
    2941  , int>::type = 0>
    2942  ReferenceType get_ref()
    2943  {
    2944  // delegate call to get_ref_impl
    2945  return get_ref_impl<ReferenceType>(*this);
    2946  }
    2947 
    2952  template<typename ReferenceType, typename
    2953  std::enable_if<
    2954  std::is_reference<ReferenceType>::value
    2955  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2956  , int>::type = 0>
    2957  ReferenceType get_ref() const
    2958  {
    2959  // delegate call to get_ref_impl
    2960  return get_ref_impl<ReferenceType>(*this);
    2961  }
    2962 
    2991  template < typename ValueType, typename
    2992  std::enable_if <
    2993  not std::is_pointer<ValueType>::value
    2994  and not std::is_same<ValueType, typename string_t::value_type>::value
    2995 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2996  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2997 #endif
    2998  , int >::type = 0 >
    2999  operator ValueType() const
    3000  {
    3001  // delegate the call to get<>() const
    3002  return get<ValueType>();
    3003  }
    3004 
    3006 
    3007 
    3009  // element access //
    3011 
    3014 
    3038  {
    3039  // at only works for arrays
    3040  if (is_array())
    3041  {
    3042  try
    3043  {
    3044  assert(m_value.array != nullptr);
    3045  return m_value.array->at(idx);
    3046  }
    3047  catch (std::out_of_range&)
    3048  {
    3049  // create better exception explanation
    3050  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3051  }
    3052  }
    3053  else
    3054  {
    3055  throw std::domain_error("cannot use at() with " + type_name());
    3056  }
    3057  }
    3058 
    3082  {
    3083  // at only works for arrays
    3084  if (is_array())
    3085  {
    3086  try
    3087  {
    3088  assert(m_value.array != nullptr);
    3089  return m_value.array->at(idx);
    3090  }
    3091  catch (std::out_of_range&)
    3092  {
    3093  // create better exception explanation
    3094  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3095  }
    3096  }
    3097  else
    3098  {
    3099  throw std::domain_error("cannot use at() with " + type_name());
    3100  }
    3101  }
    3102 
    3129  reference at(const typename object_t::key_type& key)
    3130  {
    3131  // at only works for objects
    3132  if (is_object())
    3133  {
    3134  try
    3135  {
    3136  assert(m_value.object != nullptr);
    3137  return m_value.object->at(key);
    3138  }
    3139  catch (std::out_of_range&)
    3140  {
    3141  // create better exception explanation
    3142  throw std::out_of_range("key '" + key + "' not found");
    3143  }
    3144  }
    3145  else
    3146  {
    3147  throw std::domain_error("cannot use at() with " + type_name());
    3148  }
    3149  }
    3150 
    3177  const_reference at(const typename object_t::key_type& key) const
    3178  {
    3179  // at only works for objects
    3180  if (is_object())
    3181  {
    3182  try
    3183  {
    3184  assert(m_value.object != nullptr);
    3185  return m_value.object->at(key);
    3186  }
    3187  catch (std::out_of_range&)
    3188  {
    3189  // create better exception explanation
    3190  throw std::out_of_range("key '" + key + "' not found");
    3191  }
    3192  }
    3193  else
    3194  {
    3195  throw std::domain_error("cannot use at() with " + type_name());
    3196  }
    3197  }
    3198 
    3225  {
    3226  // implicitly convert null value to an empty array
    3227  if (is_null())
    3228  {
    3229  m_type = value_t::array;
    3230  m_value.array = create<array_t>();
    3231  }
    3232 
    3233  // operator[] only works for arrays
    3234  if (is_array())
    3235  {
    3236  // fill up array with null values until given idx is reached
    3237  assert(m_value.array != nullptr);
    3238  for (size_t i = m_value.array->size(); i <= idx; ++i)
    3239  {
    3240  m_value.array->push_back(basic_json());
    3241  }
    3242 
    3243  return m_value.array->operator[](idx);
    3244  }
    3245  else
    3246  {
    3247  throw std::domain_error("cannot use operator[] with " + type_name());
    3248  }
    3249  }
    3250 
    3271  {
    3272  // const operator[] only works for arrays
    3273  if (is_array())
    3274  {
    3275  assert(m_value.array != nullptr);
    3276  return m_value.array->operator[](idx);
    3277  }
    3278  else
    3279  {
    3280  throw std::domain_error("cannot use operator[] with " + type_name());
    3281  }
    3282  }
    3283 
    3311  reference operator[](const typename object_t::key_type& key)
    3312  {
    3313  // implicitly convert null value to an empty object
    3314  if (is_null())
    3315  {
    3316  m_type = value_t::object;
    3317  m_value.object = create<object_t>();
    3318  }
    3319 
    3320  // operator[] only works for objects
    3321  if (is_object())
    3322  {
    3323  assert(m_value.object != nullptr);
    3324  return m_value.object->operator[](key);
    3325  }
    3326  else
    3327  {
    3328  throw std::domain_error("cannot use operator[] with " + type_name());
    3329  }
    3330  }
    3331 
    3359  const_reference operator[](const typename object_t::key_type& key) const
    3360  {
    3361  // const operator[] only works for objects
    3362  if (is_object())
    3363  {
    3364  assert(m_value.object != nullptr);
    3365  assert(m_value.object->find(key) != m_value.object->end());
    3366  return m_value.object->find(key)->second;
    3367  }
    3368  else
    3369  {
    3370  throw std::domain_error("cannot use operator[] with " + type_name());
    3371  }
    3372  }
    3373 
    3401  template<typename T, std::size_t n>
    3402  reference operator[](T * (&key)[n])
    3403  {
    3404  return operator[](static_cast<const T>(key));
    3405  }
    3406 
    3436  template<typename T, std::size_t n>
    3437  const_reference operator[](T * (&key)[n]) const
    3438  {
    3439  return operator[](static_cast<const T>(key));
    3440  }
    3441 
    3469  template<typename T>
    3471  {
    3472  // implicitly convert null to object
    3473  if (is_null())
    3474  {
    3475  m_type = value_t::object;
    3476  m_value = value_t::object;
    3477  }
    3478 
    3479  // at only works for objects
    3480  if (is_object())
    3481  {
    3482  assert(m_value.object != nullptr);
    3483  return m_value.object->operator[](key);
    3484  }
    3485  else
    3486  {
    3487  throw std::domain_error("cannot use operator[] with " + type_name());
    3488  }
    3489  }
    3490 
    3518  template<typename T>
    3520  {
    3521  // at only works for objects
    3522  if (is_object())
    3523  {
    3524  assert(m_value.object != nullptr);
    3525  assert(m_value.object->find(key) != m_value.object->end());
    3526  return m_value.object->find(key)->second;
    3527  }
    3528  else
    3529  {
    3530  throw std::domain_error("cannot use operator[] with " + type_name());
    3531  }
    3532  }
    3533 
    3582  template <class ValueType, typename
    3583  std::enable_if<
    3584  std::is_convertible<basic_json_t, ValueType>::value
    3585  , int>::type = 0>
    3586  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3587  {
    3588  // at only works for objects
    3589  if (is_object())
    3590  {
    3591  // if key is found, return value and given default value otherwise
    3592  const auto it = find(key);
    3593  if (it != end())
    3594  {
    3595  return *it;
    3596  }
    3597  else
    3598  {
    3599  return default_value;
    3600  }
    3601  }
    3602  else
    3603  {
    3604  throw std::domain_error("cannot use value() with " + type_name());
    3605  }
    3606  }
    3607 
    3612  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3613  {
    3614  return value(key, string_t(default_value));
    3615  }
    3616 
    3642  {
    3643  return *begin();
    3644  }
    3645 
    3650  {
    3651  return *cbegin();
    3652  }
    3653 
    3684  {
    3685  auto tmp = end();
    3686  --tmp;
    3687  return *tmp;
    3688  }
    3689 
    3694  {
    3695  auto tmp = cend();
    3696  --tmp;
    3697  return *tmp;
    3698  }
    3699 
    3745  template <class InteratorType, typename
    3746  std::enable_if<
    3747  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3748  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3749  , int>::type
    3750  = 0>
    3751  InteratorType erase(InteratorType pos)
    3752  {
    3753  // make sure iterator fits the current value
    3754  if (this != pos.m_object)
    3755  {
    3756  throw std::domain_error("iterator does not fit current value");
    3757  }
    3758 
    3759  InteratorType result = end();
    3760 
    3761  switch (m_type)
    3762  {
    3763  case value_t::boolean:
    3764  case value_t::number_float:
    3765  case value_t::number_integer:
    3766  case value_t::number_unsigned:
    3767  case value_t::string:
    3768  {
    3769  if (not pos.m_it.primitive_iterator.is_begin())
    3770  {
    3771  throw std::out_of_range("iterator out of range");
    3772  }
    3773 
    3774  if (is_string())
    3775  {
    3776  delete m_value.string;
    3777  m_value.string = nullptr;
    3778  }
    3779 
    3780  m_type = value_t::null;
    3781  break;
    3782  }
    3783 
    3784  case value_t::object:
    3785  {
    3786  assert(m_value.object != nullptr);
    3787  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3788  break;
    3789  }
    3790 
    3791  case value_t::array:
    3792  {
    3793  assert(m_value.array != nullptr);
    3794  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3795  break;
    3796  }
    3797 
    3798  default:
    3799  {
    3800  throw std::domain_error("cannot use erase() with " + type_name());
    3801  }
    3802  }
    3803 
    3804  return result;
    3805  }
    3806 
    3853  template <class InteratorType, typename
    3854  std::enable_if<
    3855  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3856  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3857  , int>::type
    3858  = 0>
    3859  InteratorType erase(InteratorType first, InteratorType last)
    3860  {
    3861  // make sure iterator fits the current value
    3862  if (this != first.m_object or this != last.m_object)
    3863  {
    3864  throw std::domain_error("iterators do not fit current value");
    3865  }
    3866 
    3867  InteratorType result = end();
    3868 
    3869  switch (m_type)
    3870  {
    3871  case value_t::boolean:
    3872  case value_t::number_float:
    3873  case value_t::number_integer:
    3874  case value_t::number_unsigned:
    3875  case value_t::string:
    3876  {
    3877  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3878  {
    3879  throw std::out_of_range("iterators out of range");
    3880  }
    3881 
    3882  if (is_string())
    3883  {
    3884  delete m_value.string;
    3885  m_value.string = nullptr;
    3886  }
    3887 
    3888  m_type = value_t::null;
    3889  break;
    3890  }
    3891 
    3892  case value_t::object:
    3893  {
    3894  assert(m_value.object != nullptr);
    3895  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3896  last.m_it.object_iterator);
    3897  break;
    3898  }
    3899 
    3900  case value_t::array:
    3901  {
    3902  assert(m_value.array != nullptr);
    3903  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3904  last.m_it.array_iterator);
    3905  break;
    3906  }
    3907 
    3908  default:
    3909  {
    3910  throw std::domain_error("cannot use erase() with " + type_name());
    3911  }
    3912  }
    3913 
    3914  return result;
    3915  }
    3916 
    3946  size_type erase(const typename object_t::key_type& key)
    3947  {
    3948  // this erase only works for objects
    3949  if (is_object())
    3950  {
    3951  assert(m_value.object != nullptr);
    3952  return m_value.object->erase(key);
    3953  }
    3954  else
    3955  {
    3956  throw std::domain_error("cannot use erase() with " + type_name());
    3957  }
    3958  }
    3959 
    3984  void erase(const size_type idx)
    3985  {
    3986  // this erase only works for arrays
    3987  if (is_array())
    3988  {
    3989  if (idx >= size())
    3990  {
    3991  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3992  }
    3993 
    3994  assert(m_value.array != nullptr);
    3995  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3996  }
    3997  else
    3998  {
    3999  throw std::domain_error("cannot use erase() with " + type_name());
    4000  }
    4001  }
    4002 
    4004 
    4005 
    4007  // lookup //
    4009 
    4012 
    4031  iterator find(typename object_t::key_type key)
    4032  {
    4033  auto result = end();
    4034 
    4035  if (is_object())
    4036  {
    4037  assert(m_value.object != nullptr);
    4038  result.m_it.object_iterator = m_value.object->find(key);
    4039  }
    4040 
    4041  return result;
    4042  }
    4043 
    4048  const_iterator find(typename object_t::key_type key) const
    4049  {
    4050  auto result = cend();
    4051 
    4052  if (is_object())
    4053  {
    4054  assert(m_value.object != nullptr);
    4055  result.m_it.object_iterator = m_value.object->find(key);
    4056  }
    4057 
    4058  return result;
    4059  }
    4060 
    4079  size_type count(typename object_t::key_type key) const
    4080  {
    4081  // return 0 for all nonobject types
    4082  assert(not is_object() or m_value.object != nullptr);
    4083  return is_object() ? m_value.object->count(key) : 0;
    4084  }
    4085 
    4087 
    4088 
    4090  // iterators //
    4092 
    4095 
    4120  iterator begin() noexcept
    4121  {
    4122  iterator result(this);
    4123  result.set_begin();
    4124  return result;
    4125  }
    4126 
    4130  const_iterator begin() const noexcept
    4131  {
    4132  return cbegin();
    4133  }
    4134 
    4160  const_iterator cbegin() const noexcept
    4161  {
    4162  const_iterator result(this);
    4163  result.set_begin();
    4164  return result;
    4165  }
    4166 
    4191  iterator end() noexcept
    4192  {
    4193  iterator result(this);
    4194  result.set_end();
    4195  return result;
    4196  }
    4197 
    4201  const_iterator end() const noexcept
    4202  {
    4203  return cend();
    4204  }
    4205 
    4231  const_iterator cend() const noexcept
    4232  {
    4233  const_iterator result(this);
    4234  result.set_end();
    4235  return result;
    4236  }
    4237 
    4262  {
    4263  return reverse_iterator(end());
    4264  }
    4265 
    4270  {
    4271  return crbegin();
    4272  }
    4273 
    4299  {
    4300  return reverse_iterator(begin());
    4301  }
    4302 
    4306  const_reverse_iterator rend() const noexcept
    4307  {
    4308  return crend();
    4309  }
    4310 
    4336  {
    4337  return const_reverse_iterator(cend());
    4338  }
    4339 
    4365  {
    4366  return const_reverse_iterator(cbegin());
    4367  }
    4368 
    4369  private:
    4370  // forward declaration
    4371  template<typename IteratorType> class iteration_proxy;
    4372 
    4373  public:
    4385  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    4386  {
    4387  return iteration_proxy<iterator>(cont);
    4388  }
    4389 
    4393  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4394  {
    4395  return iteration_proxy<const_iterator>(cont);
    4396  }
    4397 
    4399 
    4400 
    4402  // capacity //
    4404 
    4407 
    4441  bool empty() const noexcept
    4442  {
    4443  switch (m_type)
    4444  {
    4445  case value_t::null:
    4446  {
    4447  // null values are empty
    4448  return true;
    4449  }
    4450 
    4451  case value_t::array:
    4452  {
    4453  assert(m_value.array != nullptr);
    4454  return m_value.array->empty();
    4455  }
    4456 
    4457  case value_t::object:
    4458  {
    4459  assert(m_value.object != nullptr);
    4460  return m_value.object->empty();
    4461  }
    4462 
    4463  default:
    4464  {
    4465  // all other types are nonempty
    4466  return false;
    4467  }
    4468  }
    4469  }
    4470 
    4505  size_type size() const noexcept
    4506  {
    4507  switch (m_type)
    4508  {
    4509  case value_t::null:
    4510  {
    4511  // null values are empty
    4512  return 0;
    4513  }
    4514 
    4515  case value_t::array:
    4516  {
    4517  assert(m_value.array != nullptr);
    4518  return m_value.array->size();
    4519  }
    4520 
    4521  case value_t::object:
    4522  {
    4523  assert(m_value.object != nullptr);
    4524  return m_value.object->size();
    4525  }
    4526 
    4527  default:
    4528  {
    4529  // all other types have size 1
    4530  return 1;
    4531  }
    4532  }
    4533  }
    4534 
    4571  size_type max_size() const noexcept
    4572  {
    4573  switch (m_type)
    4574  {
    4575  case value_t::array:
    4576  {
    4577  assert(m_value.array != nullptr);
    4578  return m_value.array->max_size();
    4579  }
    4580 
    4581  case value_t::object:
    4582  {
    4583  assert(m_value.object != nullptr);
    4584  return m_value.object->max_size();
    4585  }
    4586 
    4587  default:
    4588  {
    4589  // all other types have max_size() == size()
    4590  return size();
    4591  }
    4592  }
    4593  }
    4594 
    4596 
    4597 
    4599  // modifiers //
    4601 
    4604 
    4630  void clear() noexcept
    4631  {
    4632  switch (m_type)
    4633  {
    4634  case value_t::number_integer:
    4635  {
    4636  m_value.number_integer = 0;
    4637  break;
    4638  }
    4639 
    4640  case value_t::number_unsigned:
    4641  {
    4642  m_value.number_unsigned = 0;
    4643  break;
    4644  }
    4645 
    4646  case value_t::number_float:
    4647  {
    4648  m_value.number_float = 0.0;
    4649  break;
    4650  }
    4651 
    4652  case value_t::boolean:
    4653  {
    4654  m_value.boolean = false;
    4655  break;
    4656  }
    4657 
    4658  case value_t::string:
    4659  {
    4660  assert(m_value.string != nullptr);
    4661  m_value.string->clear();
    4662  break;
    4663  }
    4664 
    4665  case value_t::array:
    4666  {
    4667  assert(m_value.array != nullptr);
    4668  m_value.array->clear();
    4669  break;
    4670  }
    4671 
    4672  case value_t::object:
    4673  {
    4674  assert(m_value.object != nullptr);
    4675  m_value.object->clear();
    4676  break;
    4677  }
    4678 
    4679  default:
    4680  {
    4681  break;
    4682  }
    4683  }
    4684  }
    4685 
    4706  void push_back(basic_json&& val)
    4707  {
    4708  // push_back only works for null objects or arrays
    4709  if (not(is_null() or is_array()))
    4710  {
    4711  throw std::domain_error("cannot use push_back() with " + type_name());
    4712  }
    4713 
    4714  // transform null object into an array
    4715  if (is_null())
    4716  {
    4717  m_type = value_t::array;
    4718  m_value = value_t::array;
    4719  }
    4720 
    4721  // add element to array (move semantics)
    4722  assert(m_value.array != nullptr);
    4723  m_value.array->push_back(std::move(val));
    4724  // invalidate object
    4725  val.m_type = value_t::null;
    4726  }
    4727 
    4732  reference operator+=(basic_json&& val)
    4733  {
    4734  push_back(std::move(val));
    4735  return *this;
    4736  }
    4737 
    4742  void push_back(const basic_json& val)
    4743  {
    4744  // push_back only works for null objects or arrays
    4745  if (not(is_null() or is_array()))
    4746  {
    4747  throw std::domain_error("cannot use push_back() with " + type_name());
    4748  }
    4749 
    4750  // transform null object into an array
    4751  if (is_null())
    4752  {
    4753  m_type = value_t::array;
    4754  m_value = value_t::array;
    4755  }
    4756 
    4757  // add element to array
    4758  assert(m_value.array != nullptr);
    4759  m_value.array->push_back(val);
    4760  }
    4761 
    4766  reference operator+=(const basic_json& val)
    4767  {
    4768  push_back(val);
    4769  return *this;
    4770  }
    4771 
    4792  void push_back(const typename object_t::value_type& val)
    4793  {
    4794  // push_back only works for null objects or objects
    4795  if (not(is_null() or is_object()))
    4796  {
    4797  throw std::domain_error("cannot use push_back() with " + type_name());
    4798  }
    4799 
    4800  // transform null object into an object
    4801  if (is_null())
    4802  {
    4803  m_type = value_t::object;
    4804  m_value = value_t::object;
    4805  }
    4806 
    4807  // add element to array
    4808  assert(m_value.object != nullptr);
    4809  m_value.object->insert(val);
    4810  }
    4811 
    4816  reference operator+=(const typename object_t::value_type& val)
    4817  {
    4818  push_back(val);
    4819  return *this;
    4820  }
    4821 
    4847  void push_back(std::initializer_list<basic_json> init)
    4848  {
    4849  if (is_object() and init.size() == 2 and init.begin()->is_string())
    4850  {
    4851  const string_t key = *init.begin();
    4852  push_back(typename object_t::value_type(key, *(init.begin() + 1)));
    4853  }
    4854  else
    4855  {
    4856  push_back(basic_json(init));
    4857  }
    4858  }
    4859 
    4864  reference operator+=(std::initializer_list<basic_json> init)
    4865  {
    4866  push_back(init);
    4867  return *this;
    4868  }
    4869 
    4892  iterator insert(const_iterator pos, const basic_json& val)
    4893  {
    4894  // insert only works for arrays
    4895  if (is_array())
    4896  {
    4897  // check if iterator pos fits to this JSON value
    4898  if (pos.m_object != this)
    4899  {
    4900  throw std::domain_error("iterator does not fit current value");
    4901  }
    4902 
    4903  // insert to array and return iterator
    4904  iterator result(this);
    4905  assert(m_value.array != nullptr);
    4906  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4907  return result;
    4908  }
    4909  else
    4910  {
    4911  throw std::domain_error("cannot use insert() with " + type_name());
    4912  }
    4913  }
    4914 
    4919  iterator insert(const_iterator pos, basic_json&& val)
    4920  {
    4921  return insert(pos, val);
    4922  }
    4923 
    4948  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4949  {
    4950  // insert only works for arrays
    4951  if (is_array())
    4952  {
    4953  // check if iterator pos fits to this JSON value
    4954  if (pos.m_object != this)
    4955  {
    4956  throw std::domain_error("iterator does not fit current value");
    4957  }
    4958 
    4959  // insert to array and return iterator
    4960  iterator result(this);
    4961  assert(m_value.array != nullptr);
    4962  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4963  return result;
    4964  }
    4965  else
    4966  {
    4967  throw std::domain_error("cannot use insert() with " + type_name());
    4968  }
    4969  }
    4970 
    5002  {
    5003  // insert only works for arrays
    5004  if (not is_array())
    5005  {
    5006  throw std::domain_error("cannot use insert() with " + type_name());
    5007  }
    5008 
    5009  // check if iterator pos fits to this JSON value
    5010  if (pos.m_object != this)
    5011  {
    5012  throw std::domain_error("iterator does not fit current value");
    5013  }
    5014 
    5015  // check if range iterators belong to the same JSON object
    5016  if (first.m_object != last.m_object)
    5017  {
    5018  throw std::domain_error("iterators do not fit");
    5019  }
    5020 
    5021  if (first.m_object == this or last.m_object == this)
    5022  {
    5023  throw std::domain_error("passed iterators may not belong to container");
    5024  }
    5025 
    5026  // insert to array and return iterator
    5027  iterator result(this);
    5028  assert(m_value.array != nullptr);
    5029  result.m_it.array_iterator = m_value.array->insert(
    5030  pos.m_it.array_iterator,
    5031  first.m_it.array_iterator,
    5032  last.m_it.array_iterator);
    5033  return result;
    5034  }
    5035 
    5060  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    5061  {
    5062  // insert only works for arrays
    5063  if (not is_array())
    5064  {
    5065  throw std::domain_error("cannot use insert() with " + type_name());
    5066  }
    5067 
    5068  // check if iterator pos fits to this JSON value
    5069  if (pos.m_object != this)
    5070  {
    5071  throw std::domain_error("iterator does not fit current value");
    5072  }
    5073 
    5074  // insert to array and return iterator
    5075  iterator result(this);
    5076  assert(m_value.array != nullptr);
    5077  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    5078  return result;
    5079  }
    5080 
    5098  void swap(reference other) noexcept (
    5099  std::is_nothrow_move_constructible<value_t>::value and
    5100  std::is_nothrow_move_assignable<value_t>::value and
    5101  std::is_nothrow_move_constructible<json_value>::value and
    5102  std::is_nothrow_move_assignable<json_value>::value
    5103  )
    5104  {
    5105  std::swap(m_type, other.m_type);
    5106  std::swap(m_value, other.m_value);
    5107  }
    5108 
    5129  void swap(array_t& other)
    5130  {
    5131  // swap only works for arrays
    5132  if (is_array())
    5133  {
    5134  assert(m_value.array != nullptr);
    5135  std::swap(*(m_value.array), other);
    5136  }
    5137  else
    5138  {
    5139  throw std::domain_error("cannot use swap() with " + type_name());
    5140  }
    5141  }
    5142 
    5163  void swap(object_t& other)
    5164  {
    5165  // swap only works for objects
    5166  if (is_object())
    5167  {
    5168  assert(m_value.object != nullptr);
    5169  std::swap(*(m_value.object), other);
    5170  }
    5171  else
    5172  {
    5173  throw std::domain_error("cannot use swap() with " + type_name());
    5174  }
    5175  }
    5176 
    5197  void swap(string_t& other)
    5198  {
    5199  // swap only works for strings
    5200  if (is_string())
    5201  {
    5202  assert(m_value.string != nullptr);
    5203  std::swap(*(m_value.string), other);
    5204  }
    5205  else
    5206  {
    5207  throw std::domain_error("cannot use swap() with " + type_name());
    5208  }
    5209  }
    5210 
    5212 
    5213 
    5215  // lexicographical comparison operators //
    5217 
    5220 
    5221  private:
    5231  friend bool operator<(const value_t lhs, const value_t rhs) noexcept
    5232  {
    5233  static constexpr std::array<uint8_t, 8> order = {{
    5234  0, // null
    5235  3, // object
    5236  4, // array
    5237  5, // string
    5238  1, // boolean
    5239  2, // integer
    5240  2, // unsigned
    5241  2, // float
    5242  }
    5243  };
    5244 
    5245  // discarded values are not comparable
    5246  if (lhs == value_t::discarded or rhs == value_t::discarded)
    5247  {
    5248  return false;
    5249  }
    5250 
    5251  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    5252  }
    5253 
    5254  public:
    5278  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    5279  {
    5280  const auto lhs_type = lhs.type();
    5281  const auto rhs_type = rhs.type();
    5282 
    5283  if (lhs_type == rhs_type)
    5284  {
    5285  switch (lhs_type)
    5286  {
    5287  case value_t::array:
    5288  {
    5289  assert(lhs.m_value.array != nullptr);
    5290  assert(rhs.m_value.array != nullptr);
    5291  return *lhs.m_value.array == *rhs.m_value.array;
    5292  }
    5293  case value_t::object:
    5294  {
    5295  assert(lhs.m_value.object != nullptr);
    5296  assert(rhs.m_value.object != nullptr);
    5297  return *lhs.m_value.object == *rhs.m_value.object;
    5298  }
    5299  case value_t::null:
    5300  {
    5301  return true;
    5302  }
    5303  case value_t::string:
    5304  {
    5305  assert(lhs.m_value.string != nullptr);
    5306  assert(rhs.m_value.string != nullptr);
    5307  return *lhs.m_value.string == *rhs.m_value.string;
    5308  }
    5309  case value_t::boolean:
    5310  {
    5311  return lhs.m_value.boolean == rhs.m_value.boolean;
    5312  }
    5313  case value_t::number_integer:
    5314  {
    5315  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    5316  }
    5317  case value_t::number_unsigned:
    5318  {
    5319  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
    5320  }
    5321  case value_t::number_float:
    5322  {
    5323  return lhs.m_value.number_float == rhs.m_value.number_float;
    5324  }
    5325  default:
    5326  {
    5327  return false;
    5328  }
    5329  }
    5330  }
    5331  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5332  {
    5333  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    5334  }
    5335  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5336  {
    5337  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    5338  }
    5339  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5340  {
    5341  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
    5342  }
    5343  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5344  {
    5345  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5346  }
    5347  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5348  {
    5349  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
    5350  }
    5351  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5352  {
    5353  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5354  }
    5355 
    5356  return false;
    5357  }
    5358 
    5377  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    5378  {
    5379  return v.is_null();
    5380  }
    5381 
    5386  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    5387  {
    5388  return v.is_null();
    5389  }
    5390 
    5407  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    5408  {
    5409  return not (lhs == rhs);
    5410  }
    5411 
    5430  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    5431  {
    5432  return not v.is_null();
    5433  }
    5434 
    5439  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    5440  {
    5441  return not v.is_null();
    5442  }
    5443 
    5468  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    5469  {
    5470  const auto lhs_type = lhs.type();
    5471  const auto rhs_type = rhs.type();
    5472 
    5473  if (lhs_type == rhs_type)
    5474  {
    5475  switch (lhs_type)
    5476  {
    5477  case value_t::array:
    5478  {
    5479  assert(lhs.m_value.array != nullptr);
    5480  assert(rhs.m_value.array != nullptr);
    5481  return *lhs.m_value.array < *rhs.m_value.array;
    5482  }
    5483  case value_t::object:
    5484  {
    5485  assert(lhs.m_value.object != nullptr);
    5486  assert(rhs.m_value.object != nullptr);
    5487  return *lhs.m_value.object < *rhs.m_value.object;
    5488  }
    5489  case value_t::null:
    5490  {
    5491  return false;
    5492  }
    5493  case value_t::string:
    5494  {
    5495  assert(lhs.m_value.string != nullptr);
    5496  assert(rhs.m_value.string != nullptr);
    5497  return *lhs.m_value.string < *rhs.m_value.string;
    5498  }
    5499  case value_t::boolean:
    5500  {
    5501  return lhs.m_value.boolean < rhs.m_value.boolean;
    5502  }
    5503  case value_t::number_integer:
    5504  {
    5505  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5506  }
    5507  case value_t::number_unsigned:
    5508  {
    5509  return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
    5510  }
    5511  case value_t::number_float:
    5512  {
    5513  return lhs.m_value.number_float < rhs.m_value.number_float;
    5514  }
    5515  default:
    5516  {
    5517  return false;
    5518  }
    5519  }
    5520  }
    5521  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5522  {
    5523  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
    5524  }
    5525  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5526  {
    5527  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
    5528  }
    5529  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5530  {
    5531  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
    5532  }
    5533  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5534  {
    5535  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5536  }
    5537  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5538  {
    5539  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5540  }
    5541  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5542  {
    5543  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
    5544  }
    5545 
    5546  // We only reach this line if we cannot compare values. In that case,
    5547  // we compare types. Note we have to call the operator explicitly,
    5548  // because MSVC has problems otherwise.
    5549  return operator<(lhs_type, rhs_type);
    5550  }
    5551 
    5569  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5570  {
    5571  return not (rhs < lhs);
    5572  }
    5573 
    5591  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5592  {
    5593  return not (lhs <= rhs);
    5594  }
    5595 
    5613  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5614  {
    5615  return not (lhs < rhs);
    5616  }
    5617 
    5619 
    5620 
    5622  // serialization //
    5624 
    5627 
    5650  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5651  {
    5652  // read width member and use it as indentation parameter if nonzero
    5653  const bool pretty_print = (o.width() > 0);
    5654  const auto indentation = (pretty_print ? o.width() : 0);
    5655 
    5656  // reset width to 0 for subsequent calls to this stream
    5657  o.width(0);
    5658 
    5659  // do the actual serialization
    5660  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5661  return o;
    5662  }
    5663 
    5668  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5669  {
    5670  return o << j;
    5671  }
    5672 
    5674 
    5675 
    5677  // deserialization //
    5679 
    5682 
    5707  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5708  {
    5709  return parser(s, cb).parse();
    5710  }
    5711 
    5736  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5737  {
    5738  return parser(i, cb).parse();
    5739  }
    5740 
    5744  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5745  {
    5746  return parser(i, cb).parse();
    5747  }
    5748 
    5772  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5773  {
    5774  j = parser(i).parse();
    5775  return i;
    5776  }
    5777 
    5782  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5783  {
    5784  j = parser(i).parse();
    5785  return i;
    5786  }
    5787 
    5789 
    5790 
    5791  private:
    5793  // convenience functions //
    5795 
    5797  string_t type_name() const noexcept
    5798  {
    5799  switch (m_type)
    5800  {
    5801  case value_t::null:
    5802  return "null";
    5803  case value_t::object:
    5804  return "object";
    5805  case value_t::array:
    5806  return "array";
    5807  case value_t::string:
    5808  return "string";
    5809  case value_t::boolean:
    5810  return "boolean";
    5811  case value_t::discarded:
    5812  return "discarded";
    5813  default:
    5814  return "number";
    5815  }
    5816  }
    5817 
    5826  static std::size_t extra_space(const string_t& s) noexcept
    5827  {
    5828  std::size_t result = 0;
    5829 
    5830  for (const auto& c : s)
    5831  {
    5832  switch (c)
    5833  {
    5834  case '"':
    5835  case '\\':
    5836  case '\b':
    5837  case '\f':
    5838  case '\n':
    5839  case '\r':
    5840  case '\t':
    5841  {
    5842  // from c (1 byte) to \x (2 bytes)
    5843  result += 1;
    5844  break;
    5845  }
    5846 
    5847  default:
    5848  {
    5849  if (c >= 0x00 and c <= 0x1f)
    5850  {
    5851  // from c (1 byte) to \uxxxx (6 bytes)
    5852  result += 5;
    5853  }
    5854  break;
    5855  }
    5856  }
    5857  }
    5858 
    5859  return result;
    5860  }
    5861 
    5875  static string_t escape_string(const string_t& s)
    5876  {
    5877  const auto space = extra_space(s);
    5878  if (space == 0)
    5879  {
    5880  return s;
    5881  }
    5882 
    5883  // create a result string of necessary size
    5884  string_t result(s.size() + space, '\\');
    5885  std::size_t pos = 0;
    5886 
    5887  for (const auto& c : s)
    5888  {
    5889  switch (c)
    5890  {
    5891  // quotation mark (0x22)
    5892  case '"':
    5893  {
    5894  result[pos + 1] = '"';
    5895  pos += 2;
    5896  break;
    5897  }
    5898 
    5899  // reverse solidus (0x5c)
    5900  case '\\':
    5901  {
    5902  // nothing to change
    5903  pos += 2;
    5904  break;
    5905  }
    5906 
    5907  // backspace (0x08)
    5908  case '\b':
    5909  {
    5910  result[pos + 1] = 'b';
    5911  pos += 2;
    5912  break;
    5913  }
    5914 
    5915  // formfeed (0x0c)
    5916  case '\f':
    5917  {
    5918  result[pos + 1] = 'f';
    5919  pos += 2;
    5920  break;
    5921  }
    5922 
    5923  // newline (0x0a)
    5924  case '\n':
    5925  {
    5926  result[pos + 1] = 'n';
    5927  pos += 2;
    5928  break;
    5929  }
    5930 
    5931  // carriage return (0x0d)
    5932  case '\r':
    5933  {
    5934  result[pos + 1] = 'r';
    5935  pos += 2;
    5936  break;
    5937  }
    5938 
    5939  // horizontal tab (0x09)
    5940  case '\t':
    5941  {
    5942  result[pos + 1] = 't';
    5943  pos += 2;
    5944  break;
    5945  }
    5946 
    5947  default:
    5948  {
    5949  if (c >= 0x00 and c <= 0x1f)
    5950  {
    5951  // convert a number 0..15 to its hex representation
    5952  // (0..f)
    5953  const auto hexify = [](const int v) -> char
    5954  {
    5955  return (v < 10)
    5956  ? ('0' + static_cast<char>(v))
    5957  : ('a' + static_cast<char>((v - 10) & 0x1f));
    5958  };
    5959 
    5960  // print character c as \uxxxx
    5961  for (const char m :
    5962  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5963  })
    5964  {
    5965  result[++pos] = m;
    5966  }
    5967 
    5968  ++pos;
    5969  }
    5970  else
    5971  {
    5972  // all other characters are added as-is
    5973  result[pos++] = c;
    5974  }
    5975  break;
    5976  }
    5977  }
    5978  }
    5979 
    5980  return result;
    5981  }
    5982 
    6000  void dump(std::ostream& o,
    6001  const bool pretty_print,
    6002  const unsigned int indent_step,
    6003  const unsigned int current_indent = 0) const
    6004  {
    6005  // variable to hold indentation for recursive calls
    6006  unsigned int new_indent = current_indent;
    6007 
    6008  switch (m_type)
    6009  {
    6010  case value_t::object:
    6011  {
    6012  assert(m_value.object != nullptr);
    6013 
    6014  if (m_value.object->empty())
    6015  {
    6016  o << "{}";
    6017  return;
    6018  }
    6019 
    6020  o << "{";
    6021 
    6022  // increase indentation
    6023  if (pretty_print)
    6024  {
    6025  new_indent += indent_step;
    6026  o << "\n";
    6027  }
    6028 
    6029  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    6030  {
    6031  if (i != m_value.object->cbegin())
    6032  {
    6033  o << (pretty_print ? ",\n" : ",");
    6034  }
    6035  o << string_t(new_indent, ' ') << "\""
    6036  << escape_string(i->first) << "\":"
    6037  << (pretty_print ? " " : "");
    6038  i->second.dump(o, pretty_print, indent_step, new_indent);
    6039  }
    6040 
    6041  // decrease indentation
    6042  if (pretty_print)
    6043  {
    6044  new_indent -= indent_step;
    6045  o << "\n";
    6046  }
    6047 
    6048  o << string_t(new_indent, ' ') + "}";
    6049  return;
    6050  }
    6051 
    6052  case value_t::array:
    6053  {
    6054  assert(m_value.array != nullptr);
    6055 
    6056  if (m_value.array->empty())
    6057  {
    6058  o << "[]";
    6059  return;
    6060  }
    6061 
    6062  o << "[";
    6063 
    6064  // increase indentation
    6065  if (pretty_print)
    6066  {
    6067  new_indent += indent_step;
    6068  o << "\n";
    6069  }
    6070 
    6071  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    6072  {
    6073  if (i != m_value.array->cbegin())
    6074  {
    6075  o << (pretty_print ? ",\n" : ",");
    6076  }
    6077  o << string_t(new_indent, ' ');
    6078  i->dump(o, pretty_print, indent_step, new_indent);
    6079  }
    6080 
    6081  // decrease indentation
    6082  if (pretty_print)
    6083  {
    6084  new_indent -= indent_step;
    6085  o << "\n";
    6086  }
    6087 
    6088  o << string_t(new_indent, ' ') << "]";
    6089  return;
    6090  }
    6091 
    6092  case value_t::string:
    6093  {
    6094  assert(m_value.string != nullptr);
    6095  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    6096  return;
    6097  }
    6098 
    6099  case value_t::boolean:
    6100  {
    6101  o << (m_value.boolean ? "true" : "false");
    6102  return;
    6103  }
    6104 
    6105  case value_t::number_integer:
    6106  {
    6107  o << m_value.number_integer;
    6108  return;
    6109  }
    6110 
    6111  case value_t::number_unsigned:
    6112  {
    6113  o << m_value.number_unsigned;
    6114  return;
    6115  }
    6116 
    6117  case value_t::number_float:
    6118  {
    6119  if (m_value.number_float == 0)
    6120  {
    6121  // special case for zero to get "0.0"/"-0.0"
    6122  o << (std::signbit(m_value.number_float) ? "-0.0" : "0.0");
    6123  }
    6124  else
    6125  {
    6126  // Otherwise 6, 15 or 16 digits of precision allows
    6127  // round-trip IEEE 754 string->float->string,
    6128  // string->double->string or string->long
    6129  // double->string; to be safe, we read this value from
    6130  // std::numeric_limits<number_float_t>::digits10
    6131  std::stringstream ss;
    6132  ss.imbue(std::locale(std::locale(), new DecimalSeparator)); // fix locale problems
    6133  ss << std::setprecision(std::numeric_limits<double>::digits10)
    6134  << m_value.number_float;
    6135  o << ss.str();
    6136  }
    6137  return;
    6138  }
    6139 
    6140  case value_t::discarded:
    6141  {
    6142  o << "<discarded>";
    6143  return;
    6144  }
    6145 
    6146  case value_t::null:
    6147  {
    6148  o << "null";
    6149  return;
    6150  }
    6151  }
    6152  }
    6153 
    6154  private:
    6156  // member variables //
    6158 
    6160  value_t m_type = value_t::null;
    6161 
    6163  json_value m_value = {};
    6164 
    6165 
    6166  private:
    6168  // iterators //
    6170 
    6180  class primitive_iterator_t
    6181  {
    6182  public:
    6184  void set_begin() noexcept
    6185  {
    6186  m_it = begin_value;
    6187  }
    6188 
    6190  void set_end() noexcept
    6191  {
    6192  m_it = end_value;
    6193  }
    6194 
    6196  constexpr bool is_begin() const noexcept
    6197  {
    6198  return (m_it == begin_value);
    6199  }
    6200 
    6202  constexpr bool is_end() const noexcept
    6203  {
    6204  return (m_it == end_value);
    6205  }
    6206 
    6208  operator difference_type& () noexcept
    6209  {
    6210  return m_it;
    6211  }
    6212 
    6214  constexpr operator difference_type () const noexcept
    6215  {
    6216  return m_it;
    6217  }
    6218 
    6219  private:
    6220  static constexpr difference_type begin_value = 0;
    6221  static constexpr difference_type end_value = begin_value + 1;
    6222 
    6224  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    6225  };
    6226 
    6234  struct internal_iterator
    6235  {
    6237  typename object_t::iterator object_iterator;
    6239  typename array_t::iterator array_iterator;
    6241  primitive_iterator_t primitive_iterator;
    6242 
    6244  internal_iterator() noexcept
    6245  : object_iterator(), array_iterator(), primitive_iterator()
    6246  {}
    6247  };
    6248 
    6250  template<typename IteratorType>
    6251  class iteration_proxy
    6252  {
    6253  private:
    6255  class iteration_proxy_internal
    6256  {
    6257  private:
    6259  IteratorType anchor;
    6261  size_t array_index = 0;
    6262 
    6263  public:
    6264  explicit iteration_proxy_internal(IteratorType it) noexcept
    6265  : anchor(it)
    6266  {}
    6267 
    6269  iteration_proxy_internal& operator*()
    6270  {
    6271  return *this;
    6272  }
    6273 
    6275  iteration_proxy_internal& operator++()
    6276  {
    6277  ++anchor;
    6278  ++array_index;
    6279 
    6280  return *this;
    6281  }
    6282 
    6284  bool operator!= (const iteration_proxy_internal& o) const
    6285  {
    6286  return anchor != o.anchor;
    6287  }
    6288 
    6290  typename basic_json::string_t key() const
    6291  {
    6292  assert(anchor.m_object != nullptr);
    6293 
    6294  switch (anchor.m_object->type())
    6295  {
    6296  // use integer array index as key
    6297  case value_t::array:
    6298  {
    6299  return std::to_string(array_index);
    6300  }
    6301 
    6302  // use key from the object
    6303  case value_t::object:
    6304  {
    6305  return anchor.key();
    6306  }
    6307 
    6308  // use an empty key for all primitive types
    6309  default:
    6310  {
    6311  return "";
    6312  }
    6313  }
    6314  }
    6315 
    6317  typename IteratorType::reference value() const
    6318  {
    6319  return anchor.value();
    6320  }
    6321  };
    6322 
    6324  typename IteratorType::reference container;
    6325 
    6326  public:
    6328  explicit iteration_proxy(typename IteratorType::reference cont)
    6329  : container(cont)
    6330  {}
    6331 
    6333  iteration_proxy_internal begin() noexcept
    6334  {
    6335  return iteration_proxy_internal(container.begin());
    6336  }
    6337 
    6339  iteration_proxy_internal end() noexcept
    6340  {
    6341  return iteration_proxy_internal(container.end());
    6342  }
    6343  };
    6344 
    6345  public:
    6359  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    6360  {
    6362  friend class basic_json;
    6363 
    6364  public:
    6374  using iterator_category = std::bidirectional_iterator_tag;
    6375 
    6377  const_iterator() = default;
    6378 
    6380  explicit const_iterator(pointer object) noexcept
    6381  : m_object(object)
    6382  {
    6383  assert(m_object != nullptr);
    6384 
    6385  switch (m_object->m_type)
    6386  {
    6388  {
    6389  m_it.object_iterator = typename object_t::iterator();
    6390  break;
    6391  }
    6392 
    6394  {
    6395  m_it.array_iterator = typename array_t::iterator();
    6396  break;
    6397  }
    6398 
    6399  default:
    6400  {
    6401  m_it.primitive_iterator = primitive_iterator_t();
    6402  break;
    6403  }
    6404  }
    6405  }
    6406 
    6408  explicit const_iterator(const iterator& other) noexcept
    6409  : m_object(other.m_object)
    6410  {
    6411  assert(m_object != nullptr);
    6412 
    6413  switch (m_object->m_type)
    6414  {
    6416  {
    6417  m_it.object_iterator = other.m_it.object_iterator;
    6418  break;
    6419  }
    6420 
    6422  {
    6423  m_it.array_iterator = other.m_it.array_iterator;
    6424  break;
    6425  }
    6426 
    6427  default:
    6428  {
    6429  m_it.primitive_iterator = other.m_it.primitive_iterator;
    6430  break;
    6431  }
    6432  }
    6433  }
    6434 
    6436  const_iterator(const const_iterator& other) noexcept
    6437  : m_object(other.m_object), m_it(other.m_it)
    6438  {}
    6439 
    6442  std::is_nothrow_move_constructible<pointer>::value and
    6443  std::is_nothrow_move_assignable<pointer>::value and
    6444  std::is_nothrow_move_constructible<internal_iterator>::value and
    6445  std::is_nothrow_move_assignable<internal_iterator>::value
    6446  )
    6447  {
    6448  std::swap(m_object, other.m_object);
    6449  std::swap(m_it, other.m_it);
    6450  return *this;
    6451  }
    6452 
    6453  private:
    6455  void set_begin() noexcept
    6456  {
    6457  assert(m_object != nullptr);
    6458 
    6459  switch (m_object->m_type)
    6460  {
    6462  {
    6463  assert(m_object->m_value.object != nullptr);
    6464  m_it.object_iterator = m_object->m_value.object->begin();
    6465  break;
    6466  }
    6467 
    6469  {
    6470  assert(m_object->m_value.array != nullptr);
    6471  m_it.array_iterator = m_object->m_value.array->begin();
    6472  break;
    6473  }
    6474 
    6476  {
    6477  // set to end so begin()==end() is true: null is empty
    6478  m_it.primitive_iterator.set_end();
    6479  break;
    6480  }
    6481 
    6482  default:
    6483  {
    6484  m_it.primitive_iterator.set_begin();
    6485  break;
    6486  }
    6487  }
    6488  }
    6489 
    6491  void set_end() noexcept
    6492  {
    6493  assert(m_object != nullptr);
    6494 
    6495  switch (m_object->m_type)
    6496  {
    6498  {
    6499  assert(m_object->m_value.object != nullptr);
    6500  m_it.object_iterator = m_object->m_value.object->end();
    6501  break;
    6502  }
    6503 
    6505  {
    6506  assert(m_object->m_value.array != nullptr);
    6507  m_it.array_iterator = m_object->m_value.array->end();
    6508  break;
    6509  }
    6510 
    6511  default:
    6512  {
    6513  m_it.primitive_iterator.set_end();
    6514  break;
    6515  }
    6516  }
    6517  }
    6518 
    6519  public:
    6522  {
    6523  assert(m_object != nullptr);
    6524 
    6525  switch (m_object->m_type)
    6526  {
    6528  {
    6529  assert(m_object->m_value.object);
    6530  assert(m_it.object_iterator != m_object->m_value.object->end());
    6531  return m_it.object_iterator->second;
    6532  }
    6533 
    6535  {
    6536  assert(m_object->m_value.array);
    6537  assert(m_it.array_iterator != m_object->m_value.array->end());
    6538  return *m_it.array_iterator;
    6539  }
    6540 
    6542  {
    6543  throw std::out_of_range("cannot get value");
    6544  }
    6545 
    6546  default:
    6547  {
    6548  if (m_it.primitive_iterator.is_begin())
    6549  {
    6550  return *m_object;
    6551  }
    6552  else
    6553  {
    6554  throw std::out_of_range("cannot get value");
    6555  }
    6556  }
    6557  }
    6558  }
    6559 
    6562  {
    6563  assert(m_object != nullptr);
    6564 
    6565  switch (m_object->m_type)
    6566  {
    6568  {
    6569  assert(m_object->m_value.object);
    6570  assert(m_it.object_iterator != m_object->m_value.object->end());
    6571  return &(m_it.object_iterator->second);
    6572  }
    6573 
    6575  {
    6576  assert(m_object->m_value.array);
    6577  assert(m_it.array_iterator != m_object->m_value.array->end());
    6578  return &*m_it.array_iterator;
    6579  }
    6580 
    6581  default:
    6582  {
    6583  if (m_it.primitive_iterator.is_begin())
    6584  {
    6585  return m_object;
    6586  }
    6587  else
    6588  {
    6589  throw std::out_of_range("cannot get value");
    6590  }
    6591  }
    6592  }
    6593  }
    6594 
    6597  {
    6598  auto result = *this;
    6599  ++(*this);
    6600  return result;
    6601  }
    6602 
    6605  {
    6606  assert(m_object != nullptr);
    6607 
    6608  switch (m_object->m_type)
    6609  {
    6611  {
    6612  ++m_it.object_iterator;
    6613  break;
    6614  }
    6615 
    6617  {
    6618  ++m_it.array_iterator;
    6619  break;
    6620  }
    6621 
    6622  default:
    6623  {
    6624  ++m_it.primitive_iterator;
    6625  break;
    6626  }
    6627  }
    6628 
    6629  return *this;
    6630  }
    6631 
    6634  {
    6635  auto result = *this;
    6636  --(*this);
    6637  return result;
    6638  }
    6639 
    6642  {
    6643  assert(m_object != nullptr);
    6644 
    6645  switch (m_object->m_type)
    6646  {
    6648  {
    6649  --m_it.object_iterator;
    6650  break;
    6651  }
    6652 
    6654  {
    6655  --m_it.array_iterator;
    6656  break;
    6657  }
    6658 
    6659  default:
    6660  {
    6661  --m_it.primitive_iterator;
    6662  break;
    6663  }
    6664  }
    6665 
    6666  return *this;
    6667  }
    6668 
    6670  bool operator==(const const_iterator& other) const
    6671  {
    6672  // if objects are not the same, the comparison is undefined
    6673  if (m_object != other.m_object)
    6674  {
    6675  throw std::domain_error("cannot compare iterators of different containers");
    6676  }
    6677 
    6678  assert(m_object != nullptr);
    6679 
    6680  switch (m_object->m_type)
    6681  {
    6683  {
    6684  return (m_it.object_iterator == other.m_it.object_iterator);
    6685  }
    6686 
    6688  {
    6689  return (m_it.array_iterator == other.m_it.array_iterator);
    6690  }
    6691 
    6692  default:
    6693  {
    6694  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6695  }
    6696  }
    6697  }
    6698 
    6700  bool operator!=(const const_iterator& other) const
    6701  {
    6702  return not operator==(other);
    6703  }
    6704 
    6706  bool operator<(const const_iterator& other) const
    6707  {
    6708  // if objects are not the same, the comparison is undefined
    6709  if (m_object != other.m_object)
    6710  {
    6711  throw std::domain_error("cannot compare iterators of different containers");
    6712  }
    6713 
    6714  assert(m_object != nullptr);
    6715 
    6716  switch (m_object->m_type)
    6717  {
    6719  {
    6720  throw std::domain_error("cannot compare order of object iterators");
    6721  }
    6722 
    6724  {
    6725  return (m_it.array_iterator < other.m_it.array_iterator);
    6726  }
    6727 
    6728  default:
    6729  {
    6730  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6731  }
    6732  }
    6733  }
    6734 
    6736  bool operator<=(const const_iterator& other) const
    6737  {
    6738  return not other.operator < (*this);
    6739  }
    6740 
    6742  bool operator>(const const_iterator& other) const
    6743  {
    6744  return not operator<=(other);
    6745  }
    6746 
    6748  bool operator>=(const const_iterator& other) const
    6749  {
    6750  return not operator<(other);
    6751  }
    6752 
    6755  {
    6756  assert(m_object != nullptr);
    6757 
    6758  switch (m_object->m_type)
    6759  {
    6761  {
    6762  throw std::domain_error("cannot use offsets with object iterators");
    6763  }
    6764 
    6766  {
    6767  m_it.array_iterator += i;
    6768  break;
    6769  }
    6770 
    6771  default:
    6772  {
    6773  m_it.primitive_iterator += i;
    6774  break;
    6775  }
    6776  }
    6777 
    6778  return *this;
    6779  }
    6780 
    6783  {
    6784  return operator+=(-i);
    6785  }
    6786 
    6789  {
    6790  auto result = *this;
    6791  result += i;
    6792  return result;
    6793  }
    6794 
    6797  {
    6798  auto result = *this;
    6799  result -= i;
    6800  return result;
    6801  }
    6802 
    6805  {
    6806  assert(m_object != nullptr);
    6807 
    6808  switch (m_object->m_type)
    6809  {
    6811  {
    6812  throw std::domain_error("cannot use offsets with object iterators");
    6813  }
    6814 
    6816  {
    6817  return m_it.array_iterator - other.m_it.array_iterator;
    6818  }
    6819 
    6820  default:
    6821  {
    6822  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6823  }
    6824  }
    6825  }
    6826 
    6829  {
    6830  assert(m_object != nullptr);
    6831 
    6832  switch (m_object->m_type)
    6833  {
    6835  {
    6836  throw std::domain_error("cannot use operator[] for object iterators");
    6837  }
    6838 
    6840  {
    6841  return *(m_it.array_iterator + n);
    6842  }
    6843 
    6845  {
    6846  throw std::out_of_range("cannot get value");
    6847  }
    6848 
    6849  default:
    6850  {
    6851  if (m_it.primitive_iterator == -n)
    6852  {
    6853  return *m_object;
    6854  }
    6855  else
    6856  {
    6857  throw std::out_of_range("cannot get value");
    6858  }
    6859  }
    6860  }
    6861  }
    6862 
    6864  typename object_t::key_type key() const
    6865  {
    6866  assert(m_object != nullptr);
    6867 
    6868  if (m_object->is_object())
    6869  {
    6870  return m_it.object_iterator->first;
    6871  }
    6872  else
    6873  {
    6874  throw std::domain_error("cannot use key() for non-object iterators");
    6875  }
    6876  }
    6877 
    6880  {
    6881  return operator*();
    6882  }
    6883 
    6884  private:
    6886  pointer m_object = nullptr;
    6888  internal_iterator m_it = internal_iterator();
    6889  };
    6890 
    6903  class iterator : public const_iterator
    6904  {
    6905  public:
    6907  using pointer = typename basic_json::pointer;
    6909 
    6911  iterator() = default;
    6912 
    6914  explicit iterator(pointer object) noexcept
    6915  : base_iterator(object)
    6916  {}
    6917 
    6919  iterator(const iterator& other) noexcept
    6920  : base_iterator(other)
    6921  {}
    6922 
    6924  iterator& operator=(iterator other) noexcept(
    6925  std::is_nothrow_move_constructible<pointer>::value and
    6926  std::is_nothrow_move_assignable<pointer>::value and
    6927  std::is_nothrow_move_constructible<internal_iterator>::value and
    6928  std::is_nothrow_move_assignable<internal_iterator>::value
    6929  )
    6930  {
    6931  base_iterator::operator=(other);
    6932  return *this;
    6933  }
    6934 
    6937  {
    6938  return const_cast<reference>(base_iterator::operator*());
    6939  }
    6940 
    6943  {
    6944  return const_cast<pointer>(base_iterator::operator->());
    6945  }
    6946 
    6949  {
    6950  iterator result = *this;
    6951  base_iterator::operator++();
    6952  return result;
    6953  }
    6954 
    6957  {
    6958  base_iterator::operator++();
    6959  return *this;
    6960  }
    6961 
    6964  {
    6965  iterator result = *this;
    6966  base_iterator::operator--();
    6967  return result;
    6968  }
    6969 
    6972  {
    6973  base_iterator::operator--();
    6974  return *this;
    6975  }
    6976 
    6979  {
    6980  base_iterator::operator+=(i);
    6981  return *this;
    6982  }
    6983 
    6986  {
    6987  base_iterator::operator-=(i);
    6988  return *this;
    6989  }
    6990 
    6993  {
    6994  auto result = *this;
    6995  result += i;
    6996  return result;
    6997  }
    6998 
    7001  {
    7002  auto result = *this;
    7003  result -= i;
    7004  return result;
    7005  }
    7006 
    7008  difference_type operator-(const iterator& other) const
    7009  {
    7010  return base_iterator::operator-(other);
    7011  }
    7012 
    7015  {
    7016  return const_cast<reference>(base_iterator::operator[](n));
    7017  }
    7018 
    7021  {
    7022  return const_cast<reference>(base_iterator::value());
    7023  }
    7024  };
    7025 
    7043  template<typename Base>
    7044  class json_reverse_iterator : public std::reverse_iterator<Base>
    7045  {
    7046  public:
    7048  using base_iterator = std::reverse_iterator<Base>;
    7050  using reference = typename Base::reference;
    7051 
    7053  json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept
    7054  : base_iterator(it)
    7055  {}
    7056 
    7059  : base_iterator(it)
    7060  {}
    7061 
    7064  {
    7065  return base_iterator::operator++(1);
    7066  }
    7067 
    7070  {
    7071  base_iterator::operator++();
    7072  return *this;
    7073  }
    7074 
    7077  {
    7078  return base_iterator::operator--(1);
    7079  }
    7080 
    7083  {
    7084  base_iterator::operator--();
    7085  return *this;
    7086  }
    7087 
    7090  {
    7091  base_iterator::operator+=(i);
    7092  return *this;
    7093  }
    7094 
    7097  {
    7098  auto result = *this;
    7099  result += i;
    7100  return result;
    7101  }
    7102 
    7105  {
    7106  auto result = *this;
    7107  result -= i;
    7108  return result;
    7109  }
    7110 
    7113  {
    7114  return this->base() - other.base();
    7115  }
    7116 
    7119  {
    7120  return *(this->operator+(n));
    7121  }
    7122 
    7124  typename object_t::key_type key() const
    7125  {
    7126  auto it = --this->base();
    7127  return it.key();
    7128  }
    7129 
    7132  {
    7133  auto it = --this->base();
    7134  return it.operator * ();
    7135  }
    7136  };
    7137 
    7138 
    7139  private:
    7141  // lexer and parser //
    7143 
    7151  class lexer
    7152  {
    7153  public:
    7155  enum class token_type
    7156  {
    7157  uninitialized,
    7158  literal_true,
    7159  literal_false,
    7160  literal_null,
    7161  value_string,
    7162  value_number,
    7163  begin_array,
    7164  begin_object,
    7165  end_array,
    7166  end_object,
    7167  name_separator,
    7168  value_separator,
    7169  parse_error,
    7170  end_of_input
    7171  };
    7172 
    7174  using lexer_char_t = unsigned char;
    7175 
    7177  explicit lexer(const string_t& s) noexcept
    7178  : m_stream(nullptr), m_buffer(s)
    7179  {
    7180  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    7181  assert(m_content != nullptr);
    7182  m_start = m_cursor = m_content;
    7183  m_limit = m_content + s.size();
    7184  }
    7185 
    7187  explicit lexer(std::istream* s) noexcept
    7188  : m_stream(s), m_buffer()
    7189  {
    7190  assert(m_stream != nullptr);
    7191  getline(*m_stream, m_buffer);
    7192  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7193  assert(m_content != nullptr);
    7194  m_start = m_cursor = m_content;
    7195  m_limit = m_content + m_buffer.size();
    7196  }
    7197 
    7199  lexer() = default;
    7200 
    7201  // switch off unwanted functions
    7202  lexer(const lexer&) = delete;
    7203  lexer operator=(const lexer&) = delete;
    7204 
    7220  static string_t to_unicode(const std::size_t codepoint1,
    7221  const std::size_t codepoint2 = 0)
    7222  {
    7223  // calculate the codepoint from the given code points
    7224  std::size_t codepoint = codepoint1;
    7225 
    7226  // check if codepoint1 is a high surrogate
    7227  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    7228  {
    7229  // check if codepoint2 is a low surrogate
    7230  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    7231  {
    7232  codepoint =
    7233  // high surrogate occupies the most significant 22 bits
    7234  (codepoint1 << 10)
    7235  // low surrogate occupies the least significant 15 bits
    7236  + codepoint2
    7237  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    7238  // in the result so we have to subtract with:
    7239  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    7240  - 0x35FDC00;
    7241  }
    7242  else
    7243  {
    7244  throw std::invalid_argument("missing or wrong low surrogate");
    7245  }
    7246  }
    7247 
    7248  string_t result;
    7249 
    7250  if (codepoint < 0x80)
    7251  {
    7252  // 1-byte characters: 0xxxxxxx (ASCII)
    7253  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    7254  }
    7255  else if (codepoint <= 0x7ff)
    7256  {
    7257  // 2-byte characters: 110xxxxx 10xxxxxx
    7258  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    7259  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7260  }
    7261  else if (codepoint <= 0xffff)
    7262  {
    7263  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    7264  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    7265  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7266  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7267  }
    7268  else if (codepoint <= 0x10ffff)
    7269  {
    7270  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    7271  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    7272  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    7273  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7274  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7275  }
    7276  else
    7277  {
    7278  throw std::out_of_range("code points above 0x10FFFF are invalid");
    7279  }
    7280 
    7281  return result;
    7282  }
    7283 
    7285  static std::string token_type_name(token_type t)
    7286  {
    7287  switch (t)
    7288  {
    7289  case token_type::uninitialized:
    7290  return "<uninitialized>";
    7291  case token_type::literal_true:
    7292  return "true literal";
    7293  case token_type::literal_false:
    7294  return "false literal";
    7295  case token_type::literal_null:
    7296  return "null literal";
    7297  case token_type::value_string:
    7298  return "string literal";
    7299  case token_type::value_number:
    7300  return "number literal";
    7301  case token_type::begin_array:
    7302  return "'['";
    7303  case token_type::begin_object:
    7304  return "'{'";
    7305  case token_type::end_array:
    7306  return "']'";
    7307  case token_type::end_object:
    7308  return "'}'";
    7309  case token_type::name_separator:
    7310  return "':'";
    7311  case token_type::value_separator:
    7312  return "','";
    7313  case token_type::parse_error:
    7314  return "<parse error>";
    7315  case token_type::end_of_input:
    7316  return "end of input";
    7317  default:
    7318  {
    7319  // catch non-enum values
    7320  return "unknown token"; // LCOV_EXCL_LINE
    7321  }
    7322  }
    7323  }
    7324 
    7335  token_type scan() noexcept
    7336  {
    7337  // pointer for backtracking information
    7338  m_marker = nullptr;
    7339 
    7340  // remember the begin of the token
    7341  m_start = m_cursor;
    7342  assert(m_start != nullptr);
    7343 
    7344 
    7345  {
    7346  lexer_char_t yych;
    7347  unsigned int yyaccept = 0;
    7348  static const unsigned char yybm[] =
    7349  {
    7350  0, 0, 0, 0, 0, 0, 0, 0,
    7351  0, 32, 32, 0, 0, 32, 0, 0,
    7352  128, 128, 128, 128, 128, 128, 128, 128,
    7353  128, 128, 128, 128, 128, 128, 128, 128,
    7354  160, 128, 0, 128, 128, 128, 128, 128,
    7355  128, 128, 128, 128, 128, 128, 128, 128,
    7356  192, 192, 192, 192, 192, 192, 192, 192,
    7357  192, 192, 128, 128, 128, 128, 128, 128,
    7358  128, 128, 128, 128, 128, 128, 128, 128,
    7359  128, 128, 128, 128, 128, 128, 128, 128,
    7360  128, 128, 128, 128, 128, 128, 128, 128,
    7361  128, 128, 128, 128, 0, 128, 128, 128,
    7362  128, 128, 128, 128, 128, 128, 128, 128,
    7363  128, 128, 128, 128, 128, 128, 128, 128,
    7364  128, 128, 128, 128, 128, 128, 128, 128,
    7365  128, 128, 128, 128, 128, 128, 128, 128,
    7366  128, 128, 128, 128, 128, 128, 128, 128,
    7367  128, 128, 128, 128, 128, 128, 128, 128,
    7368  128, 128, 128, 128, 128, 128, 128, 128,
    7369  128, 128, 128, 128, 128, 128, 128, 128,
    7370  128, 128, 128, 128, 128, 128, 128, 128,
    7371  128, 128, 128, 128, 128, 128, 128, 128,
    7372  128, 128, 128, 128, 128, 128, 128, 128,
    7373  128, 128, 128, 128, 128, 128, 128, 128,
    7374  128, 128, 128, 128, 128, 128, 128, 128,
    7375  128, 128, 128, 128, 128, 128, 128, 128,
    7376  128, 128, 128, 128, 128, 128, 128, 128,
    7377  128, 128, 128, 128, 128, 128, 128, 128,
    7378  128, 128, 128, 128, 128, 128, 128, 128,
    7379  128, 128, 128, 128, 128, 128, 128, 128,
    7380  128, 128, 128, 128, 128, 128, 128, 128,
    7381  128, 128, 128, 128, 128, 128, 128, 128,
    7382  };
    7383  if ((m_limit - m_cursor) < 5)
    7384  {
    7385  yyfill(); // LCOV_EXCL_LINE;
    7386  }
    7387  yych = *m_cursor;
    7388  if (yybm[0 + yych] & 32)
    7389  {
    7390  goto basic_json_parser_6;
    7391  }
    7392  if (yych <= '\\')
    7393  {
    7394  if (yych <= '-')
    7395  {
    7396  if (yych <= '"')
    7397  {
    7398  if (yych <= 0x00)
    7399  {
    7400  goto basic_json_parser_2;
    7401  }
    7402  if (yych <= '!')
    7403  {
    7404  goto basic_json_parser_4;
    7405  }
    7406  goto basic_json_parser_9;
    7407  }
    7408  else
    7409  {
    7410  if (yych <= '+')
    7411  {
    7412  goto basic_json_parser_4;
    7413  }
    7414  if (yych <= ',')
    7415  {
    7416  goto basic_json_parser_10;
    7417  }
    7418  goto basic_json_parser_12;
    7419  }
    7420  }
    7421  else
    7422  {
    7423  if (yych <= '9')
    7424  {
    7425  if (yych <= '/')
    7426  {
    7427  goto basic_json_parser_4;
    7428  }
    7429  if (yych <= '0')
    7430  {
    7431  goto basic_json_parser_13;
    7432  }
    7433  goto basic_json_parser_15;
    7434  }
    7435  else
    7436  {
    7437  if (yych <= ':')
    7438  {
    7439  goto basic_json_parser_17;
    7440  }
    7441  if (yych == '[')
    7442  {
    7443  goto basic_json_parser_19;
    7444  }
    7445  goto basic_json_parser_4;
    7446  }
    7447  }
    7448  }
    7449  else
    7450  {
    7451  if (yych <= 't')
    7452  {
    7453  if (yych <= 'f')
    7454  {
    7455  if (yych <= ']')
    7456  {
    7457  goto basic_json_parser_21;
    7458  }
    7459  if (yych <= 'e')
    7460  {
    7461  goto basic_json_parser_4;
    7462  }
    7463  goto basic_json_parser_23;
    7464  }
    7465  else
    7466  {
    7467  if (yych == 'n')
    7468  {
    7469  goto basic_json_parser_24;
    7470  }
    7471  if (yych <= 's')
    7472  {
    7473  goto basic_json_parser_4;
    7474  }
    7475  goto basic_json_parser_25;
    7476  }
    7477  }
    7478  else
    7479  {
    7480  if (yych <= '|')
    7481  {
    7482  if (yych == '{')
    7483  {
    7484  goto basic_json_parser_26;
    7485  }
    7486  goto basic_json_parser_4;
    7487  }
    7488  else
    7489  {
    7490  if (yych <= '}')
    7491  {
    7492  goto basic_json_parser_28;
    7493  }
    7494  if (yych == 0xEF)
    7495  {
    7496  goto basic_json_parser_30;
    7497  }
    7498  goto basic_json_parser_4;
    7499  }
    7500  }
    7501  }
    7502 basic_json_parser_2:
    7503  ++m_cursor;
    7504  {
    7505  return token_type::end_of_input;
    7506  }
    7507 basic_json_parser_4:
    7508  ++m_cursor;
    7509 basic_json_parser_5:
    7510  {
    7511  return token_type::parse_error;
    7512  }
    7513 basic_json_parser_6:
    7514  ++m_cursor;
    7515  if (m_limit <= m_cursor)
    7516  {
    7517  yyfill(); // LCOV_EXCL_LINE;
    7518  }
    7519  yych = *m_cursor;
    7520  if (yybm[0 + yych] & 32)
    7521  {
    7522  goto basic_json_parser_6;
    7523  }
    7524  {
    7525  return scan();
    7526  }
    7527 basic_json_parser_9:
    7528  yyaccept = 0;
    7529  yych = *(m_marker = ++m_cursor);
    7530  if (yych <= 0x0F)
    7531  {
    7532  goto basic_json_parser_5;
    7533  }
    7534  goto basic_json_parser_32;
    7535 basic_json_parser_10:
    7536  ++m_cursor;
    7537  {
    7538  return token_type::value_separator;
    7539  }
    7540 basic_json_parser_12:
    7541  yych = *++m_cursor;
    7542  if (yych <= '/')
    7543  {
    7544  goto basic_json_parser_5;
    7545  }
    7546  if (yych <= '0')
    7547  {
    7548  goto basic_json_parser_13;
    7549  }
    7550  if (yych <= '9')
    7551  {
    7552  goto basic_json_parser_15;
    7553  }
    7554  goto basic_json_parser_5;
    7555 basic_json_parser_13:
    7556  yyaccept = 1;
    7557  yych = *(m_marker = ++m_cursor);
    7558  if (yych <= 'D')
    7559  {
    7560  if (yych == '.')
    7561  {
    7562  goto basic_json_parser_37;
    7563  }
    7564  }
    7565  else
    7566  {
    7567  if (yych <= 'E')
    7568  {
    7569  goto basic_json_parser_38;
    7570  }
    7571  if (yych == 'e')
    7572  {
    7573  goto basic_json_parser_38;
    7574  }
    7575  }
    7576 basic_json_parser_14:
    7577  {
    7578  return token_type::value_number;
    7579  }
    7580 basic_json_parser_15:
    7581  yyaccept = 1;
    7582  m_marker = ++m_cursor;
    7583  if ((m_limit - m_cursor) < 3)
    7584  {
    7585  yyfill(); // LCOV_EXCL_LINE;
    7586  }
    7587  yych = *m_cursor;
    7588  if (yybm[0 + yych] & 64)
    7589  {
    7590  goto basic_json_parser_15;
    7591  }
    7592  if (yych <= 'D')
    7593  {
    7594  if (yych == '.')
    7595  {
    7596  goto basic_json_parser_37;
    7597  }
    7598  goto basic_json_parser_14;
    7599  }
    7600  else
    7601  {
    7602  if (yych <= 'E')
    7603  {
    7604  goto basic_json_parser_38;
    7605  }
    7606  if (yych == 'e')
    7607  {
    7608  goto basic_json_parser_38;
    7609  }
    7610  goto basic_json_parser_14;
    7611  }
    7612 basic_json_parser_17:
    7613  ++m_cursor;
    7614  {
    7615  return token_type::name_separator;
    7616  }
    7617 basic_json_parser_19:
    7618  ++m_cursor;
    7619  {
    7620  return token_type::begin_array;
    7621  }
    7622 basic_json_parser_21:
    7623  ++m_cursor;
    7624  {
    7625  return token_type::end_array;
    7626  }
    7627 basic_json_parser_23:
    7628  yyaccept = 0;
    7629  yych = *(m_marker = ++m_cursor);
    7630  if (yych == 'a')
    7631  {
    7632  goto basic_json_parser_39;
    7633  }
    7634  goto basic_json_parser_5;
    7635 basic_json_parser_24:
    7636  yyaccept = 0;
    7637  yych = *(m_marker = ++m_cursor);
    7638  if (yych == 'u')
    7639  {
    7640  goto basic_json_parser_40;
    7641  }
    7642  goto basic_json_parser_5;
    7643 basic_json_parser_25:
    7644  yyaccept = 0;
    7645  yych = *(m_marker = ++m_cursor);
    7646  if (yych == 'r')
    7647  {
    7648  goto basic_json_parser_41;
    7649  }
    7650  goto basic_json_parser_5;
    7651 basic_json_parser_26:
    7652  ++m_cursor;
    7653  {
    7654  return token_type::begin_object;
    7655  }
    7656 basic_json_parser_28:
    7657  ++m_cursor;
    7658  {
    7659  return token_type::end_object;
    7660  }
    7661 basic_json_parser_30:
    7662  yyaccept = 0;
    7663  yych = *(m_marker = ++m_cursor);
    7664  if (yych == 0xBB)
    7665  {
    7666  goto basic_json_parser_42;
    7667  }
    7668  goto basic_json_parser_5;
    7669 basic_json_parser_31:
    7670  ++m_cursor;
    7671  if (m_limit <= m_cursor)
    7672  {
    7673  yyfill(); // LCOV_EXCL_LINE;
    7674  }
    7675  yych = *m_cursor;
    7676 basic_json_parser_32:
    7677  if (yybm[0 + yych] & 128)
    7678  {
    7679  goto basic_json_parser_31;
    7680  }
    7681  if (yych <= 0x0F)
    7682  {
    7683  goto basic_json_parser_33;
    7684  }
    7685  if (yych <= '"')
    7686  {
    7687  goto basic_json_parser_34;
    7688  }
    7689  goto basic_json_parser_36;
    7690 basic_json_parser_33:
    7691  m_cursor = m_marker;
    7692  if (yyaccept == 0)
    7693  {
    7694  goto basic_json_parser_5;
    7695  }
    7696  else
    7697  {
    7698  goto basic_json_parser_14;
    7699  }
    7700 basic_json_parser_34:
    7701  ++m_cursor;
    7702  {
    7703  return token_type::value_string;
    7704  }
    7705 basic_json_parser_36:
    7706  ++m_cursor;
    7707  if (m_limit <= m_cursor)
    7708  {
    7709  yyfill(); // LCOV_EXCL_LINE;
    7710  }
    7711  yych = *m_cursor;
    7712  if (yych <= 'e')
    7713  {
    7714  if (yych <= '/')
    7715  {
    7716  if (yych == '"')
    7717  {
    7718  goto basic_json_parser_31;
    7719  }
    7720  if (yych <= '.')
    7721  {
    7722  goto basic_json_parser_33;
    7723  }
    7724  goto basic_json_parser_31;
    7725  }
    7726  else
    7727  {
    7728  if (yych <= '\\')
    7729  {
    7730  if (yych <= '[')
    7731  {
    7732  goto basic_json_parser_33;
    7733  }
    7734  goto basic_json_parser_31;
    7735  }
    7736  else
    7737  {
    7738  if (yych == 'b')
    7739  {
    7740  goto basic_json_parser_31;
    7741  }
    7742  goto basic_json_parser_33;
    7743  }
    7744  }
    7745  }
    7746  else
    7747  {
    7748  if (yych <= 'q')
    7749  {
    7750  if (yych <= 'f')
    7751  {
    7752  goto basic_json_parser_31;
    7753  }
    7754  if (yych == 'n')
    7755  {
    7756  goto basic_json_parser_31;
    7757  }
    7758  goto basic_json_parser_33;
    7759  }
    7760  else
    7761  {
    7762  if (yych <= 's')
    7763  {
    7764  if (yych <= 'r')
    7765  {
    7766  goto basic_json_parser_31;
    7767  }
    7768  goto basic_json_parser_33;
    7769  }
    7770  else
    7771  {
    7772  if (yych <= 't')
    7773  {
    7774  goto basic_json_parser_31;
    7775  }
    7776  if (yych <= 'u')
    7777  {
    7778  goto basic_json_parser_43;
    7779  }
    7780  goto basic_json_parser_33;
    7781  }
    7782  }
    7783  }
    7784 basic_json_parser_37:
    7785  yych = *++m_cursor;
    7786  if (yych <= '/')
    7787  {
    7788  goto basic_json_parser_33;
    7789  }
    7790  if (yych <= '9')
    7791  {
    7792  goto basic_json_parser_44;
    7793  }
    7794  goto basic_json_parser_33;
    7795 basic_json_parser_38:
    7796  yych = *++m_cursor;
    7797  if (yych <= ',')
    7798  {
    7799  if (yych == '+')
    7800  {
    7801  goto basic_json_parser_46;
    7802  }
    7803  goto basic_json_parser_33;
    7804  }
    7805  else
    7806  {
    7807  if (yych <= '-')
    7808  {
    7809  goto basic_json_parser_46;
    7810  }
    7811  if (yych <= '/')
    7812  {
    7813  goto basic_json_parser_33;
    7814  }
    7815  if (yych <= '9')
    7816  {
    7817  goto basic_json_parser_47;
    7818  }
    7819  goto basic_json_parser_33;
    7820  }
    7821 basic_json_parser_39:
    7822  yych = *++m_cursor;
    7823  if (yych == 'l')
    7824  {
    7825  goto basic_json_parser_49;
    7826  }
    7827  goto basic_json_parser_33;
    7828 basic_json_parser_40:
    7829  yych = *++m_cursor;
    7830  if (yych == 'l')
    7831  {
    7832  goto basic_json_parser_50;
    7833  }
    7834  goto basic_json_parser_33;
    7835 basic_json_parser_41:
    7836  yych = *++m_cursor;
    7837  if (yych == 'u')
    7838  {
    7839  goto basic_json_parser_51;
    7840  }
    7841  goto basic_json_parser_33;
    7842 basic_json_parser_42:
    7843  yych = *++m_cursor;
    7844  if (yych == 0xBF)
    7845  {
    7846  goto basic_json_parser_52;
    7847  }
    7848  goto basic_json_parser_33;
    7849 basic_json_parser_43:
    7850  ++m_cursor;
    7851  if (m_limit <= m_cursor)
    7852  {
    7853  yyfill(); // LCOV_EXCL_LINE;
    7854  }
    7855  yych = *m_cursor;
    7856  if (yych <= '@')
    7857  {
    7858  if (yych <= '/')
    7859  {
    7860  goto basic_json_parser_33;
    7861  }
    7862  if (yych <= '9')
    7863  {
    7864  goto basic_json_parser_54;
    7865  }
    7866  goto basic_json_parser_33;
    7867  }
    7868  else
    7869  {
    7870  if (yych <= 'F')
    7871  {
    7872  goto basic_json_parser_54;
    7873  }
    7874  if (yych <= '`')
    7875  {
    7876  goto basic_json_parser_33;
    7877  }
    7878  if (yych <= 'f')
    7879  {
    7880  goto basic_json_parser_54;
    7881  }
    7882  goto basic_json_parser_33;
    7883  }
    7884 basic_json_parser_44:
    7885  yyaccept = 1;
    7886  m_marker = ++m_cursor;
    7887  if ((m_limit - m_cursor) < 3)
    7888  {
    7889  yyfill(); // LCOV_EXCL_LINE;
    7890  }
    7891  yych = *m_cursor;
    7892  if (yych <= 'D')
    7893  {
    7894  if (yych <= '/')
    7895  {
    7896  goto basic_json_parser_14;
    7897  }
    7898  if (yych <= '9')
    7899  {
    7900  goto basic_json_parser_44;
    7901  }
    7902  goto basic_json_parser_14;
    7903  }
    7904  else
    7905  {
    7906  if (yych <= 'E')
    7907  {
    7908  goto basic_json_parser_38;
    7909  }
    7910  if (yych == 'e')
    7911  {
    7912  goto basic_json_parser_38;
    7913  }
    7914  goto basic_json_parser_14;
    7915  }
    7916 basic_json_parser_46:
    7917  yych = *++m_cursor;
    7918  if (yych <= '/')
    7919  {
    7920  goto basic_json_parser_33;
    7921  }
    7922  if (yych >= ':')
    7923  {
    7924  goto basic_json_parser_33;
    7925  }
    7926 basic_json_parser_47:
    7927  ++m_cursor;
    7928  if (m_limit <= m_cursor)
    7929  {
    7930  yyfill(); // LCOV_EXCL_LINE;
    7931  }
    7932  yych = *m_cursor;
    7933  if (yych <= '/')
    7934  {
    7935  goto basic_json_parser_14;
    7936  }
    7937  if (yych <= '9')
    7938  {
    7939  goto basic_json_parser_47;
    7940  }
    7941  goto basic_json_parser_14;
    7942 basic_json_parser_49:
    7943  yych = *++m_cursor;
    7944  if (yych == 's')
    7945  {
    7946  goto basic_json_parser_55;
    7947  }
    7948  goto basic_json_parser_33;
    7949 basic_json_parser_50:
    7950  yych = *++m_cursor;
    7951  if (yych == 'l')
    7952  {
    7953  goto basic_json_parser_56;
    7954  }
    7955  goto basic_json_parser_33;
    7956 basic_json_parser_51:
    7957  yych = *++m_cursor;
    7958  if (yych == 'e')
    7959  {
    7960  goto basic_json_parser_58;
    7961  }
    7962  goto basic_json_parser_33;
    7963 basic_json_parser_52:
    7964  ++m_cursor;
    7965  {
    7966  return scan();
    7967  }
    7968 basic_json_parser_54:
    7969  ++m_cursor;
    7970  if (m_limit <= m_cursor)
    7971  {
    7972  yyfill(); // LCOV_EXCL_LINE;
    7973  }
    7974  yych = *m_cursor;
    7975  if (yych <= '@')
    7976  {
    7977  if (yych <= '/')
    7978  {
    7979  goto basic_json_parser_33;
    7980  }
    7981  if (yych <= '9')
    7982  {
    7983  goto basic_json_parser_60;
    7984  }
    7985  goto basic_json_parser_33;
    7986  }
    7987  else
    7988  {
    7989  if (yych <= 'F')
    7990  {
    7991  goto basic_json_parser_60;
    7992  }
    7993  if (yych <= '`')
    7994  {
    7995  goto basic_json_parser_33;
    7996  }
    7997  if (yych <= 'f')
    7998  {
    7999  goto basic_json_parser_60;
    8000  }
    8001  goto basic_json_parser_33;
    8002  }
    8003 basic_json_parser_55:
    8004  yych = *++m_cursor;
    8005  if (yych == 'e')
    8006  {
    8007  goto basic_json_parser_61;
    8008  }
    8009  goto basic_json_parser_33;
    8010 basic_json_parser_56:
    8011  ++m_cursor;
    8012  {
    8013  return token_type::literal_null;
    8014  }
    8015 basic_json_parser_58:
    8016  ++m_cursor;
    8017  {
    8018  return token_type::literal_true;
    8019  }
    8020 basic_json_parser_60:
    8021  ++m_cursor;
    8022  if (m_limit <= m_cursor)
    8023  {
    8024  yyfill(); // LCOV_EXCL_LINE;
    8025  }
    8026  yych = *m_cursor;
    8027  if (yych <= '@')
    8028  {
    8029  if (yych <= '/')
    8030  {
    8031  goto basic_json_parser_33;
    8032  }
    8033  if (yych <= '9')
    8034  {
    8035  goto basic_json_parser_63;
    8036  }
    8037  goto basic_json_parser_33;
    8038  }
    8039  else
    8040  {
    8041  if (yych <= 'F')
    8042  {
    8043  goto basic_json_parser_63;
    8044  }
    8045  if (yych <= '`')
    8046  {
    8047  goto basic_json_parser_33;
    8048  }
    8049  if (yych <= 'f')
    8050  {
    8051  goto basic_json_parser_63;
    8052  }
    8053  goto basic_json_parser_33;
    8054  }
    8055 basic_json_parser_61:
    8056  ++m_cursor;
    8057  {
    8058  return token_type::literal_false;
    8059  }
    8060 basic_json_parser_63:
    8061  ++m_cursor;
    8062  if (m_limit <= m_cursor)
    8063  {
    8064  yyfill(); // LCOV_EXCL_LINE;
    8065  }
    8066  yych = *m_cursor;
    8067  if (yych <= '@')
    8068  {
    8069  if (yych <= '/')
    8070  {
    8071  goto basic_json_parser_33;
    8072  }
    8073  if (yych <= '9')
    8074  {
    8075  goto basic_json_parser_31;
    8076  }
    8077  goto basic_json_parser_33;
    8078  }
    8079  else
    8080  {
    8081  if (yych <= 'F')
    8082  {
    8083  goto basic_json_parser_31;
    8084  }
    8085  if (yych <= '`')
    8086  {
    8087  goto basic_json_parser_33;
    8088  }
    8089  if (yych <= 'f')
    8090  {
    8091  goto basic_json_parser_31;
    8092  }
    8093  goto basic_json_parser_33;
    8094  }
    8095  }
    8096 
    8097  }
    8098 
    8100  void yyfill() noexcept
    8101  {
    8102  if (m_stream == nullptr or not * m_stream)
    8103  {
    8104  return;
    8105  }
    8106 
    8107  const auto offset_start = m_start - m_content;
    8108  const auto offset_marker = m_marker - m_start;
    8109  const auto offset_cursor = m_cursor - m_start;
    8110 
    8111  m_buffer.erase(0, static_cast<size_t>(offset_start));
    8112  std::string line;
    8113  assert(m_stream != nullptr);
    8114  std::getline(*m_stream, line);
    8115  m_buffer += "\n" + line; // add line with newline symbol
    8116 
    8117  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    8118  assert(m_content != nullptr);
    8119  m_start = m_content;
    8120  m_marker = m_start + offset_marker;
    8121  m_cursor = m_start + offset_cursor;
    8122  m_limit = m_start + m_buffer.size() - 1;
    8123  }
    8124 
    8126  string_t get_token() const
    8127  {
    8128  assert(m_start != nullptr);
    8129  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    8130  static_cast<size_t>(m_cursor - m_start));
    8131  }
    8132 
    8155  string_t get_string() const
    8156  {
    8157  string_t result;
    8158  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    8159 
    8160  // iterate the result between the quotes
    8161  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    8162  {
    8163  // process escaped characters
    8164  if (*i == '\\')
    8165  {
    8166  // read next character
    8167  ++i;
    8168 
    8169  switch (*i)
    8170  {
    8171  // the default escapes
    8172  case 't':
    8173  {
    8174  result += "\t";
    8175  break;
    8176  }
    8177  case 'b':
    8178  {
    8179  result += "\b";
    8180  break;
    8181  }
    8182  case 'f':
    8183  {
    8184  result += "\f";
    8185  break;
    8186  }
    8187  case 'n':
    8188  {
    8189  result += "\n";
    8190  break;
    8191  }
    8192  case 'r':
    8193  {
    8194  result += "\r";
    8195  break;
    8196  }
    8197  case '\\':
    8198  {
    8199  result += "\\";
    8200  break;
    8201  }
    8202  case '/':
    8203  {
    8204  result += "/";
    8205  break;
    8206  }
    8207  case '"':
    8208  {
    8209  result += "\"";
    8210  break;
    8211  }
    8212 
    8213  // unicode
    8214  case 'u':
    8215  {
    8216  // get code xxxx from uxxxx
    8217  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    8218  4).c_str(), nullptr, 16);
    8219 
    8220  // check if codepoint is a high surrogate
    8221  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    8222  {
    8223  // make sure there is a subsequent unicode
    8224  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    8225  {
    8226  throw std::invalid_argument("missing low surrogate");
    8227  }
    8228 
    8229  // get code yyyy from uxxxx\uyyyy
    8230  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    8231  (i + 7), 4).c_str(), nullptr, 16);
    8232  result += to_unicode(codepoint, codepoint2);
    8233  // skip the next 10 characters (xxxx\uyyyy)
    8234  i += 10;
    8235  }
    8236  else
    8237  {
    8238  // add unicode character(s)
    8239  result += to_unicode(codepoint);
    8240  // skip the next four characters (xxxx)
    8241  i += 4;
    8242  }
    8243  break;
    8244  }
    8245  }
    8246  }
    8247  else
    8248  {
    8249  // all other characters are just copied to the end of the
    8250  // string
    8251  result.append(1, static_cast<typename string_t::value_type>(*i));
    8252  }
    8253  }
    8254 
    8255  return result;
    8256  }
    8257 
    8278  long double str_to_float_t(long double* /* type */, char** endptr) const
    8279  {
    8280  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8281  }
    8282 
    8298  double str_to_float_t(double* /* type */, char** endptr) const
    8299  {
    8300  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8301  }
    8302 
    8318  float str_to_float_t(float* /* type */, char** endptr) const
    8319  {
    8320  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8321  }
    8322 
    8344  void get_number(basic_json& result) const
    8345  {
    8346  assert(m_start != nullptr);
    8347 
    8348  const lexer::lexer_char_t* curptr = m_start;
    8349 
    8350  // accumulate the integer conversion result (unsigned for now)
    8351  number_unsigned_t value = 0;
    8352 
    8353  // maximum absolute value of the relevant integer type
    8354  number_unsigned_t max;
    8355 
    8356  // temporarily store the type to avoid unecessary bitfield access
    8357  value_t type;
    8358 
    8359  // look for sign
    8360  if (*curptr == '-')
    8361  {
    8362  type = value_t::number_integer;
    8363  max = static_cast<uint64_t>((std::numeric_limits<number_integer_t>::max)()) + 1;
    8364  curptr++;
    8365  }
    8366  else
    8367  {
    8368  type = value_t::number_unsigned;
    8369  max = static_cast<uint64_t>((std::numeric_limits<number_unsigned_t>::max)());
    8370  }
    8371 
    8372  // count the significant figures
    8373  for (; curptr < m_cursor; curptr++)
    8374  {
    8375  // quickly skip tests if a digit
    8376  if (*curptr < '0' || *curptr > '9')
    8377  {
    8378  if (*curptr == '.')
    8379  {
    8380  // don't count '.' but change to float
    8381  type = value_t::number_float;
    8382  continue;
    8383  }
    8384  // assume exponent (if not then will fail parse): change to
    8385  // float, stop counting and record exponent details
    8386  type = value_t::number_float;
    8387  break;
    8388  }
    8389 
    8390  // skip if definitely not an integer
    8391  if (type != value_t::number_float)
    8392  {
    8393  // multiply last value by ten and add the new digit
    8394  auto temp = value * 10 + *curptr - 0x30;
    8395 
    8396  // test for overflow
    8397  if (temp < value || temp > max)
    8398  {
    8399  // overflow
    8400  type = value_t::number_float;
    8401  }
    8402  else
    8403  {
    8404  // no overflow - save it
    8405  value = temp;
    8406  }
    8407  }
    8408  }
    8409 
    8410  // save the value (if not a float)
    8411  if (type == value_t::number_unsigned)
    8412  {
    8413  result.m_value.number_unsigned = value;
    8414  }
    8415  else if (type == value_t::number_integer)
    8416  {
    8417  result.m_value.number_integer = -static_cast<number_integer_t>(value);
    8418  }
    8419  else
    8420  {
    8421  // parse with strtod
    8422  result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL);
    8423  }
    8424 
    8425  // save the type
    8426  result.m_type = type;
    8427  }
    8428 
    8429  private:
    8431  std::istream* m_stream = nullptr;
    8433  string_t m_buffer;
    8435  const lexer_char_t* m_content = nullptr;
    8437  const lexer_char_t* m_start = nullptr;
    8439  const lexer_char_t* m_marker = nullptr;
    8441  const lexer_char_t* m_cursor = nullptr;
    8443  const lexer_char_t* m_limit = nullptr;
    8444  };
    8445 
    8451  class parser
    8452  {
    8453  public:
    8455  parser(const string_t& s, parser_callback_t cb = nullptr) noexcept
    8456  : callback(cb), m_lexer(s)
    8457  {
    8458  // read first token
    8459  get_token();
    8460  }
    8461 
    8463  parser(std::istream& _is, parser_callback_t cb = nullptr) noexcept
    8464  : callback(cb), m_lexer(&_is)
    8465  {
    8466  // read first token
    8467  get_token();
    8468  }
    8469 
    8471  basic_json parse()
    8472  {
    8473  basic_json result = parse_internal(true);
    8474 
    8475  expect(lexer::token_type::end_of_input);
    8476 
    8477  // return parser result and replace it with null in case the
    8478  // top-level value was discarded by the callback function
    8479  return result.is_discarded() ? basic_json() : result;
    8480  }
    8481 
    8482  private:
    8484  basic_json parse_internal(bool keep)
    8485  {
    8486  auto result = basic_json(value_t::discarded);
    8487 
    8488  switch (last_token)
    8489  {
    8490  case lexer::token_type::begin_object:
    8491  {
    8492  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    8493  {
    8494  // explicitly set result to object to cope with {}
    8495  result.m_type = value_t::object;
    8496  result.m_value = json_value(value_t::object);
    8497  }
    8498 
    8499  // read next token
    8500  get_token();
    8501 
    8502  // closing } -> we are done
    8503  if (last_token == lexer::token_type::end_object)
    8504  {
    8505  get_token();
    8506  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8507  {
    8508  result = basic_json(value_t::discarded);
    8509  }
    8510  return result;
    8511  }
    8512 
    8513  // no comma is expected here
    8514  unexpect(lexer::token_type::value_separator);
    8515 
    8516  // otherwise: parse key-value pairs
    8517  do
    8518  {
    8519  // ugly, but could be fixed with loop reorganization
    8520  if (last_token == lexer::token_type::value_separator)
    8521  {
    8522  get_token();
    8523  }
    8524 
    8525  // store key
    8526  expect(lexer::token_type::value_string);
    8527  const auto key = m_lexer.get_string();
    8528 
    8529  bool keep_tag = false;
    8530  if (keep)
    8531  {
    8532  if (callback)
    8533  {
    8534  basic_json k(key);
    8535  keep_tag = callback(depth, parse_event_t::key, k);
    8536  }
    8537  else
    8538  {
    8539  keep_tag = true;
    8540  }
    8541  }
    8542 
    8543  // parse separator (:)
    8544  get_token();
    8545  expect(lexer::token_type::name_separator);
    8546 
    8547  // parse and add value
    8548  get_token();
    8549  auto value = parse_internal(keep);
    8550  if (keep and keep_tag and not value.is_discarded())
    8551  {
    8552  result[key] = std::move(value);
    8553  }
    8554  }
    8555  while (last_token == lexer::token_type::value_separator);
    8556 
    8557  // closing }
    8558  expect(lexer::token_type::end_object);
    8559  get_token();
    8560  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8561  {
    8562  result = basic_json(value_t::discarded);
    8563  }
    8564 
    8565  return result;
    8566  }
    8567 
    8568  case lexer::token_type::begin_array:
    8569  {
    8570  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    8571  {
    8572  // explicitly set result to object to cope with []
    8573  result.m_type = value_t::array;
    8574  result.m_value = json_value(value_t::array);
    8575  }
    8576 
    8577  // read next token
    8578  get_token();
    8579 
    8580  // closing ] -> we are done
    8581  if (last_token == lexer::token_type::end_array)
    8582  {
    8583  get_token();
    8584  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8585  {
    8586  result = basic_json(value_t::discarded);
    8587  }
    8588  return result;
    8589  }
    8590 
    8591  // no comma is expected here
    8592  unexpect(lexer::token_type::value_separator);
    8593 
    8594  // otherwise: parse values
    8595  do
    8596  {
    8597  // ugly, but could be fixed with loop reorganization
    8598  if (last_token == lexer::token_type::value_separator)
    8599  {
    8600  get_token();
    8601  }
    8602 
    8603  // parse value
    8604  auto value = parse_internal(keep);
    8605  if (keep and not value.is_discarded())
    8606  {
    8607  result.push_back(std::move(value));
    8608  }
    8609  }
    8610  while (last_token == lexer::token_type::value_separator);
    8611 
    8612  // closing ]
    8613  expect(lexer::token_type::end_array);
    8614  get_token();
    8615  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8616  {
    8617  result = basic_json(value_t::discarded);
    8618  }
    8619 
    8620  return result;
    8621  }
    8622 
    8623  case lexer::token_type::literal_null:
    8624  {
    8625  get_token();
    8626  result.m_type = value_t::null;
    8627  break;
    8628  }
    8629 
    8630  case lexer::token_type::value_string:
    8631  {
    8632  const auto s = m_lexer.get_string();
    8633  get_token();
    8634  result = basic_json(s);
    8635  break;
    8636  }
    8637 
    8638  case lexer::token_type::literal_true:
    8639  {
    8640  get_token();
    8641  result.m_type = value_t::boolean;
    8642  result.m_value = true;
    8643  break;
    8644  }
    8645 
    8646  case lexer::token_type::literal_false:
    8647  {
    8648  get_token();
    8649  result.m_type = value_t::boolean;
    8650  result.m_value = false;
    8651  break;
    8652  }
    8653 
    8654  case lexer::token_type::value_number:
    8655  {
    8656  m_lexer.get_number(result);
    8657  get_token();
    8658  break;
    8659  }
    8660 
    8661  default:
    8662  {
    8663  // the last token was unexpected
    8664  unexpect(last_token);
    8665  }
    8666  }
    8667 
    8668  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8669  {
    8670  result = basic_json(value_t::discarded);
    8671  }
    8672  return result;
    8673  }
    8674 
    8676  typename lexer::token_type get_token() noexcept
    8677  {
    8678  last_token = m_lexer.scan();
    8679  return last_token;
    8680  }
    8681 
    8682  void expect(typename lexer::token_type t) const
    8683  {
    8684  if (t != last_token)
    8685  {
    8686  std::string error_msg = "parse error - unexpected ";
    8687  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8688  lexer::token_type_name(last_token));
    8689  error_msg += "; expected " + lexer::token_type_name(t);
    8690  throw std::invalid_argument(error_msg);
    8691  }
    8692  }
    8693 
    8694  void unexpect(typename lexer::token_type t) const
    8695  {
    8696  if (t == last_token)
    8697  {
    8698  std::string error_msg = "parse error - unexpected ";
    8699  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8700  lexer::token_type_name(last_token));
    8701  throw std::invalid_argument(error_msg);
    8702  }
    8703  }
    8704 
    8705  private:
    8707  int depth = 0;
    8709  parser_callback_t callback;
    8711  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8713  lexer m_lexer;
    8714  };
    8715 
    8716  public:
    8729  {
    8731  friend class basic_json;
    8732 
    8733  public:
    8756  explicit json_pointer(const std::string& s = "")
    8757  : reference_tokens(split(s))
    8758  {}
    8759 
    8775  std::string to_string() const noexcept
    8776  {
    8777  std::string result;
    8778 
    8779  for (const auto& reference_token : reference_tokens)
    8780  {
    8781  result += "/" + escape(reference_token);
    8782  }
    8783 
    8784  return result;
    8785  }
    8786 
    8788  operator std::string() const
    8789  {
    8790  return to_string();
    8791  }
    8793  private:
    8795  std::string pop_back()
    8796  {
    8797  if (is_root())
    8798  {
    8799  throw std::domain_error("JSON pointer has no parent");
    8800  }
    8801 
    8802  auto last = reference_tokens.back();
    8803  reference_tokens.pop_back();
    8804  return last;
    8805  }
    8806 
    8808  bool is_root() const
    8809  {
    8810  return reference_tokens.empty();
    8811  }
    8812 
    8813  json_pointer top() const
    8814  {
    8815  if (is_root())
    8816  {
    8817  throw std::domain_error("JSON pointer has no parent");
    8818  }
    8819 
    8820  json_pointer result = *this;
    8821  result.reference_tokens = {reference_tokens[0]};
    8822  return result;
    8823  }
    8824 
    8828  reference get_and_create(reference j) const
    8829  {
    8830  pointer result = &j;
    8831 
    8832  // in case no reference tokens exist, return a reference to the
    8833  // JSON value j which will be overwritten by a primitive value
    8834  for (const auto& reference_token : reference_tokens)
    8835  {
    8836  switch (result->m_type)
    8837  {
    8838  case value_t::null:
    8839  {
    8840  if (reference_token == "0")
    8841  {
    8842  // start a new array if reference token is 0
    8843  result = &result->operator[](0);
    8844  }
    8845  else
    8846  {
    8847  // start a new object otherwise
    8848  result = &result->operator[](reference_token);
    8849  }
    8850  break;
    8851  }
    8852 
    8853  case value_t::object:
    8854  {
    8855  // create an entry in the object
    8856  result = &result->operator[](reference_token);
    8857  break;
    8858  }
    8859 
    8860  case value_t::array:
    8861  {
    8862  // create an entry in the array
    8863  result = &result->operator[](static_cast<size_type>(std::stoi(reference_token)));
    8864  break;
    8865  }
    8866 
    8867  /*
    8868  The following code is only reached if there exists a
    8869  reference token _and_ the current value is primitive. In
    8870  this case, we have an error situation, because primitive
    8871  values may only occur as single value; that is, with an
    8872  empty list of reference tokens.
    8873  */
    8874  default:
    8875  {
    8876  throw std::domain_error("invalid value to unflatten");
    8877  }
    8878  }
    8879  }
    8880 
    8881  return *result;
    8882  }
    8883 
    8897  reference get_unchecked(pointer ptr) const
    8898  {
    8899  for (const auto& reference_token : reference_tokens)
    8900  {
    8901  switch (ptr->m_type)
    8902  {
    8903  case value_t::object:
    8904  {
    8905  // use unchecked object access
    8906  ptr = &ptr->operator[](reference_token);
    8907  break;
    8908  }
    8909 
    8910  case value_t::array:
    8911  {
    8912  // error condition (cf. RFC 6901, Sect. 4)
    8913  if (reference_token.size() > 1 and reference_token[0] == '0')
    8914  {
    8915  throw std::domain_error("array index must not begin with '0'");
    8916  }
    8917 
    8918  if (reference_token == "-")
    8919  {
    8920  // explicityly treat "-" as index beyond the end
    8921  ptr = &ptr->operator[](ptr->m_value.array->size());
    8922  }
    8923  else
    8924  {
    8925  // convert array index to number; unchecked access
    8926  ptr = &ptr->operator[](static_cast<size_type>(std::stoi(reference_token)));
    8927  }
    8928  break;
    8929  }
    8930 
    8931  default:
    8932  {
    8933  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    8934  }
    8935  }
    8936  }
    8937 
    8938  return *ptr;
    8939  }
    8940 
    8941  reference get_checked(pointer ptr) const
    8942  {
    8943  for (const auto& reference_token : reference_tokens)
    8944  {
    8945  switch (ptr->m_type)
    8946  {
    8947  case value_t::object:
    8948  {
    8949  // note: at performs range check
    8950  ptr = &ptr->at(reference_token);
    8951  break;
    8952  }
    8953 
    8954  case value_t::array:
    8955  {
    8956  if (reference_token == "-")
    8957  {
    8958  // "-" always fails the range check
    8959  throw std::out_of_range("array index '-' (" +
    8960  std::to_string(ptr->m_value.array->size()) +
    8961  ") is out of range");
    8962  }
    8963 
    8964  // error condition (cf. RFC 6901, Sect. 4)
    8965  if (reference_token.size() > 1 and reference_token[0] == '0')
    8966  {
    8967  throw std::domain_error("array index must not begin with '0'");
    8968  }
    8969 
    8970  // note: at performs range check
    8971  ptr = &ptr->at(static_cast<size_type>(std::stoi(reference_token)));
    8972  break;
    8973  }
    8974 
    8975  default:
    8976  {
    8977  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    8978  }
    8979  }
    8980  }
    8981 
    8982  return *ptr;
    8983  }
    8984 
    8993  const_reference get_unchecked(const_pointer ptr) const
    8994  {
    8995  for (const auto& reference_token : reference_tokens)
    8996  {
    8997  switch (ptr->m_type)
    8998  {
    8999  case value_t::object:
    9000  {
    9001  // use unchecked object access
    9002  ptr = &ptr->operator[](reference_token);
    9003  break;
    9004  }
    9005 
    9006  case value_t::array:
    9007  {
    9008  if (reference_token == "-")
    9009  {
    9010  // "-" cannot be used for const access
    9011  throw std::out_of_range("array index '-' (" +
    9012  std::to_string(ptr->m_value.array->size()) +
    9013  ") is out of range");
    9014  }
    9015 
    9016  // error condition (cf. RFC 6901, Sect. 4)
    9017  if (reference_token.size() > 1 and reference_token[0] == '0')
    9018  {
    9019  throw std::domain_error("array index must not begin with '0'");
    9020  }
    9021 
    9022  // use unchecked array access
    9023  ptr = &ptr->operator[](static_cast<size_type>(std::stoi(reference_token)));
    9024  break;
    9025  }
    9026 
    9027  default:
    9028  {
    9029  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    9030  }
    9031  }
    9032  }
    9033 
    9034  return *ptr;
    9035  }
    9036 
    9037  const_reference get_checked(const_pointer ptr) const
    9038  {
    9039  for (const auto& reference_token : reference_tokens)
    9040  {
    9041  switch (ptr->m_type)
    9042  {
    9043  case value_t::object:
    9044  {
    9045  // note: at performs range check
    9046  ptr = &ptr->at(reference_token);
    9047  break;
    9048  }
    9049 
    9050  case value_t::array:
    9051  {
    9052  if (reference_token == "-")
    9053  {
    9054  // "-" always fails the range check
    9055  throw std::out_of_range("array index '-' (" +
    9056  std::to_string(ptr->m_value.array->size()) +
    9057  ") is out of range");
    9058  }
    9059 
    9060  // error condition (cf. RFC 6901, Sect. 4)
    9061  if (reference_token.size() > 1 and reference_token[0] == '0')
    9062  {
    9063  throw std::domain_error("array index must not begin with '0'");
    9064  }
    9065 
    9066  // note: at performs range check
    9067  ptr = &ptr->at(static_cast<size_type>(std::stoi(reference_token)));
    9068  break;
    9069  }
    9070 
    9071  default:
    9072  {
    9073  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    9074  }
    9075  }
    9076  }
    9077 
    9078  return *ptr;
    9079  }
    9080 
    9082  static std::vector<std::string> split(std::string reference_string)
    9083  {
    9084  std::vector<std::string> result;
    9085 
    9086  // special case: empty reference string -> no reference tokens
    9087  if (reference_string.empty())
    9088  {
    9089  return result;
    9090  }
    9091 
    9092  // check if nonempty reference string begins with slash
    9093  if (reference_string[0] != '/')
    9094  {
    9095  throw std::domain_error("JSON pointer must be empty or begin with '/'");
    9096  }
    9097 
    9098  // extract the reference tokens:
    9099  // - slash: position of the last read slash (or end of string)
    9100  // - start: position after the previous slash
    9101  for (
    9102  // search for the first slash after the first character
    9103  size_t slash = reference_string.find_first_of("/", 1),
    9104  // set the beginning of the first reference token
    9105  start = 1;
    9106  // we can stop if start == string::npos+1 = 0
    9107  start != 0;
    9108  // set the beginning of the next reference token
    9109  // (will eventually be 0 if slash == std::string::npos)
    9110  start = slash + 1,
    9111  // find next slash
    9112  slash = reference_string.find_first_of("/", start))
    9113  {
    9114  // use the text between the beginning of the reference token
    9115  // (start) and the last slash (slash).
    9116  auto reference_token = reference_string.substr(start, slash - start);
    9117 
    9118  // check reference tokens are properly escaped
    9119  for (size_t pos = reference_token.find_first_of("~");
    9120  pos != std::string::npos;
    9121  pos = reference_token.find_first_of("~", pos + 1))
    9122  {
    9123  assert(reference_token[pos] == '~');
    9124 
    9125  // ~ must be followed by 0 or 1
    9126  if (pos == reference_token.size() - 1 or
    9127  (reference_token[pos + 1] != '0' and
    9128  reference_token[pos + 1] != '1'))
    9129  {
    9130  throw std::domain_error("escape error: '~' must be followed with '0' or '1'");
    9131  }
    9132  }
    9133 
    9134  // finally, store the reference token
    9135  unescape(reference_token);
    9136  result.push_back(reference_token);
    9137  }
    9138 
    9139  return result;
    9140  }
    9141 
    9142  private:
    9157  static void replace_substring(std::string& s,
    9158  const std::string& f,
    9159  const std::string& t)
    9160  {
    9161  assert(not f.empty());
    9162 
    9163  for (
    9164  size_t pos = s.find(f); // find first occurrence of f
    9165  pos != std::string::npos; // make sure f was found
    9166  s.replace(pos, f.size(), t), // replace with t
    9167  pos = s.find(f, pos + t.size()) // find next occurrence of f
    9168  );
    9169  }
    9170 
    9172  static std::string escape(std::string s)
    9173  {
    9174  // escape "~"" to "~0" and "/" to "~1"
    9175  replace_substring(s, "~", "~0");
    9176  replace_substring(s, "/", "~1");
    9177  return s;
    9178  }
    9179 
    9181  static void unescape(std::string& s)
    9182  {
    9183  // first transform any occurrence of the sequence '~1' to '/'
    9184  replace_substring(s, "~1", "/");
    9185  // then transform any occurrence of the sequence '~0' to '~'
    9186  replace_substring(s, "~0", "~");
    9187  }
    9188 
    9196  static void flatten(const std::string& reference_string,
    9197  const basic_json& value,
    9198  basic_json& result)
    9199  {
    9200  switch (value.m_type)
    9201  {
    9202  case value_t::array:
    9203  {
    9204  if (value.m_value.array->empty())
    9205  {
    9206  // flatten empty array as null
    9207  result[reference_string] = nullptr;
    9208  }
    9209  else
    9210  {
    9211  // iterate array and use index as reference string
    9212  for (size_t i = 0; i < value.m_value.array->size(); ++i)
    9213  {
    9214  flatten(reference_string + "/" + std::to_string(i),
    9215  value.m_value.array->operator[](i), result);
    9216  }
    9217  }
    9218  break;
    9219  }
    9220 
    9221  case value_t::object:
    9222  {
    9223  if (value.m_value.object->empty())
    9224  {
    9225  // flatten empty object as null
    9226  result[reference_string] = nullptr;
    9227  }
    9228  else
    9229  {
    9230  // iterate object and use keys as reference string
    9231  for (const auto& element : *value.m_value.object)
    9232  {
    9233  flatten(reference_string + "/" + escape(element.first),
    9234  element.second, result);
    9235  }
    9236  }
    9237  break;
    9238  }
    9239 
    9240  default:
    9241  {
    9242  // add primitive value with its reference string
    9243  result[reference_string] = value;
    9244  break;
    9245  }
    9246  }
    9247  }
    9248 
    9254  static basic_json unflatten(const basic_json& value)
    9255  {
    9256  if (not value.is_object())
    9257  {
    9258  throw std::domain_error("only objects can be unflattened");
    9259  }
    9260 
    9261  basic_json result;
    9262 
    9263  // iterate the JSON object values
    9264  for (const auto& element : *value.m_value.object)
    9265  {
    9266  if (not element.second.is_primitive())
    9267  {
    9268  throw std::domain_error("values in object must be primitive");
    9269  }
    9270 
    9271  // assign value to reference pointed to by JSON pointer; Note
    9272  // that if the JSON pointer is "" (i.e., points to the whole
    9273  // value), function get_and_create returns a reference to
    9274  // result itself. An assignment will then create a primitive
    9275  // value.
    9276  json_pointer(element.first).get_and_create(result) = element.second;
    9277  }
    9278 
    9279  return result;
    9280  }
    9281 
    9282  private:
    9284  std::vector<std::string> reference_tokens {};
    9285  };
    9286 
    9288  // JSON Pointer support //
    9290 
    9293 
    9327  reference operator[](const json_pointer& ptr)
    9328  {
    9329  return ptr.get_unchecked(this);
    9330  }
    9354  const_reference operator[](const json_pointer& ptr) const
    9355  {
    9356  return ptr.get_unchecked(this);
    9357  }
    9379  reference at(const json_pointer& ptr)
    9380  {
    9381  return ptr.get_checked(this);
    9382  }
    9404  const_reference at(const json_pointer& ptr) const
    9405  {
    9406  return ptr.get_checked(this);
    9407  }
    9431  basic_json flatten() const
    9432  {
    9433  basic_json result(value_t::object);
    9434  json_pointer::flatten("", *this, result);
    9435  return result;
    9436  }
    9437 
    9465  basic_json unflatten() const
    9466  {
    9467  return json_pointer::unflatten(*this);
    9468  }
    9471 
    9473  // JSON Patch functions //
    9475 
    9478 
    9515  basic_json patch(const basic_json& json_patch) const
    9516  {
    9517  // make a working copy to apply the patch to
    9518  basic_json result = *this;
    9520  // the valid JSON Patch operations
    9521  enum class patch_operations {add, remove, replace, move, copy, test, invalid};
    9522 
    9523  const auto get_op = [](const std::string op)
    9524  {
    9525  if (op == "add")
    9526  {
    9527  return patch_operations::add;
    9528  }
    9529  if (op == "remove")
    9530  {
    9531  return patch_operations::remove;
    9532  }
    9533  if (op == "replace")
    9534  {
    9535  return patch_operations::replace;
    9536  }
    9537  if (op == "move")
    9538  {
    9539  return patch_operations::move;
    9540  }
    9541  if (op == "copy")
    9542  {
    9543  return patch_operations::copy;
    9544  }
    9545  if (op == "test")
    9546  {
    9547  return patch_operations::test;
    9548  }
    9549 
    9550  return patch_operations::invalid;
    9551  };
    9552 
    9553  // wrapper for "add" operation; add value at ptr
    9554  const auto operation_add = [&result](json_pointer & ptr, basic_json val)
    9555  {
    9556  // adding to the root of the target document means replacing it
    9557  if (ptr.is_root())
    9558  {
    9559  result = val;
    9560  }
    9561  else
    9562  {
    9563  // make sure the top element of the pointer exists
    9564  json_pointer top_pointer = ptr.top();
    9565  if (top_pointer != ptr)
    9566  {
    9567  basic_json& x = result.at(top_pointer);
    9568  }
    9569 
    9570  // get reference to parent of JSON pointer ptr
    9571  const auto last_path = ptr.pop_back();
    9572  basic_json& parent = result[ptr];
    9573 
    9574  switch (parent.m_type)
    9575  {
    9576  case value_t::null:
    9577  case value_t::object:
    9578  {
    9579  // use operator[] to add value
    9580  parent[last_path] = val;
    9581  break;
    9582  }
    9583 
    9584  case value_t::array:
    9585  {
    9586  if (last_path == "-")
    9587  {
    9588  // special case: append to back
    9589  parent.push_back(val);
    9590  }
    9591  else
    9592  {
    9593  const auto idx = std::stoi(last_path);
    9594  if (static_cast<size_type>(idx) > parent.size())
    9595  {
    9596  // avoid undefined behavior
    9597  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    9598  }
    9599  else
    9600  {
    9601  // default case: insert add offset
    9602  parent.insert(parent.begin() + static_cast<difference_type>(idx), val);
    9603  }
    9604  }
    9605  break;
    9606  }
    9607 
    9608  default:
    9609  {
    9610  // if there exists a parent it cannot be primitive
    9611  assert(false); // LCOV_EXCL_LINE
    9612  }
    9613  }
    9614  }
    9615  };
    9616 
    9617  // wrapper for "remove" operation; remove value at ptr
    9618  const auto operation_remove = [&result](json_pointer & ptr)
    9619  {
    9620  // get reference to parent of JSON pointer ptr
    9621  const auto last_path = ptr.pop_back();
    9622  basic_json& parent = result.at(ptr);
    9623 
    9624  // remove child
    9625  if (parent.is_object())
    9626  {
    9627  // perform range check
    9628  auto it = parent.find(last_path);
    9629  if (it != parent.end())
    9630  {
    9631  parent.erase(it);
    9632  }
    9633  else
    9634  {
    9635  throw std::out_of_range("key '" + last_path + "' not found");
    9636  }
    9637  }
    9638  else if (parent.is_array())
    9639  {
    9640  // note erase performs range check
    9641  parent.erase(static_cast<size_type>(std::stoi(last_path)));
    9642  }
    9643  };
    9644 
    9645  // type check
    9646  if (not json_patch.is_array())
    9647  {
    9648  // a JSON patch must be an array of objects
    9649  throw std::invalid_argument("JSON patch must be an array of objects");
    9650  }
    9651 
    9652  // iterate and apply th eoperations
    9653  for (const auto& val : json_patch)
    9654  {
    9655  // wrapper to get a value for an operation
    9656  const auto get_value = [&val](const std::string & op,
    9657  const std::string & member,
    9658  bool string_type) -> basic_json&
    9659  {
    9660  // find value
    9661  auto it = val.m_value.object->find(member);
    9662 
    9663  // context-sensitive error message
    9664  const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
    9665 
    9666  // check if desired value is present
    9667  if (it == val.m_value.object->end())
    9668  {
    9669  throw std::invalid_argument(error_msg + " must have member '" + member + "'");
    9670  }
    9671 
    9672  // check if result is of type string
    9673  if (string_type and not it->second.is_string())
    9674  {
    9675  throw std::invalid_argument(error_msg + " must have string member '" + member + "'");
    9676  }
    9677 
    9678  // no error: return value
    9679  return it->second;
    9680  };
    9681 
    9682  // type check
    9683  if (not val.is_object())
    9684  {
    9685  throw std::invalid_argument("JSON patch must be an array of objects");
    9686  }
    9687 
    9688  // collect mandatory members
    9689  const std::string op = get_value("op", "op", true);
    9690  const std::string path = get_value(op, "path", true);
    9691  json_pointer ptr(path);
    9692 
    9693  switch (get_op(op))
    9694  {
    9695  case patch_operations::add:
    9696  {
    9697  operation_add(ptr, get_value("add", "value", false));
    9698  break;
    9699  }
    9700 
    9701  case patch_operations::remove:
    9702  {
    9703  operation_remove(ptr);
    9704  break;
    9705  }
    9706 
    9707  case patch_operations::replace:
    9708  {
    9709  // the "path" location must exist - use at()
    9710  result.at(ptr) = get_value("replace", "value", false);
    9711  break;
    9712  }
    9713 
    9714  case patch_operations::move:
    9715  {
    9716  const std::string from_path = get_value("move", "from", true);
    9717  json_pointer from_ptr(from_path);
    9718 
    9719  // the "from" location must exist - use at()
    9720  basic_json v = result.at(from_ptr);
    9721 
    9722  // The move operation is functionally identical to a
    9723  // "remove" operation on the "from" location, followed
    9724  // immediately by an "add" operation at the target
    9725  // location with the value that was just removed.
    9726  operation_remove(from_ptr);
    9727  operation_add(ptr, v);
    9728  break;
    9729  }
    9730 
    9731  case patch_operations::copy:
    9732  {
    9733  const std::string from_path = get_value("copy", "from", true);;
    9734  const json_pointer from_ptr(from_path);
    9735 
    9736  // the "from" location must exist - use at()
    9737  result[ptr] = result.at(from_ptr);
    9738  break;
    9739  }
    9740 
    9741  case patch_operations::test:
    9742  {
    9743  bool success = false;
    9744  try
    9745  {
    9746  // check if "value" matches the one at "path"
    9747  // the "path" location must exist - use at()
    9748  success = (result.at(ptr) == get_value("test", "value", false));
    9749  }
    9750  catch (std::out_of_range&)
    9751  {
    9752  // ignore out of range errors: success remains false
    9753  }
    9754 
    9755  // throw an exception if test fails
    9756  if (not success)
    9757  {
    9758  throw std::domain_error("unsuccessful: " + val.dump());
    9759  }
    9760 
    9761  break;
    9762  }
    9763 
    9764  case patch_operations::invalid:
    9765  {
    9766  // op must be "add", "remove", "replace", "move", "copy", or
    9767  // "test"
    9768  throw std::invalid_argument("operation value '" + op + "' is invalid");
    9769  }
    9770  }
    9771  }
    9772 
    9773  return result;
    9774  }
    9775 
    9808  static basic_json diff(const basic_json& source,
    9809  const basic_json& target,
    9810  std::string path = "")
    9811  {
    9812  // the patch
    9813  basic_json result(value_t::array);
    9814 
    9815  // if the values are the same, return empty patch
    9816  if (source == target)
    9817  {
    9818  return result;
    9819  }
    9820 
    9821  if (source.type() != target.type())
    9822  {
    9823  // different types: replace value
    9824  result.push_back(
    9825  {
    9826  {"op", "replace"},
    9827  {"path", path},
    9828  {"value", target}
    9829  });
    9830  }
    9831  else
    9832  {
    9833  switch (source.type())
    9834  {
    9835  case value_t::array:
    9836  {
    9837  // first pass: traverse common elements
    9838  size_t i = 0;
    9839  while (i < source.size() and i < target.size())
    9840  {
    9841  // recursive call to compare array values at index i
    9842  auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
    9843  result.insert(result.end(), temp_diff.begin(), temp_diff.end());
    9844  ++i;
    9845  }
    9846 
    9847  // i now reached the end of at least one array
    9848  // in a second pass, traverse the remaining elements
    9849 
    9850  // remove my remaining elements
    9851  const auto end_index = static_cast<difference_type>(result.size());
    9852  while (i < source.size())
    9853  {
    9854  // add operations in reverse order to avoid invalid
    9855  // indices
    9856  result.insert(result.begin() + end_index, object(
    9857  {
    9858  {"op", "remove"},
    9859  {"path", path + "/" + std::to_string(i)}
    9860  }));
    9861  ++i;
    9862  }
    9863 
    9864  // add other remaining elements
    9865  while (i < target.size())
    9866  {
    9867  result.push_back(
    9868  {
    9869  {"op", "add"},
    9870  {"path", path + "/" + std::to_string(i)},
    9871  {"value", target[i]}
    9872  });
    9873  ++i;
    9874  }
    9875 
    9876  break;
    9877  }
    9878 
    9879  case value_t::object:
    9880  {
    9881  // first pass: traverse this object's elements
    9882  for (auto it = source.begin(); it != source.end(); ++it)
    9883  {
    9884  // escape the key name to be used in a JSON patch
    9885  const auto key = json_pointer::escape(it.key());
    9886 
    9887  if (target.find(it.key()) != target.end())
    9888  {
    9889  // recursive call to compare object values at key it
    9890  auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key);
    9891  result.insert(result.end(), temp_diff.begin(), temp_diff.end());
    9892  }
    9893  else
    9894  {
    9895  // found a key that is not in o -> remove it
    9896  result.push_back(object(
    9897  {
    9898  {"op", "remove"},
    9899  {"path", path + "/" + key}
    9900  }));
    9901  }
    9902  }
    9903 
    9904  // second pass: traverse other object's elements
    9905  for (auto it = target.begin(); it != target.end(); ++it)
    9906  {
    9907  if (source.find(it.key()) == source.end())
    9908  {
    9909  // found a key that is not in this -> add it
    9910  const auto key = json_pointer::escape(it.key());
    9911  result.push_back(
    9912  {
    9913  {"op", "add"},
    9914  {"path", path + "/" + key},
    9915  {"value", it.value()}
    9916  });
    9917  }
    9918  }
    9919 
    9920  break;
    9921  }
    9922 
    9923  default:
    9924  {
    9925  // both primitive type: replace value
    9926  result.push_back(
    9927  {
    9928  {"op", "replace"},
    9929  {"path", path},
    9930  {"value", target}
    9931  });
    9932  break;
    9933  }
    9934  }
    9935  }
    9936 
    9937  return result;
    9938  }
    9939 
    9941 };
    9942 
    9943 
    9945 // presets //
    9947 
    9956 using json = basic_json<>;
    9957 }
    9958 
    9959 
    9961 // nonmember support //
    9963 
    9964 // specialization of std::swap, and std::hash
    9965 namespace std
    9966 {
    9972 template <>
    9973 inline void swap(nlohmann::json& j1,
    9974  nlohmann::json& j2) noexcept(
    9975  is_nothrow_move_constructible<nlohmann::json>::value and
    9976  is_nothrow_move_assignable<nlohmann::json>::value
    9977  )
    9978 {
    9979  j1.swap(j2);
    9980 }
    9981 
    9983 template <>
    9984 struct hash<nlohmann::json>
    9985 {
    9991  std::size_t operator()(const nlohmann::json& j) const
    9992  {
    9993  // a naive hashing via the string representation
    9994  const auto& h = hash<nlohmann::json::string_t>();
    9995  return h(j.dump());
    9996  }
    9997 };
    9998 }
    9999 
    10012 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    10013 {
    10014  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    10015 }
    10016 
    10022 inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t)
    10023 {
    10024  return nlohmann::json::json_pointer(s);
    10025 }
    10026 
    10027 // restore GCC/clang diagnostic settings
    10028 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    10029  #pragma GCC diagnostic pop
    10030 #endif
    10031 
    10032 #endif
    const_iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6380
    -
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5569
    +
    1 /*
    2  __ _____ _____ _____
    3  __| | __| | | | JSON for Modern C++
    4 | | |__ | | | | | | version 2.0.1
    5 |_____|_____|_____|_|___| https://github.com/nlohmann/json
    6 
    7 Licensed under the MIT License <http://opensource.org/licenses/MIT>.
    8 Copyright (c) 2013-2016 Niels Lohmann <http://nlohmann.me>.
    9 
    10 Permission is hereby granted, free of charge, to any person obtaining a copy
    11 of this software and associated documentation files (the "Software"), to deal
    12 in the Software without restriction, including without limitation the rights
    13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    14 copies of the Software, and to permit persons to whom the Software is
    15 furnished to do so, subject to the following conditions:
    16 
    17 The above copyright notice and this permission notice shall be included in all
    18 copies or substantial portions of the Software.
    19 
    20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    26 SOFTWARE.
    27 */
    28 
    29 #ifndef NLOHMANN_JSON_HPP
    30 #define NLOHMANN_JSON_HPP
    31 
    32 #include <algorithm>
    33 #include <array>
    34 #include <cassert>
    35 #include <cerrno>
    36 #include <ciso646>
    37 #include <cmath>
    38 #include <cstddef>
    39 #include <cstdio>
    40 #include <cstdlib>
    41 #include <functional>
    42 #include <initializer_list>
    43 #include <iomanip>
    44 #include <iostream>
    45 #include <iterator>
    46 #include <limits>
    47 #include <map>
    48 #include <memory>
    49 #include <sstream>
    50 #include <stdexcept>
    51 #include <string>
    52 #include <type_traits>
    53 #include <utility>
    54 #include <vector>
    55 
    56 // disable float-equal warnings on GCC/clang
    57 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    58  #pragma GCC diagnostic push
    59  #pragma GCC diagnostic ignored "-Wfloat-equal"
    60 #endif
    61 
    67 namespace nlohmann
    68 {
    69 
    70 
    75 namespace
    76 {
    81 template<typename T>
    82 struct has_mapped_type
    83 {
    84  private:
    85  template<typename C> static char test(typename C::mapped_type*);
    86  template<typename C> static char (&test(...))[2];
    87  public:
    88  static constexpr bool value = sizeof(test<T>(0)) == 1;
    89 };
    90 
    95 class DecimalSeparator : public std::numpunct<char>
    96 {
    97  protected:
    98  char do_decimal_point() const
    99  {
    100  return '.';
    101  }
    102 };
    103 
    104 }
    105 
    177 template <
    178  template<typename U, typename V, typename... Args> class ObjectType = std::map,
    179  template<typename U, typename... Args> class ArrayType = std::vector,
    180  class StringType = std::string,
    181  class BooleanType = bool,
    182  class NumberIntegerType = std::int64_t,
    183  class NumberUnsignedType = std::uint64_t,
    184  class NumberFloatType = double,
    185  template<typename U> class AllocatorType = std::allocator
    186  >
    188 {
    189  private:
    191  using basic_json_t = basic_json<ObjectType,
    192  ArrayType,
    193  StringType,
    194  BooleanType,
    195  NumberIntegerType,
    196  NumberUnsignedType,
    197  NumberFloatType,
    198  AllocatorType>;
    199 
    200  public:
    201  // forward declarations
    202  template<typename Base> class json_reverse_iterator;
    203  class json_pointer;
    204 
    206  // container types //
    208 
    211 
    214 
    218  using const_reference = const value_type&;
    219 
    221  using difference_type = std::ptrdiff_t;
    223  using size_type = std::size_t;
    224 
    226  using allocator_type = AllocatorType<basic_json>;
    227 
    229  using pointer = typename std::allocator_traits<allocator_type>::pointer;
    231  using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
    232 
    234  class iterator;
    236  class const_iterator;
    241 
    243 
    244 
    249  {
    250  return allocator_type();
    251  }
    252 
    253 
    255  // JSON value data types //
    257 
    260 
    344  using object_t = ObjectType<StringType,
    345  basic_json,
    346  std::less<StringType>,
    347  AllocatorType<std::pair<const StringType,
    348  basic_json>>>;
    349 
    394  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
    395 
    441  using string_t = StringType;
    442 
    467  using boolean_t = BooleanType;
    468 
    539  using number_integer_t = NumberIntegerType;
    540 
    611  using number_unsigned_t = NumberUnsignedType;
    612 
    679  using number_float_t = NumberFloatType;
    680 
    682 
    683 
    685  // JSON type enumeration //
    687 
    698  enum class value_t : uint8_t
    699  {
    700  null,
    701  object,
    702  array,
    703  string,
    704  boolean,
    705  number_integer,
    706  number_unsigned,
    707  number_float,
    708  discarded
    709  };
    710 
    711 
    712  private:
    713 
    715  template<typename T, typename... Args>
    716  static T* create(Args&& ... args)
    717  {
    718  AllocatorType<T> alloc;
    719  auto deleter = [&](T * object)
    720  {
    721  alloc.deallocate(object, 1);
    722  };
    723  std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
    724  alloc.construct(object.get(), std::forward<Args>(args)...);
    725  return object.release();
    726  }
    727 
    729  // JSON value storage //
    731 
    739  union json_value
    740  {
    742  object_t* object;
    744  array_t* array;
    746  string_t* string;
    748  boolean_t boolean;
    750  number_integer_t number_integer;
    752  number_unsigned_t number_unsigned;
    754  number_float_t number_float;
    755 
    757  json_value() = default;
    759  json_value(boolean_t v) noexcept : boolean(v) {}
    761  json_value(number_integer_t v) noexcept : number_integer(v) {}
    763  json_value(number_unsigned_t v) noexcept : number_unsigned(v) {}
    765  json_value(number_float_t v) noexcept : number_float(v) {}
    767  json_value(value_t t)
    768  {
    769  switch (t)
    770  {
    771  case value_t::object:
    772  {
    773  object = create<object_t>();
    774  break;
    775  }
    776 
    777  case value_t::array:
    778  {
    779  array = create<array_t>();
    780  break;
    781  }
    782 
    783  case value_t::string:
    784  {
    785  string = create<string_t>("");
    786  break;
    787  }
    788 
    789  case value_t::boolean:
    790  {
    791  boolean = boolean_t(false);
    792  break;
    793  }
    794 
    795  case value_t::number_integer:
    796  {
    797  number_integer = number_integer_t(0);
    798  break;
    799  }
    800 
    801  case value_t::number_unsigned:
    802  {
    803  number_unsigned = number_unsigned_t(0);
    804  break;
    805  }
    806 
    807  case value_t::number_float:
    808  {
    809  number_float = number_float_t(0.0);
    810  break;
    811  }
    812 
    813  default:
    814  {
    815  break;
    816  }
    817  }
    818  }
    819 
    821  json_value(const string_t& value)
    822  {
    823  string = create<string_t>(value);
    824  }
    825 
    827  json_value(const object_t& value)
    828  {
    829  object = create<object_t>(value);
    830  }
    831 
    833  json_value(const array_t& value)
    834  {
    835  array = create<array_t>(value);
    836  }
    837  };
    838 
    839 
    840  public:
    842  // JSON parser callback //
    844 
    853  enum class parse_event_t : uint8_t
    854  {
    856  object_start,
    858  object_end,
    860  array_start,
    862  array_end,
    864  key,
    866  value
    867  };
    868 
    918  using parser_callback_t = std::function<bool(int depth, parse_event_t event, basic_json& parsed)>;
    919 
    920 
    922  // constructors //
    924 
    927 
    968  : m_type(value_type), m_value(value_type)
    969  {}
    970 
    995  basic_json() = default;
    996 
    1019  basic_json(std::nullptr_t) noexcept
    1020  : basic_json(value_t::null)
    1021  {}
    1022 
    1042  basic_json(const object_t& val)
    1043  : m_type(value_t::object), m_value(val)
    1044  {}
    1045 
    1072  template <class CompatibleObjectType, typename
    1073  std::enable_if<
    1074  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    1075  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    1076  = 0>
    1077  basic_json(const CompatibleObjectType& val)
    1078  : m_type(value_t::object)
    1079  {
    1080  using std::begin;
    1081  using std::end;
    1082  m_value.object = create<object_t>(begin(val), end(val));
    1083  }
    1084 
    1104  basic_json(const array_t& val)
    1105  : m_type(value_t::array), m_value(val)
    1106  {}
    1107 
    1134  template <class CompatibleArrayType, typename
    1135  std::enable_if<
    1136  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1137  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1138  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1139  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1140  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1141  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1142  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1143  = 0>
    1144  basic_json(const CompatibleArrayType& val)
    1145  : m_type(value_t::array)
    1146  {
    1147  using std::begin;
    1148  using std::end;
    1149  m_value.array = create<array_t>(begin(val), end(val));
    1150  }
    1151 
    1173  basic_json(const string_t& val)
    1174  : m_type(value_t::string), m_value(val)
    1175  {}
    1176 
    1197  basic_json(const typename string_t::value_type* val)
    1198  : basic_json(string_t(val))
    1199  {}
    1200 
    1224  template <class CompatibleStringType, typename
    1225  std::enable_if<
    1226  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1227  = 0>
    1228  basic_json(const CompatibleStringType& val)
    1229  : basic_json(string_t(val))
    1230  {}
    1231 
    1246  basic_json(boolean_t val) noexcept
    1247  : m_type(value_t::boolean), m_value(val)
    1248  {}
    1249 
    1273  template<typename T,
    1274  typename std::enable_if<
    1275  not (std::is_same<T, int>::value)
    1276  and std::is_same<T, number_integer_t>::value
    1277  , int>::type
    1278  = 0>
    1279  basic_json(const number_integer_t val) noexcept
    1280  : m_type(value_t::number_integer), m_value(val)
    1281  {}
    1282 
    1308  basic_json(const int val) noexcept
    1309  : m_type(value_t::number_integer),
    1310  m_value(static_cast<number_integer_t>(val))
    1311  {}
    1312 
    1338  template<typename CompatibleNumberIntegerType, typename
    1339  std::enable_if<
    1340  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1341  std::numeric_limits<CompatibleNumberIntegerType>::is_integer and
    1342  std::numeric_limits<CompatibleNumberIntegerType>::is_signed,
    1343  CompatibleNumberIntegerType>::type
    1344  = 0>
    1345  basic_json(const CompatibleNumberIntegerType val) noexcept
    1346  : m_type(value_t::number_integer),
    1347  m_value(static_cast<number_integer_t>(val))
    1348  {}
    1349 
    1367  template<typename T,
    1368  typename std::enable_if<
    1369  not (std::is_same<T, int>::value)
    1370  and std::is_same<T, number_unsigned_t>::value
    1371  , int>::type
    1372  = 0>
    1373  basic_json(const number_unsigned_t val) noexcept
    1374  : m_type(value_t::number_unsigned), m_value(val)
    1375  {}
    1376 
    1397  template <typename CompatibleNumberUnsignedType, typename
    1398  std::enable_if <
    1399  std::is_constructible<number_unsigned_t, CompatibleNumberUnsignedType>::value and
    1400  std::numeric_limits<CompatibleNumberUnsignedType>::is_integer and
    1401  not std::numeric_limits<CompatibleNumberUnsignedType>::is_signed,
    1402  CompatibleNumberUnsignedType>::type
    1403  = 0>
    1404  basic_json(const CompatibleNumberUnsignedType val) noexcept
    1405  : m_type(value_t::number_unsigned),
    1406  m_value(static_cast<number_unsigned_t>(val))
    1407  {}
    1408 
    1433  basic_json(const number_float_t val) noexcept
    1434  : m_type(value_t::number_float), m_value(val)
    1435  {
    1436  // replace infinity and NAN by null
    1437  if (not std::isfinite(val))
    1438  {
    1439  m_type = value_t::null;
    1440  m_value = json_value();
    1441  }
    1442  }
    1443 
    1475  template<typename CompatibleNumberFloatType, typename = typename
    1476  std::enable_if<
    1477  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1478  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1479  >
    1480  basic_json(const CompatibleNumberFloatType val) noexcept
    1481  : basic_json(number_float_t(val))
    1482  {}
    1483 
    1553  basic_json(std::initializer_list<basic_json> init,
    1554  bool type_deduction = true,
    1555  value_t manual_type = value_t::array)
    1556  {
    1557  // the initializer list could describe an object
    1558  bool is_an_object = true;
    1559 
    1560  // check if each element is an array with two elements whose first
    1561  // element is a string
    1562  for (const auto& element : init)
    1563  {
    1564  if (not element.is_array() or element.size() != 2
    1565  or not element[0].is_string())
    1566  {
    1567  // we found an element that makes it impossible to use the
    1568  // initializer list as object
    1569  is_an_object = false;
    1570  break;
    1571  }
    1572  }
    1573 
    1574  // adjust type if type deduction is not wanted
    1575  if (not type_deduction)
    1576  {
    1577  // if array is wanted, do not create an object though possible
    1578  if (manual_type == value_t::array)
    1579  {
    1580  is_an_object = false;
    1581  }
    1582 
    1583  // if object is wanted but impossible, throw an exception
    1584  if (manual_type == value_t::object and not is_an_object)
    1585  {
    1586  throw std::domain_error("cannot create object from initializer list");
    1587  }
    1588  }
    1589 
    1590  if (is_an_object)
    1591  {
    1592  // the initializer list is a list of pairs -> create object
    1593  m_type = value_t::object;
    1594  m_value = value_t::object;
    1595 
    1596  assert(m_value.object != nullptr);
    1597 
    1598  for (auto& element : init)
    1599  {
    1600  m_value.object->emplace(*(element[0].m_value.string), element[1]);
    1601  }
    1602  }
    1603  else
    1604  {
    1605  // the initializer list describes an array -> create array
    1606  m_type = value_t::array;
    1607  m_value.array = create<array_t>(init);
    1608  }
    1609  }
    1610 
    1645  static basic_json array(std::initializer_list<basic_json> init =
    1646  std::initializer_list<basic_json>())
    1647  {
    1648  return basic_json(init, false, value_t::array);
    1649  }
    1650 
    1685  static basic_json object(std::initializer_list<basic_json> init =
    1686  std::initializer_list<basic_json>())
    1687  {
    1688  return basic_json(init, false, value_t::object);
    1689  }
    1690 
    1709  basic_json(size_type cnt, const basic_json& val)
    1710  : m_type(value_t::array)
    1711  {
    1712  m_value.array = create<array_t>(cnt, val);
    1713  }
    1714 
    1749  template <class InputIT, typename
    1750  std::enable_if<
    1751  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1752  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1753  , int>::type
    1754  = 0>
    1755  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1756  {
    1757  // make sure iterator fits the current value
    1758  if (first.m_object != last.m_object)
    1759  {
    1760  throw std::domain_error("iterators are not compatible");
    1761  }
    1762 
    1763  // check if iterator range is complete for primitive values
    1764  switch (m_type)
    1765  {
    1766  case value_t::boolean:
    1767  case value_t::number_float:
    1768  case value_t::number_integer:
    1769  case value_t::number_unsigned:
    1770  case value_t::string:
    1771  {
    1772  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1773  {
    1774  throw std::out_of_range("iterators out of range");
    1775  }
    1776  break;
    1777  }
    1778 
    1779  default:
    1780  {
    1781  break;
    1782  }
    1783  }
    1784 
    1785  switch (m_type)
    1786  {
    1787  case value_t::number_integer:
    1788  {
    1789  assert(first.m_object != nullptr);
    1790  m_value.number_integer = first.m_object->m_value.number_integer;
    1791  break;
    1792  }
    1793 
    1794  case value_t::number_unsigned:
    1795  {
    1796  assert(first.m_object != nullptr);
    1797  m_value.number_unsigned = first.m_object->m_value.number_unsigned;
    1798  break;
    1799  }
    1800 
    1801  case value_t::number_float:
    1802  {
    1803  assert(first.m_object != nullptr);
    1804  m_value.number_float = first.m_object->m_value.number_float;
    1805  break;
    1806  }
    1807 
    1808  case value_t::boolean:
    1809  {
    1810  assert(first.m_object != nullptr);
    1811  m_value.boolean = first.m_object->m_value.boolean;
    1812  break;
    1813  }
    1814 
    1815  case value_t::string:
    1816  {
    1817  assert(first.m_object != nullptr);
    1818  m_value = *first.m_object->m_value.string;
    1819  break;
    1820  }
    1821 
    1822  case value_t::object:
    1823  {
    1824  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1825  break;
    1826  }
    1827 
    1828  case value_t::array:
    1829  {
    1830  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1831  break;
    1832  }
    1833 
    1834  default:
    1835  {
    1836  assert(first.m_object != nullptr);
    1837  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1838  }
    1839  }
    1840  }
    1841 
    1862  explicit basic_json(std::istream& i, parser_callback_t cb = nullptr)
    1863  {
    1864  *this = parser(i, cb).parse();
    1865  }
    1866 
    1868  // other constructors and destructor //
    1870 
    1893  basic_json(const basic_json& other)
    1894  : m_type(other.m_type)
    1895  {
    1896  switch (m_type)
    1897  {
    1898  case value_t::object:
    1899  {
    1900  assert(other.m_value.object != nullptr);
    1901  m_value = *other.m_value.object;
    1902  break;
    1903  }
    1904 
    1905  case value_t::array:
    1906  {
    1907  assert(other.m_value.array != nullptr);
    1908  m_value = *other.m_value.array;
    1909  break;
    1910  }
    1911 
    1912  case value_t::string:
    1913  {
    1914  assert(other.m_value.string != nullptr);
    1915  m_value = *other.m_value.string;
    1916  break;
    1917  }
    1918 
    1919  case value_t::boolean:
    1920  {
    1921  m_value = other.m_value.boolean;
    1922  break;
    1923  }
    1924 
    1925  case value_t::number_integer:
    1926  {
    1927  m_value = other.m_value.number_integer;
    1928  break;
    1929  }
    1930 
    1931  case value_t::number_unsigned:
    1932  {
    1933  m_value = other.m_value.number_unsigned;
    1934  break;
    1935  }
    1936 
    1937  case value_t::number_float:
    1938  {
    1939  m_value = other.m_value.number_float;
    1940  break;
    1941  }
    1942 
    1943  default:
    1944  {
    1945  break;
    1946  }
    1947  }
    1948  }
    1949 
    1968  basic_json(basic_json&& other) noexcept
    1969  : m_type(std::move(other.m_type)),
    1970  m_value(std::move(other.m_value))
    1971  {
    1972  // invalidate payload
    1973  other.m_type = value_t::null;
    1974  other.m_value = {};
    1975  }
    1976 
    2000  reference& operator=(basic_json other) noexcept (
    2001  std::is_nothrow_move_constructible<value_t>::value and
    2002  std::is_nothrow_move_assignable<value_t>::value and
    2003  std::is_nothrow_move_constructible<json_value>::value and
    2004  std::is_nothrow_move_assignable<json_value>::value
    2005  )
    2006  {
    2007  using std::swap;
    2008  swap(m_type, other.m_type);
    2009  swap(m_value, other.m_value);
    2010  return *this;
    2011  }
    2012 
    2029  {
    2030  switch (m_type)
    2031  {
    2032  case value_t::object:
    2033  {
    2034  AllocatorType<object_t> alloc;
    2035  alloc.destroy(m_value.object);
    2036  alloc.deallocate(m_value.object, 1);
    2037  break;
    2038  }
    2039 
    2040  case value_t::array:
    2041  {
    2042  AllocatorType<array_t> alloc;
    2043  alloc.destroy(m_value.array);
    2044  alloc.deallocate(m_value.array, 1);
    2045  break;
    2046  }
    2047 
    2048  case value_t::string:
    2049  {
    2050  AllocatorType<string_t> alloc;
    2051  alloc.destroy(m_value.string);
    2052  alloc.deallocate(m_value.string, 1);
    2053  break;
    2054  }
    2055 
    2056  default:
    2057  {
    2058  // all other types need no specific destructor
    2059  break;
    2060  }
    2061  }
    2062  }
    2063 
    2065 
    2066  public:
    2068  // object inspection //
    2070 
    2073 
    2097  string_t dump(const int indent = -1) const
    2098  {
    2099  std::stringstream ss;
    2100  // fix locale problems
    2101  ss.imbue(std::locale(std::locale(), new DecimalSeparator));
    2102 
    2103  if (indent >= 0)
    2104  {
    2105  dump(ss, true, static_cast<unsigned int>(indent));
    2106  }
    2107  else
    2108  {
    2109  dump(ss, false, 0);
    2110  }
    2111 
    2112  return ss.str();
    2113  }
    2114 
    2133  constexpr value_t type() const noexcept
    2134  {
    2135  return m_type;
    2136  }
    2137 
    2163  constexpr bool is_primitive() const noexcept
    2164  {
    2165  return is_null() or is_string() or is_boolean() or is_number();
    2166  }
    2167 
    2190  constexpr bool is_structured() const noexcept
    2191  {
    2192  return is_array() or is_object();
    2193  }
    2194 
    2212  constexpr bool is_null() const noexcept
    2213  {
    2214  return m_type == value_t::null;
    2215  }
    2216 
    2234  constexpr bool is_boolean() const noexcept
    2235  {
    2236  return m_type == value_t::boolean;
    2237  }
    2238 
    2264  constexpr bool is_number() const noexcept
    2265  {
    2266  return is_number_integer() or is_number_float();
    2267  }
    2268 
    2293  constexpr bool is_number_integer() const noexcept
    2294  {
    2295  return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
    2296  }
    2297 
    2321  constexpr bool is_number_unsigned() const noexcept
    2322  {
    2323  return m_type == value_t::number_unsigned;
    2324  }
    2325 
    2349  constexpr bool is_number_float() const noexcept
    2350  {
    2351  return m_type == value_t::number_float;
    2352  }
    2353 
    2371  constexpr bool is_object() const noexcept
    2372  {
    2373  return m_type == value_t::object;
    2374  }
    2375 
    2393  constexpr bool is_array() const noexcept
    2394  {
    2395  return m_type == value_t::array;
    2396  }
    2397 
    2415  constexpr bool is_string() const noexcept
    2416  {
    2417  return m_type == value_t::string;
    2418  }
    2419 
    2442  constexpr bool is_discarded() const noexcept
    2443  {
    2444  return m_type == value_t::discarded;
    2445  }
    2446 
    2465  constexpr operator value_t() const noexcept
    2466  {
    2467  return m_type;
    2468  }
    2469 
    2471 
    2472  private:
    2474  // value access //
    2476 
    2478  template <class T, typename
    2479  std::enable_if<
    2480  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2481  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2482  , int>::type = 0>
    2483  T get_impl(T*) const
    2484  {
    2485  if (is_object())
    2486  {
    2487  assert(m_value.object != nullptr);
    2488  return T(m_value.object->begin(), m_value.object->end());
    2489  }
    2490  else
    2491  {
    2492  throw std::domain_error("type must be object, but is " + type_name());
    2493  }
    2494  }
    2495 
    2497  object_t get_impl(object_t*) const
    2498  {
    2499  if (is_object())
    2500  {
    2501  assert(m_value.object != nullptr);
    2502  return *(m_value.object);
    2503  }
    2504  else
    2505  {
    2506  throw std::domain_error("type must be object, but is " + type_name());
    2507  }
    2508  }
    2509 
    2511  template <class T, typename
    2512  std::enable_if<
    2513  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2514  not std::is_same<basic_json_t, typename T::value_type>::value and
    2515  not std::is_arithmetic<T>::value and
    2516  not std::is_convertible<std::string, T>::value and
    2517  not has_mapped_type<T>::value
    2518  , int>::type = 0>
    2519  T get_impl(T*) const
    2520  {
    2521  if (is_array())
    2522  {
    2523  T to_vector;
    2524  assert(m_value.array != nullptr);
    2525  std::transform(m_value.array->begin(), m_value.array->end(),
    2526  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2527  {
    2528  return i.get<typename T::value_type>();
    2529  });
    2530  return to_vector;
    2531  }
    2532  else
    2533  {
    2534  throw std::domain_error("type must be array, but is " + type_name());
    2535  }
    2536  }
    2537 
    2539  template <class T, typename
    2540  std::enable_if<
    2541  std::is_convertible<basic_json_t, T>::value and
    2542  not std::is_same<basic_json_t, T>::value
    2543  , int>::type = 0>
    2544  std::vector<T> get_impl(std::vector<T>*) const
    2545  {
    2546  if (is_array())
    2547  {
    2548  std::vector<T> to_vector;
    2549  assert(m_value.array != nullptr);
    2550  to_vector.reserve(m_value.array->size());
    2551  std::transform(m_value.array->begin(), m_value.array->end(),
    2552  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2553  {
    2554  return i.get<T>();
    2555  });
    2556  return to_vector;
    2557  }
    2558  else
    2559  {
    2560  throw std::domain_error("type must be array, but is " + type_name());
    2561  }
    2562  }
    2563 
    2565  template <class T, typename
    2566  std::enable_if<
    2567  std::is_same<basic_json, typename T::value_type>::value and
    2568  not has_mapped_type<T>::value
    2569  , int>::type = 0>
    2570  T get_impl(T*) const
    2571  {
    2572  if (is_array())
    2573  {
    2574  assert(m_value.array != nullptr);
    2575  return T(m_value.array->begin(), m_value.array->end());
    2576  }
    2577  else
    2578  {
    2579  throw std::domain_error("type must be array, but is " + type_name());
    2580  }
    2581  }
    2582 
    2584  array_t get_impl(array_t*) const
    2585  {
    2586  if (is_array())
    2587  {
    2588  assert(m_value.array != nullptr);
    2589  return *(m_value.array);
    2590  }
    2591  else
    2592  {
    2593  throw std::domain_error("type must be array, but is " + type_name());
    2594  }
    2595  }
    2596 
    2598  template <typename T, typename
    2599  std::enable_if<
    2600  std::is_convertible<string_t, T>::value
    2601  , int>::type = 0>
    2602  T get_impl(T*) const
    2603  {
    2604  if (is_string())
    2605  {
    2606  assert(m_value.string != nullptr);
    2607  return *m_value.string;
    2608  }
    2609  else
    2610  {
    2611  throw std::domain_error("type must be string, but is " + type_name());
    2612  }
    2613  }
    2614 
    2616  template<typename T, typename
    2617  std::enable_if<
    2618  std::is_arithmetic<T>::value
    2619  , int>::type = 0>
    2620  T get_impl(T*) const
    2621  {
    2622  switch (m_type)
    2623  {
    2624  case value_t::number_integer:
    2625  {
    2626  return static_cast<T>(m_value.number_integer);
    2627  }
    2628 
    2629  case value_t::number_unsigned:
    2630  {
    2631  return static_cast<T>(m_value.number_unsigned);
    2632  }
    2633 
    2634  case value_t::number_float:
    2635  {
    2636  return static_cast<T>(m_value.number_float);
    2637  }
    2638 
    2639  default:
    2640  {
    2641  throw std::domain_error("type must be number, but is " + type_name());
    2642  }
    2643  }
    2644  }
    2645 
    2647  constexpr boolean_t get_impl(boolean_t*) const
    2648  {
    2649  return is_boolean()
    2650  ? m_value.boolean
    2651  : throw std::domain_error("type must be boolean, but is " + type_name());
    2652  }
    2653 
    2655  object_t* get_impl_ptr(object_t*) noexcept
    2656  {
    2657  return is_object() ? m_value.object : nullptr;
    2658  }
    2659 
    2661  constexpr const object_t* get_impl_ptr(const object_t*) const noexcept
    2662  {
    2663  return is_object() ? m_value.object : nullptr;
    2664  }
    2665 
    2667  array_t* get_impl_ptr(array_t*) noexcept
    2668  {
    2669  return is_array() ? m_value.array : nullptr;
    2670  }
    2671 
    2673  constexpr const array_t* get_impl_ptr(const array_t*) const noexcept
    2674  {
    2675  return is_array() ? m_value.array : nullptr;
    2676  }
    2677 
    2679  string_t* get_impl_ptr(string_t*) noexcept
    2680  {
    2681  return is_string() ? m_value.string : nullptr;
    2682  }
    2683 
    2685  constexpr const string_t* get_impl_ptr(const string_t*) const noexcept
    2686  {
    2687  return is_string() ? m_value.string : nullptr;
    2688  }
    2689 
    2691  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2692  {
    2693  return is_boolean() ? &m_value.boolean : nullptr;
    2694  }
    2695 
    2697  constexpr const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2698  {
    2699  return is_boolean() ? &m_value.boolean : nullptr;
    2700  }
    2701 
    2703  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2704  {
    2705  return is_number_integer() ? &m_value.number_integer : nullptr;
    2706  }
    2707 
    2709  constexpr const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2710  {
    2711  return is_number_integer() ? &m_value.number_integer : nullptr;
    2712  }
    2713 
    2715  number_unsigned_t* get_impl_ptr(number_unsigned_t*) noexcept
    2716  {
    2717  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2718  }
    2719 
    2721  constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t*) const noexcept
    2722  {
    2723  return is_number_unsigned() ? &m_value.number_unsigned : nullptr;
    2724  }
    2725 
    2727  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2728  {
    2729  return is_number_float() ? &m_value.number_float : nullptr;
    2730  }
    2731 
    2733  constexpr const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2734  {
    2735  return is_number_float() ? &m_value.number_float : nullptr;
    2736  }
    2737 
    2749  template<typename ReferenceType, typename ThisType>
    2750  static ReferenceType get_ref_impl(ThisType& obj)
    2751  {
    2752  // delegate the call to get_ptr<>()
    2753  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2754  auto ptr = obj.template get_ptr<PointerType>();
    2755 
    2756  if (ptr != nullptr)
    2757  {
    2758  return *ptr;
    2759  }
    2760  else
    2761  {
    2762  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2763  obj.type_name());
    2764  }
    2765  }
    2766 
    2767  public:
    2768 
    2771 
    2805  template<typename ValueType, typename
    2806  std::enable_if<
    2807  not std::is_pointer<ValueType>::value
    2808  , int>::type = 0>
    2809  ValueType get() const
    2810  {
    2811  return get_impl(static_cast<ValueType*>(nullptr));
    2812  }
    2813 
    2840  template<typename PointerType, typename
    2841  std::enable_if<
    2842  std::is_pointer<PointerType>::value
    2843  , int>::type = 0>
    2844  PointerType get() noexcept
    2845  {
    2846  // delegate the call to get_ptr
    2847  return get_ptr<PointerType>();
    2848  }
    2849 
    2854  template<typename PointerType, typename
    2855  std::enable_if<
    2856  std::is_pointer<PointerType>::value
    2857  , int>::type = 0>
    2858  constexpr const PointerType get() const noexcept
    2859  {
    2860  // delegate the call to get_ptr
    2861  return get_ptr<PointerType>();
    2862  }
    2863 
    2889  template<typename PointerType, typename
    2890  std::enable_if<
    2891  std::is_pointer<PointerType>::value
    2892  , int>::type = 0>
    2893  PointerType get_ptr() noexcept
    2894  {
    2895  // delegate the call to get_impl_ptr<>()
    2896  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2897  }
    2898 
    2903  template<typename PointerType, typename
    2904  std::enable_if<
    2905  std::is_pointer<PointerType>::value
    2906  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2907  , int>::type = 0>
    2908  constexpr const PointerType get_ptr() const noexcept
    2909  {
    2910  // delegate the call to get_impl_ptr<>() const
    2911  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2912  }
    2913 
    2940  template<typename ReferenceType, typename
    2941  std::enable_if<
    2942  std::is_reference<ReferenceType>::value
    2943  , int>::type = 0>
    2944  ReferenceType get_ref()
    2945  {
    2946  // delegate call to get_ref_impl
    2947  return get_ref_impl<ReferenceType>(*this);
    2948  }
    2949 
    2954  template<typename ReferenceType, typename
    2955  std::enable_if<
    2956  std::is_reference<ReferenceType>::value
    2957  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2958  , int>::type = 0>
    2959  ReferenceType get_ref() const
    2960  {
    2961  // delegate call to get_ref_impl
    2962  return get_ref_impl<ReferenceType>(*this);
    2963  }
    2964 
    2993  template < typename ValueType, typename
    2994  std::enable_if <
    2995  not std::is_pointer<ValueType>::value
    2996  and not std::is_same<ValueType, typename string_t::value_type>::value
    2997 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2998  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2999 #endif
    3000  , int >::type = 0 >
    3001  operator ValueType() const
    3002  {
    3003  // delegate the call to get<>() const
    3004  return get<ValueType>();
    3005  }
    3006 
    3008 
    3009 
    3011  // element access //
    3013 
    3016 
    3040  {
    3041  // at only works for arrays
    3042  if (is_array())
    3043  {
    3044  try
    3045  {
    3046  assert(m_value.array != nullptr);
    3047  return m_value.array->at(idx);
    3048  }
    3049  catch (std::out_of_range&)
    3050  {
    3051  // create better exception explanation
    3052  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3053  }
    3054  }
    3055  else
    3056  {
    3057  throw std::domain_error("cannot use at() with " + type_name());
    3058  }
    3059  }
    3060 
    3084  {
    3085  // at only works for arrays
    3086  if (is_array())
    3087  {
    3088  try
    3089  {
    3090  assert(m_value.array != nullptr);
    3091  return m_value.array->at(idx);
    3092  }
    3093  catch (std::out_of_range&)
    3094  {
    3095  // create better exception explanation
    3096  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3097  }
    3098  }
    3099  else
    3100  {
    3101  throw std::domain_error("cannot use at() with " + type_name());
    3102  }
    3103  }
    3104 
    3131  reference at(const typename object_t::key_type& key)
    3132  {
    3133  // at only works for objects
    3134  if (is_object())
    3135  {
    3136  try
    3137  {
    3138  assert(m_value.object != nullptr);
    3139  return m_value.object->at(key);
    3140  }
    3141  catch (std::out_of_range&)
    3142  {
    3143  // create better exception explanation
    3144  throw std::out_of_range("key '" + key + "' not found");
    3145  }
    3146  }
    3147  else
    3148  {
    3149  throw std::domain_error("cannot use at() with " + type_name());
    3150  }
    3151  }
    3152 
    3179  const_reference at(const typename object_t::key_type& key) const
    3180  {
    3181  // at only works for objects
    3182  if (is_object())
    3183  {
    3184  try
    3185  {
    3186  assert(m_value.object != nullptr);
    3187  return m_value.object->at(key);
    3188  }
    3189  catch (std::out_of_range&)
    3190  {
    3191  // create better exception explanation
    3192  throw std::out_of_range("key '" + key + "' not found");
    3193  }
    3194  }
    3195  else
    3196  {
    3197  throw std::domain_error("cannot use at() with " + type_name());
    3198  }
    3199  }
    3200 
    3227  {
    3228  // implicitly convert null value to an empty array
    3229  if (is_null())
    3230  {
    3231  m_type = value_t::array;
    3232  m_value.array = create<array_t>();
    3233  }
    3234 
    3235  // operator[] only works for arrays
    3236  if (is_array())
    3237  {
    3238  // fill up array with null values until given idx is reached
    3239  assert(m_value.array != nullptr);
    3240  for (size_t i = m_value.array->size(); i <= idx; ++i)
    3241  {
    3242  m_value.array->push_back(basic_json());
    3243  }
    3244 
    3245  return m_value.array->operator[](idx);
    3246  }
    3247  else
    3248  {
    3249  throw std::domain_error("cannot use operator[] with " + type_name());
    3250  }
    3251  }
    3252 
    3273  {
    3274  // const operator[] only works for arrays
    3275  if (is_array())
    3276  {
    3277  assert(m_value.array != nullptr);
    3278  return m_value.array->operator[](idx);
    3279  }
    3280  else
    3281  {
    3282  throw std::domain_error("cannot use operator[] with " + type_name());
    3283  }
    3284  }
    3285 
    3313  reference operator[](const typename object_t::key_type& key)
    3314  {
    3315  // implicitly convert null value to an empty object
    3316  if (is_null())
    3317  {
    3318  m_type = value_t::object;
    3319  m_value.object = create<object_t>();
    3320  }
    3321 
    3322  // operator[] only works for objects
    3323  if (is_object())
    3324  {
    3325  assert(m_value.object != nullptr);
    3326  return m_value.object->operator[](key);
    3327  }
    3328  else
    3329  {
    3330  throw std::domain_error("cannot use operator[] with " + type_name());
    3331  }
    3332  }
    3333 
    3361  const_reference operator[](const typename object_t::key_type& key) const
    3362  {
    3363  // const operator[] only works for objects
    3364  if (is_object())
    3365  {
    3366  assert(m_value.object != nullptr);
    3367  assert(m_value.object->find(key) != m_value.object->end());
    3368  return m_value.object->find(key)->second;
    3369  }
    3370  else
    3371  {
    3372  throw std::domain_error("cannot use operator[] with " + type_name());
    3373  }
    3374  }
    3375 
    3403  template<typename T, std::size_t n>
    3404  reference operator[](T * (&key)[n])
    3405  {
    3406  return operator[](static_cast<const T>(key));
    3407  }
    3408 
    3438  template<typename T, std::size_t n>
    3439  const_reference operator[](T * (&key)[n]) const
    3440  {
    3441  return operator[](static_cast<const T>(key));
    3442  }
    3443 
    3471  template<typename T>
    3473  {
    3474  // implicitly convert null to object
    3475  if (is_null())
    3476  {
    3477  m_type = value_t::object;
    3478  m_value = value_t::object;
    3479  }
    3480 
    3481  // at only works for objects
    3482  if (is_object())
    3483  {
    3484  assert(m_value.object != nullptr);
    3485  return m_value.object->operator[](key);
    3486  }
    3487  else
    3488  {
    3489  throw std::domain_error("cannot use operator[] with " + type_name());
    3490  }
    3491  }
    3492 
    3520  template<typename T>
    3522  {
    3523  // at only works for objects
    3524  if (is_object())
    3525  {
    3526  assert(m_value.object != nullptr);
    3527  assert(m_value.object->find(key) != m_value.object->end());
    3528  return m_value.object->find(key)->second;
    3529  }
    3530  else
    3531  {
    3532  throw std::domain_error("cannot use operator[] with " + type_name());
    3533  }
    3534  }
    3535 
    3584  template <class ValueType, typename
    3585  std::enable_if<
    3586  std::is_convertible<basic_json_t, ValueType>::value
    3587  , int>::type = 0>
    3588  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3589  {
    3590  // at only works for objects
    3591  if (is_object())
    3592  {
    3593  // if key is found, return value and given default value otherwise
    3594  const auto it = find(key);
    3595  if (it != end())
    3596  {
    3597  return *it;
    3598  }
    3599  else
    3600  {
    3601  return default_value;
    3602  }
    3603  }
    3604  else
    3605  {
    3606  throw std::domain_error("cannot use value() with " + type_name());
    3607  }
    3608  }
    3609 
    3614  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3615  {
    3616  return value(key, string_t(default_value));
    3617  }
    3618 
    3644  {
    3645  return *begin();
    3646  }
    3647 
    3652  {
    3653  return *cbegin();
    3654  }
    3655 
    3686  {
    3687  auto tmp = end();
    3688  --tmp;
    3689  return *tmp;
    3690  }
    3691 
    3696  {
    3697  auto tmp = cend();
    3698  --tmp;
    3699  return *tmp;
    3700  }
    3701 
    3747  template <class InteratorType, typename
    3748  std::enable_if<
    3749  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3750  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3751  , int>::type
    3752  = 0>
    3753  InteratorType erase(InteratorType pos)
    3754  {
    3755  // make sure iterator fits the current value
    3756  if (this != pos.m_object)
    3757  {
    3758  throw std::domain_error("iterator does not fit current value");
    3759  }
    3760 
    3761  InteratorType result = end();
    3762 
    3763  switch (m_type)
    3764  {
    3765  case value_t::boolean:
    3766  case value_t::number_float:
    3767  case value_t::number_integer:
    3768  case value_t::number_unsigned:
    3769  case value_t::string:
    3770  {
    3771  if (not pos.m_it.primitive_iterator.is_begin())
    3772  {
    3773  throw std::out_of_range("iterator out of range");
    3774  }
    3775 
    3776  if (is_string())
    3777  {
    3778  delete m_value.string;
    3779  m_value.string = nullptr;
    3780  }
    3781 
    3782  m_type = value_t::null;
    3783  break;
    3784  }
    3785 
    3786  case value_t::object:
    3787  {
    3788  assert(m_value.object != nullptr);
    3789  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3790  break;
    3791  }
    3792 
    3793  case value_t::array:
    3794  {
    3795  assert(m_value.array != nullptr);
    3796  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3797  break;
    3798  }
    3799 
    3800  default:
    3801  {
    3802  throw std::domain_error("cannot use erase() with " + type_name());
    3803  }
    3804  }
    3805 
    3806  return result;
    3807  }
    3808 
    3855  template <class InteratorType, typename
    3856  std::enable_if<
    3857  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3858  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3859  , int>::type
    3860  = 0>
    3861  InteratorType erase(InteratorType first, InteratorType last)
    3862  {
    3863  // make sure iterator fits the current value
    3864  if (this != first.m_object or this != last.m_object)
    3865  {
    3866  throw std::domain_error("iterators do not fit current value");
    3867  }
    3868 
    3869  InteratorType result = end();
    3870 
    3871  switch (m_type)
    3872  {
    3873  case value_t::boolean:
    3874  case value_t::number_float:
    3875  case value_t::number_integer:
    3876  case value_t::number_unsigned:
    3877  case value_t::string:
    3878  {
    3879  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3880  {
    3881  throw std::out_of_range("iterators out of range");
    3882  }
    3883 
    3884  if (is_string())
    3885  {
    3886  delete m_value.string;
    3887  m_value.string = nullptr;
    3888  }
    3889 
    3890  m_type = value_t::null;
    3891  break;
    3892  }
    3893 
    3894  case value_t::object:
    3895  {
    3896  assert(m_value.object != nullptr);
    3897  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3898  last.m_it.object_iterator);
    3899  break;
    3900  }
    3901 
    3902  case value_t::array:
    3903  {
    3904  assert(m_value.array != nullptr);
    3905  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3906  last.m_it.array_iterator);
    3907  break;
    3908  }
    3909 
    3910  default:
    3911  {
    3912  throw std::domain_error("cannot use erase() with " + type_name());
    3913  }
    3914  }
    3915 
    3916  return result;
    3917  }
    3918 
    3948  size_type erase(const typename object_t::key_type& key)
    3949  {
    3950  // this erase only works for objects
    3951  if (is_object())
    3952  {
    3953  assert(m_value.object != nullptr);
    3954  return m_value.object->erase(key);
    3955  }
    3956  else
    3957  {
    3958  throw std::domain_error("cannot use erase() with " + type_name());
    3959  }
    3960  }
    3961 
    3986  void erase(const size_type idx)
    3987  {
    3988  // this erase only works for arrays
    3989  if (is_array())
    3990  {
    3991  if (idx >= size())
    3992  {
    3993  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    3994  }
    3995 
    3996  assert(m_value.array != nullptr);
    3997  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3998  }
    3999  else
    4000  {
    4001  throw std::domain_error("cannot use erase() with " + type_name());
    4002  }
    4003  }
    4004 
    4006 
    4007 
    4009  // lookup //
    4011 
    4014 
    4033  iterator find(typename object_t::key_type key)
    4034  {
    4035  auto result = end();
    4036 
    4037  if (is_object())
    4038  {
    4039  assert(m_value.object != nullptr);
    4040  result.m_it.object_iterator = m_value.object->find(key);
    4041  }
    4042 
    4043  return result;
    4044  }
    4045 
    4050  const_iterator find(typename object_t::key_type key) const
    4051  {
    4052  auto result = cend();
    4053 
    4054  if (is_object())
    4055  {
    4056  assert(m_value.object != nullptr);
    4057  result.m_it.object_iterator = m_value.object->find(key);
    4058  }
    4059 
    4060  return result;
    4061  }
    4062 
    4081  size_type count(typename object_t::key_type key) const
    4082  {
    4083  // return 0 for all nonobject types
    4084  assert(not is_object() or m_value.object != nullptr);
    4085  return is_object() ? m_value.object->count(key) : 0;
    4086  }
    4087 
    4089 
    4090 
    4092  // iterators //
    4094 
    4097 
    4122  iterator begin() noexcept
    4123  {
    4124  iterator result(this);
    4125  result.set_begin();
    4126  return result;
    4127  }
    4128 
    4132  const_iterator begin() const noexcept
    4133  {
    4134  return cbegin();
    4135  }
    4136 
    4162  const_iterator cbegin() const noexcept
    4163  {
    4164  const_iterator result(this);
    4165  result.set_begin();
    4166  return result;
    4167  }
    4168 
    4193  iterator end() noexcept
    4194  {
    4195  iterator result(this);
    4196  result.set_end();
    4197  return result;
    4198  }
    4199 
    4203  const_iterator end() const noexcept
    4204  {
    4205  return cend();
    4206  }
    4207 
    4233  const_iterator cend() const noexcept
    4234  {
    4235  const_iterator result(this);
    4236  result.set_end();
    4237  return result;
    4238  }
    4239 
    4264  {
    4265  return reverse_iterator(end());
    4266  }
    4267 
    4272  {
    4273  return crbegin();
    4274  }
    4275 
    4301  {
    4302  return reverse_iterator(begin());
    4303  }
    4304 
    4308  const_reverse_iterator rend() const noexcept
    4309  {
    4310  return crend();
    4311  }
    4312 
    4338  {
    4339  return const_reverse_iterator(cend());
    4340  }
    4341 
    4367  {
    4368  return const_reverse_iterator(cbegin());
    4369  }
    4370 
    4371  private:
    4372  // forward declaration
    4373  template<typename IteratorType> class iteration_proxy;
    4374 
    4375  public:
    4387  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    4388  {
    4389  return iteration_proxy<iterator>(cont);
    4390  }
    4391 
    4395  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4396  {
    4397  return iteration_proxy<const_iterator>(cont);
    4398  }
    4399 
    4401 
    4402 
    4404  // capacity //
    4406 
    4409 
    4443  bool empty() const noexcept
    4444  {
    4445  switch (m_type)
    4446  {
    4447  case value_t::null:
    4448  {
    4449  // null values are empty
    4450  return true;
    4451  }
    4452 
    4453  case value_t::array:
    4454  {
    4455  assert(m_value.array != nullptr);
    4456  return m_value.array->empty();
    4457  }
    4458 
    4459  case value_t::object:
    4460  {
    4461  assert(m_value.object != nullptr);
    4462  return m_value.object->empty();
    4463  }
    4464 
    4465  default:
    4466  {
    4467  // all other types are nonempty
    4468  return false;
    4469  }
    4470  }
    4471  }
    4472 
    4507  size_type size() const noexcept
    4508  {
    4509  switch (m_type)
    4510  {
    4511  case value_t::null:
    4512  {
    4513  // null values are empty
    4514  return 0;
    4515  }
    4516 
    4517  case value_t::array:
    4518  {
    4519  assert(m_value.array != nullptr);
    4520  return m_value.array->size();
    4521  }
    4522 
    4523  case value_t::object:
    4524  {
    4525  assert(m_value.object != nullptr);
    4526  return m_value.object->size();
    4527  }
    4528 
    4529  default:
    4530  {
    4531  // all other types have size 1
    4532  return 1;
    4533  }
    4534  }
    4535  }
    4536 
    4573  size_type max_size() const noexcept
    4574  {
    4575  switch (m_type)
    4576  {
    4577  case value_t::array:
    4578  {
    4579  assert(m_value.array != nullptr);
    4580  return m_value.array->max_size();
    4581  }
    4582 
    4583  case value_t::object:
    4584  {
    4585  assert(m_value.object != nullptr);
    4586  return m_value.object->max_size();
    4587  }
    4588 
    4589  default:
    4590  {
    4591  // all other types have max_size() == size()
    4592  return size();
    4593  }
    4594  }
    4595  }
    4596 
    4598 
    4599 
    4601  // modifiers //
    4603 
    4606 
    4632  void clear() noexcept
    4633  {
    4634  switch (m_type)
    4635  {
    4636  case value_t::number_integer:
    4637  {
    4638  m_value.number_integer = 0;
    4639  break;
    4640  }
    4641 
    4642  case value_t::number_unsigned:
    4643  {
    4644  m_value.number_unsigned = 0;
    4645  break;
    4646  }
    4647 
    4648  case value_t::number_float:
    4649  {
    4650  m_value.number_float = 0.0;
    4651  break;
    4652  }
    4653 
    4654  case value_t::boolean:
    4655  {
    4656  m_value.boolean = false;
    4657  break;
    4658  }
    4659 
    4660  case value_t::string:
    4661  {
    4662  assert(m_value.string != nullptr);
    4663  m_value.string->clear();
    4664  break;
    4665  }
    4666 
    4667  case value_t::array:
    4668  {
    4669  assert(m_value.array != nullptr);
    4670  m_value.array->clear();
    4671  break;
    4672  }
    4673 
    4674  case value_t::object:
    4675  {
    4676  assert(m_value.object != nullptr);
    4677  m_value.object->clear();
    4678  break;
    4679  }
    4680 
    4681  default:
    4682  {
    4683  break;
    4684  }
    4685  }
    4686  }
    4687 
    4708  void push_back(basic_json&& val)
    4709  {
    4710  // push_back only works for null objects or arrays
    4711  if (not(is_null() or is_array()))
    4712  {
    4713  throw std::domain_error("cannot use push_back() with " + type_name());
    4714  }
    4715 
    4716  // transform null object into an array
    4717  if (is_null())
    4718  {
    4719  m_type = value_t::array;
    4720  m_value = value_t::array;
    4721  }
    4722 
    4723  // add element to array (move semantics)
    4724  assert(m_value.array != nullptr);
    4725  m_value.array->push_back(std::move(val));
    4726  // invalidate object
    4727  val.m_type = value_t::null;
    4728  }
    4729 
    4734  reference operator+=(basic_json&& val)
    4735  {
    4736  push_back(std::move(val));
    4737  return *this;
    4738  }
    4739 
    4744  void push_back(const basic_json& val)
    4745  {
    4746  // push_back only works for null objects or arrays
    4747  if (not(is_null() or is_array()))
    4748  {
    4749  throw std::domain_error("cannot use push_back() with " + type_name());
    4750  }
    4751 
    4752  // transform null object into an array
    4753  if (is_null())
    4754  {
    4755  m_type = value_t::array;
    4756  m_value = value_t::array;
    4757  }
    4758 
    4759  // add element to array
    4760  assert(m_value.array != nullptr);
    4761  m_value.array->push_back(val);
    4762  }
    4763 
    4768  reference operator+=(const basic_json& val)
    4769  {
    4770  push_back(val);
    4771  return *this;
    4772  }
    4773 
    4794  void push_back(const typename object_t::value_type& val)
    4795  {
    4796  // push_back only works for null objects or objects
    4797  if (not(is_null() or is_object()))
    4798  {
    4799  throw std::domain_error("cannot use push_back() with " + type_name());
    4800  }
    4801 
    4802  // transform null object into an object
    4803  if (is_null())
    4804  {
    4805  m_type = value_t::object;
    4806  m_value = value_t::object;
    4807  }
    4808 
    4809  // add element to array
    4810  assert(m_value.object != nullptr);
    4811  m_value.object->insert(val);
    4812  }
    4813 
    4818  reference operator+=(const typename object_t::value_type& val)
    4819  {
    4820  push_back(val);
    4821  return *this;
    4822  }
    4823 
    4849  void push_back(std::initializer_list<basic_json> init)
    4850  {
    4851  if (is_object() and init.size() == 2 and init.begin()->is_string())
    4852  {
    4853  const string_t key = *init.begin();
    4854  push_back(typename object_t::value_type(key, *(init.begin() + 1)));
    4855  }
    4856  else
    4857  {
    4858  push_back(basic_json(init));
    4859  }
    4860  }
    4861 
    4866  reference operator+=(std::initializer_list<basic_json> init)
    4867  {
    4868  push_back(init);
    4869  return *this;
    4870  }
    4871 
    4894  iterator insert(const_iterator pos, const basic_json& val)
    4895  {
    4896  // insert only works for arrays
    4897  if (is_array())
    4898  {
    4899  // check if iterator pos fits to this JSON value
    4900  if (pos.m_object != this)
    4901  {
    4902  throw std::domain_error("iterator does not fit current value");
    4903  }
    4904 
    4905  // insert to array and return iterator
    4906  iterator result(this);
    4907  assert(m_value.array != nullptr);
    4908  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4909  return result;
    4910  }
    4911  else
    4912  {
    4913  throw std::domain_error("cannot use insert() with " + type_name());
    4914  }
    4915  }
    4916 
    4921  iterator insert(const_iterator pos, basic_json&& val)
    4922  {
    4923  return insert(pos, val);
    4924  }
    4925 
    4950  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4951  {
    4952  // insert only works for arrays
    4953  if (is_array())
    4954  {
    4955  // check if iterator pos fits to this JSON value
    4956  if (pos.m_object != this)
    4957  {
    4958  throw std::domain_error("iterator does not fit current value");
    4959  }
    4960 
    4961  // insert to array and return iterator
    4962  iterator result(this);
    4963  assert(m_value.array != nullptr);
    4964  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4965  return result;
    4966  }
    4967  else
    4968  {
    4969  throw std::domain_error("cannot use insert() with " + type_name());
    4970  }
    4971  }
    4972 
    5004  {
    5005  // insert only works for arrays
    5006  if (not is_array())
    5007  {
    5008  throw std::domain_error("cannot use insert() with " + type_name());
    5009  }
    5010 
    5011  // check if iterator pos fits to this JSON value
    5012  if (pos.m_object != this)
    5013  {
    5014  throw std::domain_error("iterator does not fit current value");
    5015  }
    5016 
    5017  // check if range iterators belong to the same JSON object
    5018  if (first.m_object != last.m_object)
    5019  {
    5020  throw std::domain_error("iterators do not fit");
    5021  }
    5022 
    5023  if (first.m_object == this or last.m_object == this)
    5024  {
    5025  throw std::domain_error("passed iterators may not belong to container");
    5026  }
    5027 
    5028  // insert to array and return iterator
    5029  iterator result(this);
    5030  assert(m_value.array != nullptr);
    5031  result.m_it.array_iterator = m_value.array->insert(
    5032  pos.m_it.array_iterator,
    5033  first.m_it.array_iterator,
    5034  last.m_it.array_iterator);
    5035  return result;
    5036  }
    5037 
    5062  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    5063  {
    5064  // insert only works for arrays
    5065  if (not is_array())
    5066  {
    5067  throw std::domain_error("cannot use insert() with " + type_name());
    5068  }
    5069 
    5070  // check if iterator pos fits to this JSON value
    5071  if (pos.m_object != this)
    5072  {
    5073  throw std::domain_error("iterator does not fit current value");
    5074  }
    5075 
    5076  // insert to array and return iterator
    5077  iterator result(this);
    5078  assert(m_value.array != nullptr);
    5079  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    5080  return result;
    5081  }
    5082 
    5100  void swap(reference other) noexcept (
    5101  std::is_nothrow_move_constructible<value_t>::value and
    5102  std::is_nothrow_move_assignable<value_t>::value and
    5103  std::is_nothrow_move_constructible<json_value>::value and
    5104  std::is_nothrow_move_assignable<json_value>::value
    5105  )
    5106  {
    5107  std::swap(m_type, other.m_type);
    5108  std::swap(m_value, other.m_value);
    5109  }
    5110 
    5131  void swap(array_t& other)
    5132  {
    5133  // swap only works for arrays
    5134  if (is_array())
    5135  {
    5136  assert(m_value.array != nullptr);
    5137  std::swap(*(m_value.array), other);
    5138  }
    5139  else
    5140  {
    5141  throw std::domain_error("cannot use swap() with " + type_name());
    5142  }
    5143  }
    5144 
    5165  void swap(object_t& other)
    5166  {
    5167  // swap only works for objects
    5168  if (is_object())
    5169  {
    5170  assert(m_value.object != nullptr);
    5171  std::swap(*(m_value.object), other);
    5172  }
    5173  else
    5174  {
    5175  throw std::domain_error("cannot use swap() with " + type_name());
    5176  }
    5177  }
    5178 
    5199  void swap(string_t& other)
    5200  {
    5201  // swap only works for strings
    5202  if (is_string())
    5203  {
    5204  assert(m_value.string != nullptr);
    5205  std::swap(*(m_value.string), other);
    5206  }
    5207  else
    5208  {
    5209  throw std::domain_error("cannot use swap() with " + type_name());
    5210  }
    5211  }
    5212 
    5214 
    5215 
    5217  // lexicographical comparison operators //
    5219 
    5222 
    5223  private:
    5233  friend bool operator<(const value_t lhs, const value_t rhs) noexcept
    5234  {
    5235  static constexpr std::array<uint8_t, 8> order = {{
    5236  0, // null
    5237  3, // object
    5238  4, // array
    5239  5, // string
    5240  1, // boolean
    5241  2, // integer
    5242  2, // unsigned
    5243  2, // float
    5244  }
    5245  };
    5246 
    5247  // discarded values are not comparable
    5248  if (lhs == value_t::discarded or rhs == value_t::discarded)
    5249  {
    5250  return false;
    5251  }
    5252 
    5253  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    5254  }
    5255 
    5256  public:
    5280  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    5281  {
    5282  const auto lhs_type = lhs.type();
    5283  const auto rhs_type = rhs.type();
    5284 
    5285  if (lhs_type == rhs_type)
    5286  {
    5287  switch (lhs_type)
    5288  {
    5289  case value_t::array:
    5290  {
    5291  assert(lhs.m_value.array != nullptr);
    5292  assert(rhs.m_value.array != nullptr);
    5293  return *lhs.m_value.array == *rhs.m_value.array;
    5294  }
    5295  case value_t::object:
    5296  {
    5297  assert(lhs.m_value.object != nullptr);
    5298  assert(rhs.m_value.object != nullptr);
    5299  return *lhs.m_value.object == *rhs.m_value.object;
    5300  }
    5301  case value_t::null:
    5302  {
    5303  return true;
    5304  }
    5305  case value_t::string:
    5306  {
    5307  assert(lhs.m_value.string != nullptr);
    5308  assert(rhs.m_value.string != nullptr);
    5309  return *lhs.m_value.string == *rhs.m_value.string;
    5310  }
    5311  case value_t::boolean:
    5312  {
    5313  return lhs.m_value.boolean == rhs.m_value.boolean;
    5314  }
    5315  case value_t::number_integer:
    5316  {
    5317  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    5318  }
    5319  case value_t::number_unsigned:
    5320  {
    5321  return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
    5322  }
    5323  case value_t::number_float:
    5324  {
    5325  return lhs.m_value.number_float == rhs.m_value.number_float;
    5326  }
    5327  default:
    5328  {
    5329  return false;
    5330  }
    5331  }
    5332  }
    5333  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5334  {
    5335  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    5336  }
    5337  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5338  {
    5339  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    5340  }
    5341  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5342  {
    5343  return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
    5344  }
    5345  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5346  {
    5347  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5348  }
    5349  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5350  {
    5351  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
    5352  }
    5353  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5354  {
    5355  return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5356  }
    5357 
    5358  return false;
    5359  }
    5360 
    5379  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    5380  {
    5381  return v.is_null();
    5382  }
    5383 
    5388  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    5389  {
    5390  return v.is_null();
    5391  }
    5392 
    5409  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    5410  {
    5411  return not (lhs == rhs);
    5412  }
    5413 
    5432  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    5433  {
    5434  return not v.is_null();
    5435  }
    5436 
    5441  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    5442  {
    5443  return not v.is_null();
    5444  }
    5445 
    5470  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    5471  {
    5472  const auto lhs_type = lhs.type();
    5473  const auto rhs_type = rhs.type();
    5474 
    5475  if (lhs_type == rhs_type)
    5476  {
    5477  switch (lhs_type)
    5478  {
    5479  case value_t::array:
    5480  {
    5481  assert(lhs.m_value.array != nullptr);
    5482  assert(rhs.m_value.array != nullptr);
    5483  return *lhs.m_value.array < *rhs.m_value.array;
    5484  }
    5485  case value_t::object:
    5486  {
    5487  assert(lhs.m_value.object != nullptr);
    5488  assert(rhs.m_value.object != nullptr);
    5489  return *lhs.m_value.object < *rhs.m_value.object;
    5490  }
    5491  case value_t::null:
    5492  {
    5493  return false;
    5494  }
    5495  case value_t::string:
    5496  {
    5497  assert(lhs.m_value.string != nullptr);
    5498  assert(rhs.m_value.string != nullptr);
    5499  return *lhs.m_value.string < *rhs.m_value.string;
    5500  }
    5501  case value_t::boolean:
    5502  {
    5503  return lhs.m_value.boolean < rhs.m_value.boolean;
    5504  }
    5505  case value_t::number_integer:
    5506  {
    5507  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5508  }
    5509  case value_t::number_unsigned:
    5510  {
    5511  return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
    5512  }
    5513  case value_t::number_float:
    5514  {
    5515  return lhs.m_value.number_float < rhs.m_value.number_float;
    5516  }
    5517  default:
    5518  {
    5519  return false;
    5520  }
    5521  }
    5522  }
    5523  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5524  {
    5525  return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
    5526  }
    5527  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5528  {
    5529  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
    5530  }
    5531  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
    5532  {
    5533  return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
    5534  }
    5535  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
    5536  {
    5537  return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
    5538  }
    5539  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
    5540  {
    5541  return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
    5542  }
    5543  else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
    5544  {
    5545  return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
    5546  }
    5547 
    5548  // We only reach this line if we cannot compare values. In that case,
    5549  // we compare types. Note we have to call the operator explicitly,
    5550  // because MSVC has problems otherwise.
    5551  return operator<(lhs_type, rhs_type);
    5552  }
    5553 
    5571  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5572  {
    5573  return not (rhs < lhs);
    5574  }
    5575 
    5593  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5594  {
    5595  return not (lhs <= rhs);
    5596  }
    5597 
    5615  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5616  {
    5617  return not (lhs < rhs);
    5618  }
    5619 
    5621 
    5622 
    5624  // serialization //
    5626 
    5629 
    5652  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5653  {
    5654  // read width member and use it as indentation parameter if nonzero
    5655  const bool pretty_print = (o.width() > 0);
    5656  const auto indentation = (pretty_print ? o.width() : 0);
    5657 
    5658  // reset width to 0 for subsequent calls to this stream
    5659  o.width(0);
    5660  // fix locale problems
    5661  auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator));
    5662 
    5663  // do the actual serialization
    5664  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5665 
    5666  // reset locale
    5667  o.imbue(old_locale);
    5668  return o;
    5669  }
    5670 
    5675  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5676  {
    5677  return o << j;
    5678  }
    5679 
    5681 
    5682 
    5684  // deserialization //
    5686 
    5689 
    5714  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5715  {
    5716  return parser(s, cb).parse();
    5717  }
    5718 
    5743  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5744  {
    5745  return parser(i, cb).parse();
    5746  }
    5747 
    5751  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5752  {
    5753  return parser(i, cb).parse();
    5754  }
    5755 
    5779  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5780  {
    5781  j = parser(i).parse();
    5782  return i;
    5783  }
    5784 
    5789  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5790  {
    5791  j = parser(i).parse();
    5792  return i;
    5793  }
    5794 
    5796 
    5797 
    5798  private:
    5800  // convenience functions //
    5802 
    5804  string_t type_name() const noexcept
    5805  {
    5806  switch (m_type)
    5807  {
    5808  case value_t::null:
    5809  return "null";
    5810  case value_t::object:
    5811  return "object";
    5812  case value_t::array:
    5813  return "array";
    5814  case value_t::string:
    5815  return "string";
    5816  case value_t::boolean:
    5817  return "boolean";
    5818  case value_t::discarded:
    5819  return "discarded";
    5820  default:
    5821  return "number";
    5822  }
    5823  }
    5824 
    5833  static std::size_t extra_space(const string_t& s) noexcept
    5834  {
    5835  std::size_t result = 0;
    5836 
    5837  for (const auto& c : s)
    5838  {
    5839  switch (c)
    5840  {
    5841  case '"':
    5842  case '\\':
    5843  case '\b':
    5844  case '\f':
    5845  case '\n':
    5846  case '\r':
    5847  case '\t':
    5848  {
    5849  // from c (1 byte) to \x (2 bytes)
    5850  result += 1;
    5851  break;
    5852  }
    5853 
    5854  default:
    5855  {
    5856  if (c >= 0x00 and c <= 0x1f)
    5857  {
    5858  // from c (1 byte) to \uxxxx (6 bytes)
    5859  result += 5;
    5860  }
    5861  break;
    5862  }
    5863  }
    5864  }
    5865 
    5866  return result;
    5867  }
    5868 
    5882  static string_t escape_string(const string_t& s)
    5883  {
    5884  const auto space = extra_space(s);
    5885  if (space == 0)
    5886  {
    5887  return s;
    5888  }
    5889 
    5890  // create a result string of necessary size
    5891  string_t result(s.size() + space, '\\');
    5892  std::size_t pos = 0;
    5893 
    5894  for (const auto& c : s)
    5895  {
    5896  switch (c)
    5897  {
    5898  // quotation mark (0x22)
    5899  case '"':
    5900  {
    5901  result[pos + 1] = '"';
    5902  pos += 2;
    5903  break;
    5904  }
    5905 
    5906  // reverse solidus (0x5c)
    5907  case '\\':
    5908  {
    5909  // nothing to change
    5910  pos += 2;
    5911  break;
    5912  }
    5913 
    5914  // backspace (0x08)
    5915  case '\b':
    5916  {
    5917  result[pos + 1] = 'b';
    5918  pos += 2;
    5919  break;
    5920  }
    5921 
    5922  // formfeed (0x0c)
    5923  case '\f':
    5924  {
    5925  result[pos + 1] = 'f';
    5926  pos += 2;
    5927  break;
    5928  }
    5929 
    5930  // newline (0x0a)
    5931  case '\n':
    5932  {
    5933  result[pos + 1] = 'n';
    5934  pos += 2;
    5935  break;
    5936  }
    5937 
    5938  // carriage return (0x0d)
    5939  case '\r':
    5940  {
    5941  result[pos + 1] = 'r';
    5942  pos += 2;
    5943  break;
    5944  }
    5945 
    5946  // horizontal tab (0x09)
    5947  case '\t':
    5948  {
    5949  result[pos + 1] = 't';
    5950  pos += 2;
    5951  break;
    5952  }
    5953 
    5954  default:
    5955  {
    5956  if (c >= 0x00 and c <= 0x1f)
    5957  {
    5958  // convert a number 0..15 to its hex representation
    5959  // (0..f)
    5960  const auto hexify = [](const int v) -> char
    5961  {
    5962  return (v < 10)
    5963  ? ('0' + static_cast<char>(v))
    5964  : ('a' + static_cast<char>((v - 10) & 0x1f));
    5965  };
    5966 
    5967  // print character c as \uxxxx
    5968  for (const char m :
    5969  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5970  })
    5971  {
    5972  result[++pos] = m;
    5973  }
    5974 
    5975  ++pos;
    5976  }
    5977  else
    5978  {
    5979  // all other characters are added as-is
    5980  result[pos++] = c;
    5981  }
    5982  break;
    5983  }
    5984  }
    5985  }
    5986 
    5987  return result;
    5988  }
    5989 
    6007  void dump(std::ostream& o,
    6008  const bool pretty_print,
    6009  const unsigned int indent_step,
    6010  const unsigned int current_indent = 0) const
    6011  {
    6012  // variable to hold indentation for recursive calls
    6013  unsigned int new_indent = current_indent;
    6014 
    6015  switch (m_type)
    6016  {
    6017  case value_t::object:
    6018  {
    6019  assert(m_value.object != nullptr);
    6020 
    6021  if (m_value.object->empty())
    6022  {
    6023  o << "{}";
    6024  return;
    6025  }
    6026 
    6027  o << "{";
    6028 
    6029  // increase indentation
    6030  if (pretty_print)
    6031  {
    6032  new_indent += indent_step;
    6033  o << "\n";
    6034  }
    6035 
    6036  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    6037  {
    6038  if (i != m_value.object->cbegin())
    6039  {
    6040  o << (pretty_print ? ",\n" : ",");
    6041  }
    6042  o << string_t(new_indent, ' ') << "\""
    6043  << escape_string(i->first) << "\":"
    6044  << (pretty_print ? " " : "");
    6045  i->second.dump(o, pretty_print, indent_step, new_indent);
    6046  }
    6047 
    6048  // decrease indentation
    6049  if (pretty_print)
    6050  {
    6051  new_indent -= indent_step;
    6052  o << "\n";
    6053  }
    6054 
    6055  o << string_t(new_indent, ' ') + "}";
    6056  return;
    6057  }
    6058 
    6059  case value_t::array:
    6060  {
    6061  assert(m_value.array != nullptr);
    6062 
    6063  if (m_value.array->empty())
    6064  {
    6065  o << "[]";
    6066  return;
    6067  }
    6068 
    6069  o << "[";
    6070 
    6071  // increase indentation
    6072  if (pretty_print)
    6073  {
    6074  new_indent += indent_step;
    6075  o << "\n";
    6076  }
    6077 
    6078  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    6079  {
    6080  if (i != m_value.array->cbegin())
    6081  {
    6082  o << (pretty_print ? ",\n" : ",");
    6083  }
    6084  o << string_t(new_indent, ' ');
    6085  i->dump(o, pretty_print, indent_step, new_indent);
    6086  }
    6087 
    6088  // decrease indentation
    6089  if (pretty_print)
    6090  {
    6091  new_indent -= indent_step;
    6092  o << "\n";
    6093  }
    6094 
    6095  o << string_t(new_indent, ' ') << "]";
    6096  return;
    6097  }
    6098 
    6099  case value_t::string:
    6100  {
    6101  assert(m_value.string != nullptr);
    6102  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    6103  return;
    6104  }
    6105 
    6106  case value_t::boolean:
    6107  {
    6108  o << (m_value.boolean ? "true" : "false");
    6109  return;
    6110  }
    6111 
    6112  case value_t::number_integer:
    6113  {
    6114  o << m_value.number_integer;
    6115  return;
    6116  }
    6117 
    6118  case value_t::number_unsigned:
    6119  {
    6120  o << m_value.number_unsigned;
    6121  return;
    6122  }
    6123 
    6124  case value_t::number_float:
    6125  {
    6126  if (m_value.number_float == 0)
    6127  {
    6128  // special case for zero to get "0.0"/"-0.0"
    6129  o << (std::signbit(m_value.number_float) ? "-0.0" : "0.0");
    6130  }
    6131  else
    6132  {
    6133  // Otherwise 6, 15 or 16 digits of precision allows
    6134  // round-trip IEEE 754 string->float->string,
    6135  // string->double->string or string->long
    6136  // double->string; to be safe, we read this value from
    6137  // std::numeric_limits<number_float_t>::digits10
    6138  o << std::setprecision(std::numeric_limits<double>::digits10)
    6139  << m_value.number_float;
    6140  }
    6141  return;
    6142  }
    6143 
    6144  case value_t::discarded:
    6145  {
    6146  o << "<discarded>";
    6147  return;
    6148  }
    6149 
    6150  case value_t::null:
    6151  {
    6152  o << "null";
    6153  return;
    6154  }
    6155  }
    6156  }
    6157 
    6158  private:
    6160  // member variables //
    6162 
    6164  value_t m_type = value_t::null;
    6165 
    6167  json_value m_value = {};
    6168 
    6169 
    6170  private:
    6172  // iterators //
    6174 
    6184  class primitive_iterator_t
    6185  {
    6186  public:
    6188  void set_begin() noexcept
    6189  {
    6190  m_it = begin_value;
    6191  }
    6192 
    6194  void set_end() noexcept
    6195  {
    6196  m_it = end_value;
    6197  }
    6198 
    6200  constexpr bool is_begin() const noexcept
    6201  {
    6202  return (m_it == begin_value);
    6203  }
    6204 
    6206  constexpr bool is_end() const noexcept
    6207  {
    6208  return (m_it == end_value);
    6209  }
    6210 
    6212  operator difference_type& () noexcept
    6213  {
    6214  return m_it;
    6215  }
    6216 
    6218  constexpr operator difference_type () const noexcept
    6219  {
    6220  return m_it;
    6221  }
    6222 
    6223  private:
    6224  static constexpr difference_type begin_value = 0;
    6225  static constexpr difference_type end_value = begin_value + 1;
    6226 
    6228  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    6229  };
    6230 
    6238  struct internal_iterator
    6239  {
    6241  typename object_t::iterator object_iterator;
    6243  typename array_t::iterator array_iterator;
    6245  primitive_iterator_t primitive_iterator;
    6246 
    6248  internal_iterator() noexcept
    6249  : object_iterator(), array_iterator(), primitive_iterator()
    6250  {}
    6251  };
    6252 
    6254  template<typename IteratorType>
    6255  class iteration_proxy
    6256  {
    6257  private:
    6259  class iteration_proxy_internal
    6260  {
    6261  private:
    6263  IteratorType anchor;
    6265  size_t array_index = 0;
    6266 
    6267  public:
    6268  explicit iteration_proxy_internal(IteratorType it) noexcept
    6269  : anchor(it)
    6270  {}
    6271 
    6273  iteration_proxy_internal& operator*()
    6274  {
    6275  return *this;
    6276  }
    6277 
    6279  iteration_proxy_internal& operator++()
    6280  {
    6281  ++anchor;
    6282  ++array_index;
    6283 
    6284  return *this;
    6285  }
    6286 
    6288  bool operator!= (const iteration_proxy_internal& o) const
    6289  {
    6290  return anchor != o.anchor;
    6291  }
    6292 
    6294  typename basic_json::string_t key() const
    6295  {
    6296  assert(anchor.m_object != nullptr);
    6297 
    6298  switch (anchor.m_object->type())
    6299  {
    6300  // use integer array index as key
    6301  case value_t::array:
    6302  {
    6303  return std::to_string(array_index);
    6304  }
    6305 
    6306  // use key from the object
    6307  case value_t::object:
    6308  {
    6309  return anchor.key();
    6310  }
    6311 
    6312  // use an empty key for all primitive types
    6313  default:
    6314  {
    6315  return "";
    6316  }
    6317  }
    6318  }
    6319 
    6321  typename IteratorType::reference value() const
    6322  {
    6323  return anchor.value();
    6324  }
    6325  };
    6326 
    6328  typename IteratorType::reference container;
    6329 
    6330  public:
    6332  explicit iteration_proxy(typename IteratorType::reference cont)
    6333  : container(cont)
    6334  {}
    6335 
    6337  iteration_proxy_internal begin() noexcept
    6338  {
    6339  return iteration_proxy_internal(container.begin());
    6340  }
    6341 
    6343  iteration_proxy_internal end() noexcept
    6344  {
    6345  return iteration_proxy_internal(container.end());
    6346  }
    6347  };
    6348 
    6349  public:
    6363  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    6364  {
    6366  friend class basic_json;
    6367 
    6368  public:
    6378  using iterator_category = std::bidirectional_iterator_tag;
    6379 
    6381  const_iterator() = default;
    6382 
    6384  explicit const_iterator(pointer object) noexcept
    6385  : m_object(object)
    6386  {
    6387  assert(m_object != nullptr);
    6388 
    6389  switch (m_object->m_type)
    6390  {
    6392  {
    6393  m_it.object_iterator = typename object_t::iterator();
    6394  break;
    6395  }
    6396 
    6398  {
    6399  m_it.array_iterator = typename array_t::iterator();
    6400  break;
    6401  }
    6402 
    6403  default:
    6404  {
    6405  m_it.primitive_iterator = primitive_iterator_t();
    6406  break;
    6407  }
    6408  }
    6409  }
    6410 
    6412  explicit const_iterator(const iterator& other) noexcept
    6413  : m_object(other.m_object)
    6414  {
    6415  assert(m_object != nullptr);
    6416 
    6417  switch (m_object->m_type)
    6418  {
    6420  {
    6421  m_it.object_iterator = other.m_it.object_iterator;
    6422  break;
    6423  }
    6424 
    6426  {
    6427  m_it.array_iterator = other.m_it.array_iterator;
    6428  break;
    6429  }
    6430 
    6431  default:
    6432  {
    6433  m_it.primitive_iterator = other.m_it.primitive_iterator;
    6434  break;
    6435  }
    6436  }
    6437  }
    6438 
    6440  const_iterator(const const_iterator& other) noexcept
    6441  : m_object(other.m_object), m_it(other.m_it)
    6442  {}
    6443 
    6446  std::is_nothrow_move_constructible<pointer>::value and
    6447  std::is_nothrow_move_assignable<pointer>::value and
    6448  std::is_nothrow_move_constructible<internal_iterator>::value and
    6449  std::is_nothrow_move_assignable<internal_iterator>::value
    6450  )
    6451  {
    6452  std::swap(m_object, other.m_object);
    6453  std::swap(m_it, other.m_it);
    6454  return *this;
    6455  }
    6456 
    6457  private:
    6459  void set_begin() noexcept
    6460  {
    6461  assert(m_object != nullptr);
    6462 
    6463  switch (m_object->m_type)
    6464  {
    6466  {
    6467  assert(m_object->m_value.object != nullptr);
    6468  m_it.object_iterator = m_object->m_value.object->begin();
    6469  break;
    6470  }
    6471 
    6473  {
    6474  assert(m_object->m_value.array != nullptr);
    6475  m_it.array_iterator = m_object->m_value.array->begin();
    6476  break;
    6477  }
    6478 
    6480  {
    6481  // set to end so begin()==end() is true: null is empty
    6482  m_it.primitive_iterator.set_end();
    6483  break;
    6484  }
    6485 
    6486  default:
    6487  {
    6488  m_it.primitive_iterator.set_begin();
    6489  break;
    6490  }
    6491  }
    6492  }
    6493 
    6495  void set_end() noexcept
    6496  {
    6497  assert(m_object != nullptr);
    6498 
    6499  switch (m_object->m_type)
    6500  {
    6502  {
    6503  assert(m_object->m_value.object != nullptr);
    6504  m_it.object_iterator = m_object->m_value.object->end();
    6505  break;
    6506  }
    6507 
    6509  {
    6510  assert(m_object->m_value.array != nullptr);
    6511  m_it.array_iterator = m_object->m_value.array->end();
    6512  break;
    6513  }
    6514 
    6515  default:
    6516  {
    6517  m_it.primitive_iterator.set_end();
    6518  break;
    6519  }
    6520  }
    6521  }
    6522 
    6523  public:
    6526  {
    6527  assert(m_object != nullptr);
    6528 
    6529  switch (m_object->m_type)
    6530  {
    6532  {
    6533  assert(m_object->m_value.object);
    6534  assert(m_it.object_iterator != m_object->m_value.object->end());
    6535  return m_it.object_iterator->second;
    6536  }
    6537 
    6539  {
    6540  assert(m_object->m_value.array);
    6541  assert(m_it.array_iterator != m_object->m_value.array->end());
    6542  return *m_it.array_iterator;
    6543  }
    6544 
    6546  {
    6547  throw std::out_of_range("cannot get value");
    6548  }
    6549 
    6550  default:
    6551  {
    6552  if (m_it.primitive_iterator.is_begin())
    6553  {
    6554  return *m_object;
    6555  }
    6556  else
    6557  {
    6558  throw std::out_of_range("cannot get value");
    6559  }
    6560  }
    6561  }
    6562  }
    6563 
    6566  {
    6567  assert(m_object != nullptr);
    6568 
    6569  switch (m_object->m_type)
    6570  {
    6572  {
    6573  assert(m_object->m_value.object);
    6574  assert(m_it.object_iterator != m_object->m_value.object->end());
    6575  return &(m_it.object_iterator->second);
    6576  }
    6577 
    6579  {
    6580  assert(m_object->m_value.array);
    6581  assert(m_it.array_iterator != m_object->m_value.array->end());
    6582  return &*m_it.array_iterator;
    6583  }
    6584 
    6585  default:
    6586  {
    6587  if (m_it.primitive_iterator.is_begin())
    6588  {
    6589  return m_object;
    6590  }
    6591  else
    6592  {
    6593  throw std::out_of_range("cannot get value");
    6594  }
    6595  }
    6596  }
    6597  }
    6598 
    6601  {
    6602  auto result = *this;
    6603  ++(*this);
    6604  return result;
    6605  }
    6606 
    6609  {
    6610  assert(m_object != nullptr);
    6611 
    6612  switch (m_object->m_type)
    6613  {
    6615  {
    6616  ++m_it.object_iterator;
    6617  break;
    6618  }
    6619 
    6621  {
    6622  ++m_it.array_iterator;
    6623  break;
    6624  }
    6625 
    6626  default:
    6627  {
    6628  ++m_it.primitive_iterator;
    6629  break;
    6630  }
    6631  }
    6632 
    6633  return *this;
    6634  }
    6635 
    6638  {
    6639  auto result = *this;
    6640  --(*this);
    6641  return result;
    6642  }
    6643 
    6646  {
    6647  assert(m_object != nullptr);
    6648 
    6649  switch (m_object->m_type)
    6650  {
    6652  {
    6653  --m_it.object_iterator;
    6654  break;
    6655  }
    6656 
    6658  {
    6659  --m_it.array_iterator;
    6660  break;
    6661  }
    6662 
    6663  default:
    6664  {
    6665  --m_it.primitive_iterator;
    6666  break;
    6667  }
    6668  }
    6669 
    6670  return *this;
    6671  }
    6672 
    6674  bool operator==(const const_iterator& other) const
    6675  {
    6676  // if objects are not the same, the comparison is undefined
    6677  if (m_object != other.m_object)
    6678  {
    6679  throw std::domain_error("cannot compare iterators of different containers");
    6680  }
    6681 
    6682  assert(m_object != nullptr);
    6683 
    6684  switch (m_object->m_type)
    6685  {
    6687  {
    6688  return (m_it.object_iterator == other.m_it.object_iterator);
    6689  }
    6690 
    6692  {
    6693  return (m_it.array_iterator == other.m_it.array_iterator);
    6694  }
    6695 
    6696  default:
    6697  {
    6698  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6699  }
    6700  }
    6701  }
    6702 
    6704  bool operator!=(const const_iterator& other) const
    6705  {
    6706  return not operator==(other);
    6707  }
    6708 
    6710  bool operator<(const const_iterator& other) const
    6711  {
    6712  // if objects are not the same, the comparison is undefined
    6713  if (m_object != other.m_object)
    6714  {
    6715  throw std::domain_error("cannot compare iterators of different containers");
    6716  }
    6717 
    6718  assert(m_object != nullptr);
    6719 
    6720  switch (m_object->m_type)
    6721  {
    6723  {
    6724  throw std::domain_error("cannot compare order of object iterators");
    6725  }
    6726 
    6728  {
    6729  return (m_it.array_iterator < other.m_it.array_iterator);
    6730  }
    6731 
    6732  default:
    6733  {
    6734  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6735  }
    6736  }
    6737  }
    6738 
    6740  bool operator<=(const const_iterator& other) const
    6741  {
    6742  return not other.operator < (*this);
    6743  }
    6744 
    6746  bool operator>(const const_iterator& other) const
    6747  {
    6748  return not operator<=(other);
    6749  }
    6750 
    6752  bool operator>=(const const_iterator& other) const
    6753  {
    6754  return not operator<(other);
    6755  }
    6756 
    6759  {
    6760  assert(m_object != nullptr);
    6761 
    6762  switch (m_object->m_type)
    6763  {
    6765  {
    6766  throw std::domain_error("cannot use offsets with object iterators");
    6767  }
    6768 
    6770  {
    6771  m_it.array_iterator += i;
    6772  break;
    6773  }
    6774 
    6775  default:
    6776  {
    6777  m_it.primitive_iterator += i;
    6778  break;
    6779  }
    6780  }
    6781 
    6782  return *this;
    6783  }
    6784 
    6787  {
    6788  return operator+=(-i);
    6789  }
    6790 
    6793  {
    6794  auto result = *this;
    6795  result += i;
    6796  return result;
    6797  }
    6798 
    6801  {
    6802  auto result = *this;
    6803  result -= i;
    6804  return result;
    6805  }
    6806 
    6809  {
    6810  assert(m_object != nullptr);
    6811 
    6812  switch (m_object->m_type)
    6813  {
    6815  {
    6816  throw std::domain_error("cannot use offsets with object iterators");
    6817  }
    6818 
    6820  {
    6821  return m_it.array_iterator - other.m_it.array_iterator;
    6822  }
    6823 
    6824  default:
    6825  {
    6826  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6827  }
    6828  }
    6829  }
    6830 
    6833  {
    6834  assert(m_object != nullptr);
    6835 
    6836  switch (m_object->m_type)
    6837  {
    6839  {
    6840  throw std::domain_error("cannot use operator[] for object iterators");
    6841  }
    6842 
    6844  {
    6845  return *(m_it.array_iterator + n);
    6846  }
    6847 
    6849  {
    6850  throw std::out_of_range("cannot get value");
    6851  }
    6852 
    6853  default:
    6854  {
    6855  if (m_it.primitive_iterator == -n)
    6856  {
    6857  return *m_object;
    6858  }
    6859  else
    6860  {
    6861  throw std::out_of_range("cannot get value");
    6862  }
    6863  }
    6864  }
    6865  }
    6866 
    6868  typename object_t::key_type key() const
    6869  {
    6870  assert(m_object != nullptr);
    6871 
    6872  if (m_object->is_object())
    6873  {
    6874  return m_it.object_iterator->first;
    6875  }
    6876  else
    6877  {
    6878  throw std::domain_error("cannot use key() for non-object iterators");
    6879  }
    6880  }
    6881 
    6884  {
    6885  return operator*();
    6886  }
    6887 
    6888  private:
    6890  pointer m_object = nullptr;
    6892  internal_iterator m_it = internal_iterator();
    6893  };
    6894 
    6907  class iterator : public const_iterator
    6908  {
    6909  public:
    6911  using pointer = typename basic_json::pointer;
    6913 
    6915  iterator() = default;
    6916 
    6918  explicit iterator(pointer object) noexcept
    6919  : base_iterator(object)
    6920  {}
    6921 
    6923  iterator(const iterator& other) noexcept
    6924  : base_iterator(other)
    6925  {}
    6926 
    6928  iterator& operator=(iterator other) noexcept(
    6929  std::is_nothrow_move_constructible<pointer>::value and
    6930  std::is_nothrow_move_assignable<pointer>::value and
    6931  std::is_nothrow_move_constructible<internal_iterator>::value and
    6932  std::is_nothrow_move_assignable<internal_iterator>::value
    6933  )
    6934  {
    6935  base_iterator::operator=(other);
    6936  return *this;
    6937  }
    6938 
    6941  {
    6942  return const_cast<reference>(base_iterator::operator*());
    6943  }
    6944 
    6947  {
    6948  return const_cast<pointer>(base_iterator::operator->());
    6949  }
    6950 
    6953  {
    6954  iterator result = *this;
    6955  base_iterator::operator++();
    6956  return result;
    6957  }
    6958 
    6961  {
    6962  base_iterator::operator++();
    6963  return *this;
    6964  }
    6965 
    6968  {
    6969  iterator result = *this;
    6970  base_iterator::operator--();
    6971  return result;
    6972  }
    6973 
    6976  {
    6977  base_iterator::operator--();
    6978  return *this;
    6979  }
    6980 
    6983  {
    6984  base_iterator::operator+=(i);
    6985  return *this;
    6986  }
    6987 
    6990  {
    6991  base_iterator::operator-=(i);
    6992  return *this;
    6993  }
    6994 
    6997  {
    6998  auto result = *this;
    6999  result += i;
    7000  return result;
    7001  }
    7002 
    7005  {
    7006  auto result = *this;
    7007  result -= i;
    7008  return result;
    7009  }
    7010 
    7012  difference_type operator-(const iterator& other) const
    7013  {
    7014  return base_iterator::operator-(other);
    7015  }
    7016 
    7019  {
    7020  return const_cast<reference>(base_iterator::operator[](n));
    7021  }
    7022 
    7025  {
    7026  return const_cast<reference>(base_iterator::value());
    7027  }
    7028  };
    7029 
    7047  template<typename Base>
    7048  class json_reverse_iterator : public std::reverse_iterator<Base>
    7049  {
    7050  public:
    7052  using base_iterator = std::reverse_iterator<Base>;
    7054  using reference = typename Base::reference;
    7055 
    7057  json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept
    7058  : base_iterator(it)
    7059  {}
    7060 
    7063  : base_iterator(it)
    7064  {}
    7065 
    7068  {
    7069  return base_iterator::operator++(1);
    7070  }
    7071 
    7074  {
    7075  base_iterator::operator++();
    7076  return *this;
    7077  }
    7078 
    7081  {
    7082  return base_iterator::operator--(1);
    7083  }
    7084 
    7087  {
    7088  base_iterator::operator--();
    7089  return *this;
    7090  }
    7091 
    7094  {
    7095  base_iterator::operator+=(i);
    7096  return *this;
    7097  }
    7098 
    7101  {
    7102  auto result = *this;
    7103  result += i;
    7104  return result;
    7105  }
    7106 
    7109  {
    7110  auto result = *this;
    7111  result -= i;
    7112  return result;
    7113  }
    7114 
    7117  {
    7118  return this->base() - other.base();
    7119  }
    7120 
    7123  {
    7124  return *(this->operator+(n));
    7125  }
    7126 
    7128  typename object_t::key_type key() const
    7129  {
    7130  auto it = --this->base();
    7131  return it.key();
    7132  }
    7133 
    7136  {
    7137  auto it = --this->base();
    7138  return it.operator * ();
    7139  }
    7140  };
    7141 
    7142 
    7143  private:
    7145  // lexer and parser //
    7147 
    7155  class lexer
    7156  {
    7157  public:
    7159  enum class token_type
    7160  {
    7161  uninitialized,
    7162  literal_true,
    7163  literal_false,
    7164  literal_null,
    7165  value_string,
    7166  value_number,
    7167  begin_array,
    7168  begin_object,
    7169  end_array,
    7170  end_object,
    7171  name_separator,
    7172  value_separator,
    7173  parse_error,
    7174  end_of_input
    7175  };
    7176 
    7178  using lexer_char_t = unsigned char;
    7179 
    7181  explicit lexer(const string_t& s) noexcept
    7182  : m_stream(nullptr), m_buffer(s)
    7183  {
    7184  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    7185  assert(m_content != nullptr);
    7186  m_start = m_cursor = m_content;
    7187  m_limit = m_content + s.size();
    7188  }
    7189 
    7191  explicit lexer(std::istream* s) noexcept
    7192  : m_stream(s), m_buffer()
    7193  {
    7194  assert(m_stream != nullptr);
    7195  getline(*m_stream, m_buffer);
    7196  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7197  assert(m_content != nullptr);
    7198  m_start = m_cursor = m_content;
    7199  m_limit = m_content + m_buffer.size();
    7200  }
    7201 
    7203  lexer() = default;
    7204 
    7205  // switch off unwanted functions
    7206  lexer(const lexer&) = delete;
    7207  lexer operator=(const lexer&) = delete;
    7208 
    7224  static string_t to_unicode(const std::size_t codepoint1,
    7225  const std::size_t codepoint2 = 0)
    7226  {
    7227  // calculate the codepoint from the given code points
    7228  std::size_t codepoint = codepoint1;
    7229 
    7230  // check if codepoint1 is a high surrogate
    7231  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    7232  {
    7233  // check if codepoint2 is a low surrogate
    7234  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    7235  {
    7236  codepoint =
    7237  // high surrogate occupies the most significant 22 bits
    7238  (codepoint1 << 10)
    7239  // low surrogate occupies the least significant 15 bits
    7240  + codepoint2
    7241  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    7242  // in the result so we have to subtract with:
    7243  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    7244  - 0x35FDC00;
    7245  }
    7246  else
    7247  {
    7248  throw std::invalid_argument("missing or wrong low surrogate");
    7249  }
    7250  }
    7251 
    7252  string_t result;
    7253 
    7254  if (codepoint < 0x80)
    7255  {
    7256  // 1-byte characters: 0xxxxxxx (ASCII)
    7257  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    7258  }
    7259  else if (codepoint <= 0x7ff)
    7260  {
    7261  // 2-byte characters: 110xxxxx 10xxxxxx
    7262  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    7263  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7264  }
    7265  else if (codepoint <= 0xffff)
    7266  {
    7267  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    7268  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    7269  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7270  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7271  }
    7272  else if (codepoint <= 0x10ffff)
    7273  {
    7274  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    7275  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    7276  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    7277  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    7278  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    7279  }
    7280  else
    7281  {
    7282  throw std::out_of_range("code points above 0x10FFFF are invalid");
    7283  }
    7284 
    7285  return result;
    7286  }
    7287 
    7289  static std::string token_type_name(token_type t)
    7290  {
    7291  switch (t)
    7292  {
    7293  case token_type::uninitialized:
    7294  return "<uninitialized>";
    7295  case token_type::literal_true:
    7296  return "true literal";
    7297  case token_type::literal_false:
    7298  return "false literal";
    7299  case token_type::literal_null:
    7300  return "null literal";
    7301  case token_type::value_string:
    7302  return "string literal";
    7303  case token_type::value_number:
    7304  return "number literal";
    7305  case token_type::begin_array:
    7306  return "'['";
    7307  case token_type::begin_object:
    7308  return "'{'";
    7309  case token_type::end_array:
    7310  return "']'";
    7311  case token_type::end_object:
    7312  return "'}'";
    7313  case token_type::name_separator:
    7314  return "':'";
    7315  case token_type::value_separator:
    7316  return "','";
    7317  case token_type::parse_error:
    7318  return "<parse error>";
    7319  case token_type::end_of_input:
    7320  return "end of input";
    7321  default:
    7322  {
    7323  // catch non-enum values
    7324  return "unknown token"; // LCOV_EXCL_LINE
    7325  }
    7326  }
    7327  }
    7328 
    7339  token_type scan() noexcept
    7340  {
    7341  // pointer for backtracking information
    7342  m_marker = nullptr;
    7343 
    7344  // remember the begin of the token
    7345  m_start = m_cursor;
    7346  assert(m_start != nullptr);
    7347 
    7348 
    7349  {
    7350  lexer_char_t yych;
    7351  unsigned int yyaccept = 0;
    7352  static const unsigned char yybm[] =
    7353  {
    7354  0, 0, 0, 0, 0, 0, 0, 0,
    7355  0, 32, 32, 0, 0, 32, 0, 0,
    7356  128, 128, 128, 128, 128, 128, 128, 128,
    7357  128, 128, 128, 128, 128, 128, 128, 128,
    7358  160, 128, 0, 128, 128, 128, 128, 128,
    7359  128, 128, 128, 128, 128, 128, 128, 128,
    7360  192, 192, 192, 192, 192, 192, 192, 192,
    7361  192, 192, 128, 128, 128, 128, 128, 128,
    7362  128, 128, 128, 128, 128, 128, 128, 128,
    7363  128, 128, 128, 128, 128, 128, 128, 128,
    7364  128, 128, 128, 128, 128, 128, 128, 128,
    7365  128, 128, 128, 128, 0, 128, 128, 128,
    7366  128, 128, 128, 128, 128, 128, 128, 128,
    7367  128, 128, 128, 128, 128, 128, 128, 128,
    7368  128, 128, 128, 128, 128, 128, 128, 128,
    7369  128, 128, 128, 128, 128, 128, 128, 128,
    7370  128, 128, 128, 128, 128, 128, 128, 128,
    7371  128, 128, 128, 128, 128, 128, 128, 128,
    7372  128, 128, 128, 128, 128, 128, 128, 128,
    7373  128, 128, 128, 128, 128, 128, 128, 128,
    7374  128, 128, 128, 128, 128, 128, 128, 128,
    7375  128, 128, 128, 128, 128, 128, 128, 128,
    7376  128, 128, 128, 128, 128, 128, 128, 128,
    7377  128, 128, 128, 128, 128, 128, 128, 128,
    7378  128, 128, 128, 128, 128, 128, 128, 128,
    7379  128, 128, 128, 128, 128, 128, 128, 128,
    7380  128, 128, 128, 128, 128, 128, 128, 128,
    7381  128, 128, 128, 128, 128, 128, 128, 128,
    7382  128, 128, 128, 128, 128, 128, 128, 128,
    7383  128, 128, 128, 128, 128, 128, 128, 128,
    7384  128, 128, 128, 128, 128, 128, 128, 128,
    7385  128, 128, 128, 128, 128, 128, 128, 128,
    7386  };
    7387  if ((m_limit - m_cursor) < 5)
    7388  {
    7389  yyfill(); // LCOV_EXCL_LINE;
    7390  }
    7391  yych = *m_cursor;
    7392  if (yybm[0 + yych] & 32)
    7393  {
    7394  goto basic_json_parser_6;
    7395  }
    7396  if (yych <= '\\')
    7397  {
    7398  if (yych <= '-')
    7399  {
    7400  if (yych <= '"')
    7401  {
    7402  if (yych <= 0x00)
    7403  {
    7404  goto basic_json_parser_2;
    7405  }
    7406  if (yych <= '!')
    7407  {
    7408  goto basic_json_parser_4;
    7409  }
    7410  goto basic_json_parser_9;
    7411  }
    7412  else
    7413  {
    7414  if (yych <= '+')
    7415  {
    7416  goto basic_json_parser_4;
    7417  }
    7418  if (yych <= ',')
    7419  {
    7420  goto basic_json_parser_10;
    7421  }
    7422  goto basic_json_parser_12;
    7423  }
    7424  }
    7425  else
    7426  {
    7427  if (yych <= '9')
    7428  {
    7429  if (yych <= '/')
    7430  {
    7431  goto basic_json_parser_4;
    7432  }
    7433  if (yych <= '0')
    7434  {
    7435  goto basic_json_parser_13;
    7436  }
    7437  goto basic_json_parser_15;
    7438  }
    7439  else
    7440  {
    7441  if (yych <= ':')
    7442  {
    7443  goto basic_json_parser_17;
    7444  }
    7445  if (yych == '[')
    7446  {
    7447  goto basic_json_parser_19;
    7448  }
    7449  goto basic_json_parser_4;
    7450  }
    7451  }
    7452  }
    7453  else
    7454  {
    7455  if (yych <= 't')
    7456  {
    7457  if (yych <= 'f')
    7458  {
    7459  if (yych <= ']')
    7460  {
    7461  goto basic_json_parser_21;
    7462  }
    7463  if (yych <= 'e')
    7464  {
    7465  goto basic_json_parser_4;
    7466  }
    7467  goto basic_json_parser_23;
    7468  }
    7469  else
    7470  {
    7471  if (yych == 'n')
    7472  {
    7473  goto basic_json_parser_24;
    7474  }
    7475  if (yych <= 's')
    7476  {
    7477  goto basic_json_parser_4;
    7478  }
    7479  goto basic_json_parser_25;
    7480  }
    7481  }
    7482  else
    7483  {
    7484  if (yych <= '|')
    7485  {
    7486  if (yych == '{')
    7487  {
    7488  goto basic_json_parser_26;
    7489  }
    7490  goto basic_json_parser_4;
    7491  }
    7492  else
    7493  {
    7494  if (yych <= '}')
    7495  {
    7496  goto basic_json_parser_28;
    7497  }
    7498  if (yych == 0xEF)
    7499  {
    7500  goto basic_json_parser_30;
    7501  }
    7502  goto basic_json_parser_4;
    7503  }
    7504  }
    7505  }
    7506 basic_json_parser_2:
    7507  ++m_cursor;
    7508  {
    7509  return token_type::end_of_input;
    7510  }
    7511 basic_json_parser_4:
    7512  ++m_cursor;
    7513 basic_json_parser_5:
    7514  {
    7515  return token_type::parse_error;
    7516  }
    7517 basic_json_parser_6:
    7518  ++m_cursor;
    7519  if (m_limit <= m_cursor)
    7520  {
    7521  yyfill(); // LCOV_EXCL_LINE;
    7522  }
    7523  yych = *m_cursor;
    7524  if (yybm[0 + yych] & 32)
    7525  {
    7526  goto basic_json_parser_6;
    7527  }
    7528  {
    7529  return scan();
    7530  }
    7531 basic_json_parser_9:
    7532  yyaccept = 0;
    7533  yych = *(m_marker = ++m_cursor);
    7534  if (yych <= 0x0F)
    7535  {
    7536  goto basic_json_parser_5;
    7537  }
    7538  goto basic_json_parser_32;
    7539 basic_json_parser_10:
    7540  ++m_cursor;
    7541  {
    7542  return token_type::value_separator;
    7543  }
    7544 basic_json_parser_12:
    7545  yych = *++m_cursor;
    7546  if (yych <= '/')
    7547  {
    7548  goto basic_json_parser_5;
    7549  }
    7550  if (yych <= '0')
    7551  {
    7552  goto basic_json_parser_13;
    7553  }
    7554  if (yych <= '9')
    7555  {
    7556  goto basic_json_parser_15;
    7557  }
    7558  goto basic_json_parser_5;
    7559 basic_json_parser_13:
    7560  yyaccept = 1;
    7561  yych = *(m_marker = ++m_cursor);
    7562  if (yych <= 'D')
    7563  {
    7564  if (yych == '.')
    7565  {
    7566  goto basic_json_parser_37;
    7567  }
    7568  }
    7569  else
    7570  {
    7571  if (yych <= 'E')
    7572  {
    7573  goto basic_json_parser_38;
    7574  }
    7575  if (yych == 'e')
    7576  {
    7577  goto basic_json_parser_38;
    7578  }
    7579  }
    7580 basic_json_parser_14:
    7581  {
    7582  return token_type::value_number;
    7583  }
    7584 basic_json_parser_15:
    7585  yyaccept = 1;
    7586  m_marker = ++m_cursor;
    7587  if ((m_limit - m_cursor) < 3)
    7588  {
    7589  yyfill(); // LCOV_EXCL_LINE;
    7590  }
    7591  yych = *m_cursor;
    7592  if (yybm[0 + yych] & 64)
    7593  {
    7594  goto basic_json_parser_15;
    7595  }
    7596  if (yych <= 'D')
    7597  {
    7598  if (yych == '.')
    7599  {
    7600  goto basic_json_parser_37;
    7601  }
    7602  goto basic_json_parser_14;
    7603  }
    7604  else
    7605  {
    7606  if (yych <= 'E')
    7607  {
    7608  goto basic_json_parser_38;
    7609  }
    7610  if (yych == 'e')
    7611  {
    7612  goto basic_json_parser_38;
    7613  }
    7614  goto basic_json_parser_14;
    7615  }
    7616 basic_json_parser_17:
    7617  ++m_cursor;
    7618  {
    7619  return token_type::name_separator;
    7620  }
    7621 basic_json_parser_19:
    7622  ++m_cursor;
    7623  {
    7624  return token_type::begin_array;
    7625  }
    7626 basic_json_parser_21:
    7627  ++m_cursor;
    7628  {
    7629  return token_type::end_array;
    7630  }
    7631 basic_json_parser_23:
    7632  yyaccept = 0;
    7633  yych = *(m_marker = ++m_cursor);
    7634  if (yych == 'a')
    7635  {
    7636  goto basic_json_parser_39;
    7637  }
    7638  goto basic_json_parser_5;
    7639 basic_json_parser_24:
    7640  yyaccept = 0;
    7641  yych = *(m_marker = ++m_cursor);
    7642  if (yych == 'u')
    7643  {
    7644  goto basic_json_parser_40;
    7645  }
    7646  goto basic_json_parser_5;
    7647 basic_json_parser_25:
    7648  yyaccept = 0;
    7649  yych = *(m_marker = ++m_cursor);
    7650  if (yych == 'r')
    7651  {
    7652  goto basic_json_parser_41;
    7653  }
    7654  goto basic_json_parser_5;
    7655 basic_json_parser_26:
    7656  ++m_cursor;
    7657  {
    7658  return token_type::begin_object;
    7659  }
    7660 basic_json_parser_28:
    7661  ++m_cursor;
    7662  {
    7663  return token_type::end_object;
    7664  }
    7665 basic_json_parser_30:
    7666  yyaccept = 0;
    7667  yych = *(m_marker = ++m_cursor);
    7668  if (yych == 0xBB)
    7669  {
    7670  goto basic_json_parser_42;
    7671  }
    7672  goto basic_json_parser_5;
    7673 basic_json_parser_31:
    7674  ++m_cursor;
    7675  if (m_limit <= m_cursor)
    7676  {
    7677  yyfill(); // LCOV_EXCL_LINE;
    7678  }
    7679  yych = *m_cursor;
    7680 basic_json_parser_32:
    7681  if (yybm[0 + yych] & 128)
    7682  {
    7683  goto basic_json_parser_31;
    7684  }
    7685  if (yych <= 0x0F)
    7686  {
    7687  goto basic_json_parser_33;
    7688  }
    7689  if (yych <= '"')
    7690  {
    7691  goto basic_json_parser_34;
    7692  }
    7693  goto basic_json_parser_36;
    7694 basic_json_parser_33:
    7695  m_cursor = m_marker;
    7696  if (yyaccept == 0)
    7697  {
    7698  goto basic_json_parser_5;
    7699  }
    7700  else
    7701  {
    7702  goto basic_json_parser_14;
    7703  }
    7704 basic_json_parser_34:
    7705  ++m_cursor;
    7706  {
    7707  return token_type::value_string;
    7708  }
    7709 basic_json_parser_36:
    7710  ++m_cursor;
    7711  if (m_limit <= m_cursor)
    7712  {
    7713  yyfill(); // LCOV_EXCL_LINE;
    7714  }
    7715  yych = *m_cursor;
    7716  if (yych <= 'e')
    7717  {
    7718  if (yych <= '/')
    7719  {
    7720  if (yych == '"')
    7721  {
    7722  goto basic_json_parser_31;
    7723  }
    7724  if (yych <= '.')
    7725  {
    7726  goto basic_json_parser_33;
    7727  }
    7728  goto basic_json_parser_31;
    7729  }
    7730  else
    7731  {
    7732  if (yych <= '\\')
    7733  {
    7734  if (yych <= '[')
    7735  {
    7736  goto basic_json_parser_33;
    7737  }
    7738  goto basic_json_parser_31;
    7739  }
    7740  else
    7741  {
    7742  if (yych == 'b')
    7743  {
    7744  goto basic_json_parser_31;
    7745  }
    7746  goto basic_json_parser_33;
    7747  }
    7748  }
    7749  }
    7750  else
    7751  {
    7752  if (yych <= 'q')
    7753  {
    7754  if (yych <= 'f')
    7755  {
    7756  goto basic_json_parser_31;
    7757  }
    7758  if (yych == 'n')
    7759  {
    7760  goto basic_json_parser_31;
    7761  }
    7762  goto basic_json_parser_33;
    7763  }
    7764  else
    7765  {
    7766  if (yych <= 's')
    7767  {
    7768  if (yych <= 'r')
    7769  {
    7770  goto basic_json_parser_31;
    7771  }
    7772  goto basic_json_parser_33;
    7773  }
    7774  else
    7775  {
    7776  if (yych <= 't')
    7777  {
    7778  goto basic_json_parser_31;
    7779  }
    7780  if (yych <= 'u')
    7781  {
    7782  goto basic_json_parser_43;
    7783  }
    7784  goto basic_json_parser_33;
    7785  }
    7786  }
    7787  }
    7788 basic_json_parser_37:
    7789  yych = *++m_cursor;
    7790  if (yych <= '/')
    7791  {
    7792  goto basic_json_parser_33;
    7793  }
    7794  if (yych <= '9')
    7795  {
    7796  goto basic_json_parser_44;
    7797  }
    7798  goto basic_json_parser_33;
    7799 basic_json_parser_38:
    7800  yych = *++m_cursor;
    7801  if (yych <= ',')
    7802  {
    7803  if (yych == '+')
    7804  {
    7805  goto basic_json_parser_46;
    7806  }
    7807  goto basic_json_parser_33;
    7808  }
    7809  else
    7810  {
    7811  if (yych <= '-')
    7812  {
    7813  goto basic_json_parser_46;
    7814  }
    7815  if (yych <= '/')
    7816  {
    7817  goto basic_json_parser_33;
    7818  }
    7819  if (yych <= '9')
    7820  {
    7821  goto basic_json_parser_47;
    7822  }
    7823  goto basic_json_parser_33;
    7824  }
    7825 basic_json_parser_39:
    7826  yych = *++m_cursor;
    7827  if (yych == 'l')
    7828  {
    7829  goto basic_json_parser_49;
    7830  }
    7831  goto basic_json_parser_33;
    7832 basic_json_parser_40:
    7833  yych = *++m_cursor;
    7834  if (yych == 'l')
    7835  {
    7836  goto basic_json_parser_50;
    7837  }
    7838  goto basic_json_parser_33;
    7839 basic_json_parser_41:
    7840  yych = *++m_cursor;
    7841  if (yych == 'u')
    7842  {
    7843  goto basic_json_parser_51;
    7844  }
    7845  goto basic_json_parser_33;
    7846 basic_json_parser_42:
    7847  yych = *++m_cursor;
    7848  if (yych == 0xBF)
    7849  {
    7850  goto basic_json_parser_52;
    7851  }
    7852  goto basic_json_parser_33;
    7853 basic_json_parser_43:
    7854  ++m_cursor;
    7855  if (m_limit <= m_cursor)
    7856  {
    7857  yyfill(); // LCOV_EXCL_LINE;
    7858  }
    7859  yych = *m_cursor;
    7860  if (yych <= '@')
    7861  {
    7862  if (yych <= '/')
    7863  {
    7864  goto basic_json_parser_33;
    7865  }
    7866  if (yych <= '9')
    7867  {
    7868  goto basic_json_parser_54;
    7869  }
    7870  goto basic_json_parser_33;
    7871  }
    7872  else
    7873  {
    7874  if (yych <= 'F')
    7875  {
    7876  goto basic_json_parser_54;
    7877  }
    7878  if (yych <= '`')
    7879  {
    7880  goto basic_json_parser_33;
    7881  }
    7882  if (yych <= 'f')
    7883  {
    7884  goto basic_json_parser_54;
    7885  }
    7886  goto basic_json_parser_33;
    7887  }
    7888 basic_json_parser_44:
    7889  yyaccept = 1;
    7890  m_marker = ++m_cursor;
    7891  if ((m_limit - m_cursor) < 3)
    7892  {
    7893  yyfill(); // LCOV_EXCL_LINE;
    7894  }
    7895  yych = *m_cursor;
    7896  if (yych <= 'D')
    7897  {
    7898  if (yych <= '/')
    7899  {
    7900  goto basic_json_parser_14;
    7901  }
    7902  if (yych <= '9')
    7903  {
    7904  goto basic_json_parser_44;
    7905  }
    7906  goto basic_json_parser_14;
    7907  }
    7908  else
    7909  {
    7910  if (yych <= 'E')
    7911  {
    7912  goto basic_json_parser_38;
    7913  }
    7914  if (yych == 'e')
    7915  {
    7916  goto basic_json_parser_38;
    7917  }
    7918  goto basic_json_parser_14;
    7919  }
    7920 basic_json_parser_46:
    7921  yych = *++m_cursor;
    7922  if (yych <= '/')
    7923  {
    7924  goto basic_json_parser_33;
    7925  }
    7926  if (yych >= ':')
    7927  {
    7928  goto basic_json_parser_33;
    7929  }
    7930 basic_json_parser_47:
    7931  ++m_cursor;
    7932  if (m_limit <= m_cursor)
    7933  {
    7934  yyfill(); // LCOV_EXCL_LINE;
    7935  }
    7936  yych = *m_cursor;
    7937  if (yych <= '/')
    7938  {
    7939  goto basic_json_parser_14;
    7940  }
    7941  if (yych <= '9')
    7942  {
    7943  goto basic_json_parser_47;
    7944  }
    7945  goto basic_json_parser_14;
    7946 basic_json_parser_49:
    7947  yych = *++m_cursor;
    7948  if (yych == 's')
    7949  {
    7950  goto basic_json_parser_55;
    7951  }
    7952  goto basic_json_parser_33;
    7953 basic_json_parser_50:
    7954  yych = *++m_cursor;
    7955  if (yych == 'l')
    7956  {
    7957  goto basic_json_parser_56;
    7958  }
    7959  goto basic_json_parser_33;
    7960 basic_json_parser_51:
    7961  yych = *++m_cursor;
    7962  if (yych == 'e')
    7963  {
    7964  goto basic_json_parser_58;
    7965  }
    7966  goto basic_json_parser_33;
    7967 basic_json_parser_52:
    7968  ++m_cursor;
    7969  {
    7970  return scan();
    7971  }
    7972 basic_json_parser_54:
    7973  ++m_cursor;
    7974  if (m_limit <= m_cursor)
    7975  {
    7976  yyfill(); // LCOV_EXCL_LINE;
    7977  }
    7978  yych = *m_cursor;
    7979  if (yych <= '@')
    7980  {
    7981  if (yych <= '/')
    7982  {
    7983  goto basic_json_parser_33;
    7984  }
    7985  if (yych <= '9')
    7986  {
    7987  goto basic_json_parser_60;
    7988  }
    7989  goto basic_json_parser_33;
    7990  }
    7991  else
    7992  {
    7993  if (yych <= 'F')
    7994  {
    7995  goto basic_json_parser_60;
    7996  }
    7997  if (yych <= '`')
    7998  {
    7999  goto basic_json_parser_33;
    8000  }
    8001  if (yych <= 'f')
    8002  {
    8003  goto basic_json_parser_60;
    8004  }
    8005  goto basic_json_parser_33;
    8006  }
    8007 basic_json_parser_55:
    8008  yych = *++m_cursor;
    8009  if (yych == 'e')
    8010  {
    8011  goto basic_json_parser_61;
    8012  }
    8013  goto basic_json_parser_33;
    8014 basic_json_parser_56:
    8015  ++m_cursor;
    8016  {
    8017  return token_type::literal_null;
    8018  }
    8019 basic_json_parser_58:
    8020  ++m_cursor;
    8021  {
    8022  return token_type::literal_true;
    8023  }
    8024 basic_json_parser_60:
    8025  ++m_cursor;
    8026  if (m_limit <= m_cursor)
    8027  {
    8028  yyfill(); // LCOV_EXCL_LINE;
    8029  }
    8030  yych = *m_cursor;
    8031  if (yych <= '@')
    8032  {
    8033  if (yych <= '/')
    8034  {
    8035  goto basic_json_parser_33;
    8036  }
    8037  if (yych <= '9')
    8038  {
    8039  goto basic_json_parser_63;
    8040  }
    8041  goto basic_json_parser_33;
    8042  }
    8043  else
    8044  {
    8045  if (yych <= 'F')
    8046  {
    8047  goto basic_json_parser_63;
    8048  }
    8049  if (yych <= '`')
    8050  {
    8051  goto basic_json_parser_33;
    8052  }
    8053  if (yych <= 'f')
    8054  {
    8055  goto basic_json_parser_63;
    8056  }
    8057  goto basic_json_parser_33;
    8058  }
    8059 basic_json_parser_61:
    8060  ++m_cursor;
    8061  {
    8062  return token_type::literal_false;
    8063  }
    8064 basic_json_parser_63:
    8065  ++m_cursor;
    8066  if (m_limit <= m_cursor)
    8067  {
    8068  yyfill(); // LCOV_EXCL_LINE;
    8069  }
    8070  yych = *m_cursor;
    8071  if (yych <= '@')
    8072  {
    8073  if (yych <= '/')
    8074  {
    8075  goto basic_json_parser_33;
    8076  }
    8077  if (yych <= '9')
    8078  {
    8079  goto basic_json_parser_31;
    8080  }
    8081  goto basic_json_parser_33;
    8082  }
    8083  else
    8084  {
    8085  if (yych <= 'F')
    8086  {
    8087  goto basic_json_parser_31;
    8088  }
    8089  if (yych <= '`')
    8090  {
    8091  goto basic_json_parser_33;
    8092  }
    8093  if (yych <= 'f')
    8094  {
    8095  goto basic_json_parser_31;
    8096  }
    8097  goto basic_json_parser_33;
    8098  }
    8099  }
    8100 
    8101  }
    8102 
    8104  void yyfill() noexcept
    8105  {
    8106  if (m_stream == nullptr or not * m_stream)
    8107  {
    8108  return;
    8109  }
    8110 
    8111  const auto offset_start = m_start - m_content;
    8112  const auto offset_marker = m_marker - m_start;
    8113  const auto offset_cursor = m_cursor - m_start;
    8114 
    8115  m_buffer.erase(0, static_cast<size_t>(offset_start));
    8116  std::string line;
    8117  assert(m_stream != nullptr);
    8118  std::getline(*m_stream, line);
    8119  m_buffer += "\n" + line; // add line with newline symbol
    8120 
    8121  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    8122  assert(m_content != nullptr);
    8123  m_start = m_content;
    8124  m_marker = m_start + offset_marker;
    8125  m_cursor = m_start + offset_cursor;
    8126  m_limit = m_start + m_buffer.size() - 1;
    8127  }
    8128 
    8130  string_t get_token() const
    8131  {
    8132  assert(m_start != nullptr);
    8133  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    8134  static_cast<size_t>(m_cursor - m_start));
    8135  }
    8136 
    8159  string_t get_string() const
    8160  {
    8161  string_t result;
    8162  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    8163 
    8164  // iterate the result between the quotes
    8165  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    8166  {
    8167  // process escaped characters
    8168  if (*i == '\\')
    8169  {
    8170  // read next character
    8171  ++i;
    8172 
    8173  switch (*i)
    8174  {
    8175  // the default escapes
    8176  case 't':
    8177  {
    8178  result += "\t";
    8179  break;
    8180  }
    8181  case 'b':
    8182  {
    8183  result += "\b";
    8184  break;
    8185  }
    8186  case 'f':
    8187  {
    8188  result += "\f";
    8189  break;
    8190  }
    8191  case 'n':
    8192  {
    8193  result += "\n";
    8194  break;
    8195  }
    8196  case 'r':
    8197  {
    8198  result += "\r";
    8199  break;
    8200  }
    8201  case '\\':
    8202  {
    8203  result += "\\";
    8204  break;
    8205  }
    8206  case '/':
    8207  {
    8208  result += "/";
    8209  break;
    8210  }
    8211  case '"':
    8212  {
    8213  result += "\"";
    8214  break;
    8215  }
    8216 
    8217  // unicode
    8218  case 'u':
    8219  {
    8220  // get code xxxx from uxxxx
    8221  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    8222  4).c_str(), nullptr, 16);
    8223 
    8224  // check if codepoint is a high surrogate
    8225  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    8226  {
    8227  // make sure there is a subsequent unicode
    8228  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    8229  {
    8230  throw std::invalid_argument("missing low surrogate");
    8231  }
    8232 
    8233  // get code yyyy from uxxxx\uyyyy
    8234  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    8235  (i + 7), 4).c_str(), nullptr, 16);
    8236  result += to_unicode(codepoint, codepoint2);
    8237  // skip the next 10 characters (xxxx\uyyyy)
    8238  i += 10;
    8239  }
    8240  else
    8241  {
    8242  // add unicode character(s)
    8243  result += to_unicode(codepoint);
    8244  // skip the next four characters (xxxx)
    8245  i += 4;
    8246  }
    8247  break;
    8248  }
    8249  }
    8250  }
    8251  else
    8252  {
    8253  // all other characters are just copied to the end of the
    8254  // string
    8255  result.append(1, static_cast<typename string_t::value_type>(*i));
    8256  }
    8257  }
    8258 
    8259  return result;
    8260  }
    8261 
    8282  long double str_to_float_t(long double* /* type */, char** endptr) const
    8283  {
    8284  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8285  }
    8286 
    8302  double str_to_float_t(double* /* type */, char** endptr) const
    8303  {
    8304  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8305  }
    8306 
    8322  float str_to_float_t(float* /* type */, char** endptr) const
    8323  {
    8324  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    8325  }
    8326 
    8348  void get_number(basic_json& result) const
    8349  {
    8350  assert(m_start != nullptr);
    8351 
    8352  const lexer::lexer_char_t* curptr = m_start;
    8353 
    8354  // accumulate the integer conversion result (unsigned for now)
    8355  number_unsigned_t value = 0;
    8356 
    8357  // maximum absolute value of the relevant integer type
    8358  number_unsigned_t max;
    8359 
    8360  // temporarily store the type to avoid unecessary bitfield access
    8361  value_t type;
    8362 
    8363  // look for sign
    8364  if (*curptr == '-')
    8365  {
    8366  type = value_t::number_integer;
    8367  max = static_cast<uint64_t>((std::numeric_limits<number_integer_t>::max)()) + 1;
    8368  curptr++;
    8369  }
    8370  else
    8371  {
    8372  type = value_t::number_unsigned;
    8373  max = static_cast<uint64_t>((std::numeric_limits<number_unsigned_t>::max)());
    8374  }
    8375 
    8376  // count the significant figures
    8377  for (; curptr < m_cursor; curptr++)
    8378  {
    8379  // quickly skip tests if a digit
    8380  if (*curptr < '0' || *curptr > '9')
    8381  {
    8382  if (*curptr == '.')
    8383  {
    8384  // don't count '.' but change to float
    8385  type = value_t::number_float;
    8386  continue;
    8387  }
    8388  // assume exponent (if not then will fail parse): change to
    8389  // float, stop counting and record exponent details
    8390  type = value_t::number_float;
    8391  break;
    8392  }
    8393 
    8394  // skip if definitely not an integer
    8395  if (type != value_t::number_float)
    8396  {
    8397  // multiply last value by ten and add the new digit
    8398  auto temp = value * 10 + *curptr - 0x30;
    8399 
    8400  // test for overflow
    8401  if (temp < value || temp > max)
    8402  {
    8403  // overflow
    8404  type = value_t::number_float;
    8405  }
    8406  else
    8407  {
    8408  // no overflow - save it
    8409  value = temp;
    8410  }
    8411  }
    8412  }
    8413 
    8414  // save the value (if not a float)
    8415  if (type == value_t::number_unsigned)
    8416  {
    8417  result.m_value.number_unsigned = value;
    8418  }
    8419  else if (type == value_t::number_integer)
    8420  {
    8421  result.m_value.number_integer = -static_cast<number_integer_t>(value);
    8422  }
    8423  else
    8424  {
    8425  // parse with strtod
    8426  result.m_value.number_float = str_to_float_t(static_cast<number_float_t*>(nullptr), NULL);
    8427  }
    8428 
    8429  // save the type
    8430  result.m_type = type;
    8431  }
    8432 
    8433  private:
    8435  std::istream* m_stream = nullptr;
    8437  string_t m_buffer;
    8439  const lexer_char_t* m_content = nullptr;
    8441  const lexer_char_t* m_start = nullptr;
    8443  const lexer_char_t* m_marker = nullptr;
    8445  const lexer_char_t* m_cursor = nullptr;
    8447  const lexer_char_t* m_limit = nullptr;
    8448  };
    8449 
    8455  class parser
    8456  {
    8457  public:
    8459  parser(const string_t& s, parser_callback_t cb = nullptr) noexcept
    8460  : callback(cb), m_lexer(s)
    8461  {
    8462  // read first token
    8463  get_token();
    8464  }
    8465 
    8467  parser(std::istream& _is, parser_callback_t cb = nullptr) noexcept
    8468  : callback(cb), m_lexer(&_is)
    8469  {
    8470  // read first token
    8471  get_token();
    8472  }
    8473 
    8475  basic_json parse()
    8476  {
    8477  basic_json result = parse_internal(true);
    8478 
    8479  expect(lexer::token_type::end_of_input);
    8480 
    8481  // return parser result and replace it with null in case the
    8482  // top-level value was discarded by the callback function
    8483  return result.is_discarded() ? basic_json() : result;
    8484  }
    8485 
    8486  private:
    8488  basic_json parse_internal(bool keep)
    8489  {
    8490  auto result = basic_json(value_t::discarded);
    8491 
    8492  switch (last_token)
    8493  {
    8494  case lexer::token_type::begin_object:
    8495  {
    8496  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    8497  {
    8498  // explicitly set result to object to cope with {}
    8499  result.m_type = value_t::object;
    8500  result.m_value = json_value(value_t::object);
    8501  }
    8502 
    8503  // read next token
    8504  get_token();
    8505 
    8506  // closing } -> we are done
    8507  if (last_token == lexer::token_type::end_object)
    8508  {
    8509  get_token();
    8510  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8511  {
    8512  result = basic_json(value_t::discarded);
    8513  }
    8514  return result;
    8515  }
    8516 
    8517  // no comma is expected here
    8518  unexpect(lexer::token_type::value_separator);
    8519 
    8520  // otherwise: parse key-value pairs
    8521  do
    8522  {
    8523  // ugly, but could be fixed with loop reorganization
    8524  if (last_token == lexer::token_type::value_separator)
    8525  {
    8526  get_token();
    8527  }
    8528 
    8529  // store key
    8530  expect(lexer::token_type::value_string);
    8531  const auto key = m_lexer.get_string();
    8532 
    8533  bool keep_tag = false;
    8534  if (keep)
    8535  {
    8536  if (callback)
    8537  {
    8538  basic_json k(key);
    8539  keep_tag = callback(depth, parse_event_t::key, k);
    8540  }
    8541  else
    8542  {
    8543  keep_tag = true;
    8544  }
    8545  }
    8546 
    8547  // parse separator (:)
    8548  get_token();
    8549  expect(lexer::token_type::name_separator);
    8550 
    8551  // parse and add value
    8552  get_token();
    8553  auto value = parse_internal(keep);
    8554  if (keep and keep_tag and not value.is_discarded())
    8555  {
    8556  result[key] = std::move(value);
    8557  }
    8558  }
    8559  while (last_token == lexer::token_type::value_separator);
    8560 
    8561  // closing }
    8562  expect(lexer::token_type::end_object);
    8563  get_token();
    8564  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    8565  {
    8566  result = basic_json(value_t::discarded);
    8567  }
    8568 
    8569  return result;
    8570  }
    8571 
    8572  case lexer::token_type::begin_array:
    8573  {
    8574  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    8575  {
    8576  // explicitly set result to object to cope with []
    8577  result.m_type = value_t::array;
    8578  result.m_value = json_value(value_t::array);
    8579  }
    8580 
    8581  // read next token
    8582  get_token();
    8583 
    8584  // closing ] -> we are done
    8585  if (last_token == lexer::token_type::end_array)
    8586  {
    8587  get_token();
    8588  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8589  {
    8590  result = basic_json(value_t::discarded);
    8591  }
    8592  return result;
    8593  }
    8594 
    8595  // no comma is expected here
    8596  unexpect(lexer::token_type::value_separator);
    8597 
    8598  // otherwise: parse values
    8599  do
    8600  {
    8601  // ugly, but could be fixed with loop reorganization
    8602  if (last_token == lexer::token_type::value_separator)
    8603  {
    8604  get_token();
    8605  }
    8606 
    8607  // parse value
    8608  auto value = parse_internal(keep);
    8609  if (keep and not value.is_discarded())
    8610  {
    8611  result.push_back(std::move(value));
    8612  }
    8613  }
    8614  while (last_token == lexer::token_type::value_separator);
    8615 
    8616  // closing ]
    8617  expect(lexer::token_type::end_array);
    8618  get_token();
    8619  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8620  {
    8621  result = basic_json(value_t::discarded);
    8622  }
    8623 
    8624  return result;
    8625  }
    8626 
    8627  case lexer::token_type::literal_null:
    8628  {
    8629  get_token();
    8630  result.m_type = value_t::null;
    8631  break;
    8632  }
    8633 
    8634  case lexer::token_type::value_string:
    8635  {
    8636  const auto s = m_lexer.get_string();
    8637  get_token();
    8638  result = basic_json(s);
    8639  break;
    8640  }
    8641 
    8642  case lexer::token_type::literal_true:
    8643  {
    8644  get_token();
    8645  result.m_type = value_t::boolean;
    8646  result.m_value = true;
    8647  break;
    8648  }
    8649 
    8650  case lexer::token_type::literal_false:
    8651  {
    8652  get_token();
    8653  result.m_type = value_t::boolean;
    8654  result.m_value = false;
    8655  break;
    8656  }
    8657 
    8658  case lexer::token_type::value_number:
    8659  {
    8660  m_lexer.get_number(result);
    8661  get_token();
    8662  break;
    8663  }
    8664 
    8665  default:
    8666  {
    8667  // the last token was unexpected
    8668  unexpect(last_token);
    8669  }
    8670  }
    8671 
    8672  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8673  {
    8674  result = basic_json(value_t::discarded);
    8675  }
    8676  return result;
    8677  }
    8678 
    8680  typename lexer::token_type get_token() noexcept
    8681  {
    8682  last_token = m_lexer.scan();
    8683  return last_token;
    8684  }
    8685 
    8686  void expect(typename lexer::token_type t) const
    8687  {
    8688  if (t != last_token)
    8689  {
    8690  std::string error_msg = "parse error - unexpected ";
    8691  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8692  lexer::token_type_name(last_token));
    8693  error_msg += "; expected " + lexer::token_type_name(t);
    8694  throw std::invalid_argument(error_msg);
    8695  }
    8696  }
    8697 
    8698  void unexpect(typename lexer::token_type t) const
    8699  {
    8700  if (t == last_token)
    8701  {
    8702  std::string error_msg = "parse error - unexpected ";
    8703  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8704  lexer::token_type_name(last_token));
    8705  throw std::invalid_argument(error_msg);
    8706  }
    8707  }
    8708 
    8709  private:
    8711  int depth = 0;
    8713  parser_callback_t callback;
    8715  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8717  lexer m_lexer;
    8718  };
    8719 
    8720  public:
    8733  {
    8735  friend class basic_json;
    8736 
    8737  public:
    8760  explicit json_pointer(const std::string& s = "")
    8761  : reference_tokens(split(s))
    8762  {}
    8763 
    8779  std::string to_string() const noexcept
    8780  {
    8781  std::string result;
    8782 
    8783  for (const auto& reference_token : reference_tokens)
    8784  {
    8785  result += "/" + escape(reference_token);
    8786  }
    8787 
    8788  return result;
    8789  }
    8790 
    8792  operator std::string() const
    8793  {
    8794  return to_string();
    8795  }
    8797  private:
    8799  std::string pop_back()
    8800  {
    8801  if (is_root())
    8802  {
    8803  throw std::domain_error("JSON pointer has no parent");
    8804  }
    8805 
    8806  auto last = reference_tokens.back();
    8807  reference_tokens.pop_back();
    8808  return last;
    8809  }
    8810 
    8812  bool is_root() const
    8813  {
    8814  return reference_tokens.empty();
    8815  }
    8816 
    8817  json_pointer top() const
    8818  {
    8819  if (is_root())
    8820  {
    8821  throw std::domain_error("JSON pointer has no parent");
    8822  }
    8823 
    8824  json_pointer result = *this;
    8825  result.reference_tokens = {reference_tokens[0]};
    8826  return result;
    8827  }
    8828 
    8832  reference get_and_create(reference j) const
    8833  {
    8834  pointer result = &j;
    8835 
    8836  // in case no reference tokens exist, return a reference to the
    8837  // JSON value j which will be overwritten by a primitive value
    8838  for (const auto& reference_token : reference_tokens)
    8839  {
    8840  switch (result->m_type)
    8841  {
    8842  case value_t::null:
    8843  {
    8844  if (reference_token == "0")
    8845  {
    8846  // start a new array if reference token is 0
    8847  result = &result->operator[](0);
    8848  }
    8849  else
    8850  {
    8851  // start a new object otherwise
    8852  result = &result->operator[](reference_token);
    8853  }
    8854  break;
    8855  }
    8856 
    8857  case value_t::object:
    8858  {
    8859  // create an entry in the object
    8860  result = &result->operator[](reference_token);
    8861  break;
    8862  }
    8863 
    8864  case value_t::array:
    8865  {
    8866  // create an entry in the array
    8867  result = &result->operator[](static_cast<size_type>(std::stoi(reference_token)));
    8868  break;
    8869  }
    8870 
    8871  /*
    8872  The following code is only reached if there exists a
    8873  reference token _and_ the current value is primitive. In
    8874  this case, we have an error situation, because primitive
    8875  values may only occur as single value; that is, with an
    8876  empty list of reference tokens.
    8877  */
    8878  default:
    8879  {
    8880  throw std::domain_error("invalid value to unflatten");
    8881  }
    8882  }
    8883  }
    8884 
    8885  return *result;
    8886  }
    8887 
    8901  reference get_unchecked(pointer ptr) const
    8902  {
    8903  for (const auto& reference_token : reference_tokens)
    8904  {
    8905  switch (ptr->m_type)
    8906  {
    8907  case value_t::object:
    8908  {
    8909  // use unchecked object access
    8910  ptr = &ptr->operator[](reference_token);
    8911  break;
    8912  }
    8913 
    8914  case value_t::array:
    8915  {
    8916  // error condition (cf. RFC 6901, Sect. 4)
    8917  if (reference_token.size() > 1 and reference_token[0] == '0')
    8918  {
    8919  throw std::domain_error("array index must not begin with '0'");
    8920  }
    8921 
    8922  if (reference_token == "-")
    8923  {
    8924  // explicityly treat "-" as index beyond the end
    8925  ptr = &ptr->operator[](ptr->m_value.array->size());
    8926  }
    8927  else
    8928  {
    8929  // convert array index to number; unchecked access
    8930  ptr = &ptr->operator[](static_cast<size_type>(std::stoi(reference_token)));
    8931  }
    8932  break;
    8933  }
    8934 
    8935  default:
    8936  {
    8937  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    8938  }
    8939  }
    8940  }
    8941 
    8942  return *ptr;
    8943  }
    8944 
    8945  reference get_checked(pointer ptr) const
    8946  {
    8947  for (const auto& reference_token : reference_tokens)
    8948  {
    8949  switch (ptr->m_type)
    8950  {
    8951  case value_t::object:
    8952  {
    8953  // note: at performs range check
    8954  ptr = &ptr->at(reference_token);
    8955  break;
    8956  }
    8957 
    8958  case value_t::array:
    8959  {
    8960  if (reference_token == "-")
    8961  {
    8962  // "-" always fails the range check
    8963  throw std::out_of_range("array index '-' (" +
    8964  std::to_string(ptr->m_value.array->size()) +
    8965  ") is out of range");
    8966  }
    8967 
    8968  // error condition (cf. RFC 6901, Sect. 4)
    8969  if (reference_token.size() > 1 and reference_token[0] == '0')
    8970  {
    8971  throw std::domain_error("array index must not begin with '0'");
    8972  }
    8973 
    8974  // note: at performs range check
    8975  ptr = &ptr->at(static_cast<size_type>(std::stoi(reference_token)));
    8976  break;
    8977  }
    8978 
    8979  default:
    8980  {
    8981  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    8982  }
    8983  }
    8984  }
    8985 
    8986  return *ptr;
    8987  }
    8988 
    8997  const_reference get_unchecked(const_pointer ptr) const
    8998  {
    8999  for (const auto& reference_token : reference_tokens)
    9000  {
    9001  switch (ptr->m_type)
    9002  {
    9003  case value_t::object:
    9004  {
    9005  // use unchecked object access
    9006  ptr = &ptr->operator[](reference_token);
    9007  break;
    9008  }
    9009 
    9010  case value_t::array:
    9011  {
    9012  if (reference_token == "-")
    9013  {
    9014  // "-" cannot be used for const access
    9015  throw std::out_of_range("array index '-' (" +
    9016  std::to_string(ptr->m_value.array->size()) +
    9017  ") is out of range");
    9018  }
    9019 
    9020  // error condition (cf. RFC 6901, Sect. 4)
    9021  if (reference_token.size() > 1 and reference_token[0] == '0')
    9022  {
    9023  throw std::domain_error("array index must not begin with '0'");
    9024  }
    9025 
    9026  // use unchecked array access
    9027  ptr = &ptr->operator[](static_cast<size_type>(std::stoi(reference_token)));
    9028  break;
    9029  }
    9030 
    9031  default:
    9032  {
    9033  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    9034  }
    9035  }
    9036  }
    9037 
    9038  return *ptr;
    9039  }
    9040 
    9041  const_reference get_checked(const_pointer ptr) const
    9042  {
    9043  for (const auto& reference_token : reference_tokens)
    9044  {
    9045  switch (ptr->m_type)
    9046  {
    9047  case value_t::object:
    9048  {
    9049  // note: at performs range check
    9050  ptr = &ptr->at(reference_token);
    9051  break;
    9052  }
    9053 
    9054  case value_t::array:
    9055  {
    9056  if (reference_token == "-")
    9057  {
    9058  // "-" always fails the range check
    9059  throw std::out_of_range("array index '-' (" +
    9060  std::to_string(ptr->m_value.array->size()) +
    9061  ") is out of range");
    9062  }
    9063 
    9064  // error condition (cf. RFC 6901, Sect. 4)
    9065  if (reference_token.size() > 1 and reference_token[0] == '0')
    9066  {
    9067  throw std::domain_error("array index must not begin with '0'");
    9068  }
    9069 
    9070  // note: at performs range check
    9071  ptr = &ptr->at(static_cast<size_type>(std::stoi(reference_token)));
    9072  break;
    9073  }
    9074 
    9075  default:
    9076  {
    9077  throw std::out_of_range("unresolved reference token '" + reference_token + "'");
    9078  }
    9079  }
    9080  }
    9081 
    9082  return *ptr;
    9083  }
    9084 
    9086  static std::vector<std::string> split(std::string reference_string)
    9087  {
    9088  std::vector<std::string> result;
    9089 
    9090  // special case: empty reference string -> no reference tokens
    9091  if (reference_string.empty())
    9092  {
    9093  return result;
    9094  }
    9095 
    9096  // check if nonempty reference string begins with slash
    9097  if (reference_string[0] != '/')
    9098  {
    9099  throw std::domain_error("JSON pointer must be empty or begin with '/'");
    9100  }
    9101 
    9102  // extract the reference tokens:
    9103  // - slash: position of the last read slash (or end of string)
    9104  // - start: position after the previous slash
    9105  for (
    9106  // search for the first slash after the first character
    9107  size_t slash = reference_string.find_first_of("/", 1),
    9108  // set the beginning of the first reference token
    9109  start = 1;
    9110  // we can stop if start == string::npos+1 = 0
    9111  start != 0;
    9112  // set the beginning of the next reference token
    9113  // (will eventually be 0 if slash == std::string::npos)
    9114  start = slash + 1,
    9115  // find next slash
    9116  slash = reference_string.find_first_of("/", start))
    9117  {
    9118  // use the text between the beginning of the reference token
    9119  // (start) and the last slash (slash).
    9120  auto reference_token = reference_string.substr(start, slash - start);
    9121 
    9122  // check reference tokens are properly escaped
    9123  for (size_t pos = reference_token.find_first_of("~");
    9124  pos != std::string::npos;
    9125  pos = reference_token.find_first_of("~", pos + 1))
    9126  {
    9127  assert(reference_token[pos] == '~');
    9128 
    9129  // ~ must be followed by 0 or 1
    9130  if (pos == reference_token.size() - 1 or
    9131  (reference_token[pos + 1] != '0' and
    9132  reference_token[pos + 1] != '1'))
    9133  {
    9134  throw std::domain_error("escape error: '~' must be followed with '0' or '1'");
    9135  }
    9136  }
    9137 
    9138  // finally, store the reference token
    9139  unescape(reference_token);
    9140  result.push_back(reference_token);
    9141  }
    9142 
    9143  return result;
    9144  }
    9145 
    9146  private:
    9161  static void replace_substring(std::string& s,
    9162  const std::string& f,
    9163  const std::string& t)
    9164  {
    9165  assert(not f.empty());
    9166 
    9167  for (
    9168  size_t pos = s.find(f); // find first occurrence of f
    9169  pos != std::string::npos; // make sure f was found
    9170  s.replace(pos, f.size(), t), // replace with t
    9171  pos = s.find(f, pos + t.size()) // find next occurrence of f
    9172  );
    9173  }
    9174 
    9176  static std::string escape(std::string s)
    9177  {
    9178  // escape "~"" to "~0" and "/" to "~1"
    9179  replace_substring(s, "~", "~0");
    9180  replace_substring(s, "/", "~1");
    9181  return s;
    9182  }
    9183 
    9185  static void unescape(std::string& s)
    9186  {
    9187  // first transform any occurrence of the sequence '~1' to '/'
    9188  replace_substring(s, "~1", "/");
    9189  // then transform any occurrence of the sequence '~0' to '~'
    9190  replace_substring(s, "~0", "~");
    9191  }
    9192 
    9200  static void flatten(const std::string& reference_string,
    9201  const basic_json& value,
    9202  basic_json& result)
    9203  {
    9204  switch (value.m_type)
    9205  {
    9206  case value_t::array:
    9207  {
    9208  if (value.m_value.array->empty())
    9209  {
    9210  // flatten empty array as null
    9211  result[reference_string] = nullptr;
    9212  }
    9213  else
    9214  {
    9215  // iterate array and use index as reference string
    9216  for (size_t i = 0; i < value.m_value.array->size(); ++i)
    9217  {
    9218  flatten(reference_string + "/" + std::to_string(i),
    9219  value.m_value.array->operator[](i), result);
    9220  }
    9221  }
    9222  break;
    9223  }
    9224 
    9225  case value_t::object:
    9226  {
    9227  if (value.m_value.object->empty())
    9228  {
    9229  // flatten empty object as null
    9230  result[reference_string] = nullptr;
    9231  }
    9232  else
    9233  {
    9234  // iterate object and use keys as reference string
    9235  for (const auto& element : *value.m_value.object)
    9236  {
    9237  flatten(reference_string + "/" + escape(element.first),
    9238  element.second, result);
    9239  }
    9240  }
    9241  break;
    9242  }
    9243 
    9244  default:
    9245  {
    9246  // add primitive value with its reference string
    9247  result[reference_string] = value;
    9248  break;
    9249  }
    9250  }
    9251  }
    9252 
    9258  static basic_json unflatten(const basic_json& value)
    9259  {
    9260  if (not value.is_object())
    9261  {
    9262  throw std::domain_error("only objects can be unflattened");
    9263  }
    9264 
    9265  basic_json result;
    9266 
    9267  // iterate the JSON object values
    9268  for (const auto& element : *value.m_value.object)
    9269  {
    9270  if (not element.second.is_primitive())
    9271  {
    9272  throw std::domain_error("values in object must be primitive");
    9273  }
    9274 
    9275  // assign value to reference pointed to by JSON pointer; Note
    9276  // that if the JSON pointer is "" (i.e., points to the whole
    9277  // value), function get_and_create returns a reference to
    9278  // result itself. An assignment will then create a primitive
    9279  // value.
    9280  json_pointer(element.first).get_and_create(result) = element.second;
    9281  }
    9282 
    9283  return result;
    9284  }
    9285 
    9286  private:
    9288  std::vector<std::string> reference_tokens {};
    9289  };
    9290 
    9292  // JSON Pointer support //
    9294 
    9297 
    9331  reference operator[](const json_pointer& ptr)
    9332  {
    9333  return ptr.get_unchecked(this);
    9334  }
    9358  const_reference operator[](const json_pointer& ptr) const
    9359  {
    9360  return ptr.get_unchecked(this);
    9361  }
    9383  reference at(const json_pointer& ptr)
    9384  {
    9385  return ptr.get_checked(this);
    9386  }
    9408  const_reference at(const json_pointer& ptr) const
    9409  {
    9410  return ptr.get_checked(this);
    9411  }
    9435  basic_json flatten() const
    9436  {
    9437  basic_json result(value_t::object);
    9438  json_pointer::flatten("", *this, result);
    9439  return result;
    9440  }
    9441 
    9469  basic_json unflatten() const
    9470  {
    9471  return json_pointer::unflatten(*this);
    9472  }
    9475 
    9477  // JSON Patch functions //
    9479 
    9482 
    9519  basic_json patch(const basic_json& json_patch) const
    9520  {
    9521  // make a working copy to apply the patch to
    9522  basic_json result = *this;
    9524  // the valid JSON Patch operations
    9525  enum class patch_operations {add, remove, replace, move, copy, test, invalid};
    9526 
    9527  const auto get_op = [](const std::string op)
    9528  {
    9529  if (op == "add")
    9530  {
    9531  return patch_operations::add;
    9532  }
    9533  if (op == "remove")
    9534  {
    9535  return patch_operations::remove;
    9536  }
    9537  if (op == "replace")
    9538  {
    9539  return patch_operations::replace;
    9540  }
    9541  if (op == "move")
    9542  {
    9543  return patch_operations::move;
    9544  }
    9545  if (op == "copy")
    9546  {
    9547  return patch_operations::copy;
    9548  }
    9549  if (op == "test")
    9550  {
    9551  return patch_operations::test;
    9552  }
    9553 
    9554  return patch_operations::invalid;
    9555  };
    9556 
    9557  // wrapper for "add" operation; add value at ptr
    9558  const auto operation_add = [&result](json_pointer & ptr, basic_json val)
    9559  {
    9560  // adding to the root of the target document means replacing it
    9561  if (ptr.is_root())
    9562  {
    9563  result = val;
    9564  }
    9565  else
    9566  {
    9567  // make sure the top element of the pointer exists
    9568  json_pointer top_pointer = ptr.top();
    9569  if (top_pointer != ptr)
    9570  {
    9571  basic_json& x = result.at(top_pointer);
    9572  }
    9573 
    9574  // get reference to parent of JSON pointer ptr
    9575  const auto last_path = ptr.pop_back();
    9576  basic_json& parent = result[ptr];
    9577 
    9578  switch (parent.m_type)
    9579  {
    9580  case value_t::null:
    9581  case value_t::object:
    9582  {
    9583  // use operator[] to add value
    9584  parent[last_path] = val;
    9585  break;
    9586  }
    9587 
    9588  case value_t::array:
    9589  {
    9590  if (last_path == "-")
    9591  {
    9592  // special case: append to back
    9593  parent.push_back(val);
    9594  }
    9595  else
    9596  {
    9597  const auto idx = std::stoi(last_path);
    9598  if (static_cast<size_type>(idx) > parent.size())
    9599  {
    9600  // avoid undefined behavior
    9601  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    9602  }
    9603  else
    9604  {
    9605  // default case: insert add offset
    9606  parent.insert(parent.begin() + static_cast<difference_type>(idx), val);
    9607  }
    9608  }
    9609  break;
    9610  }
    9611 
    9612  default:
    9613  {
    9614  // if there exists a parent it cannot be primitive
    9615  assert(false); // LCOV_EXCL_LINE
    9616  }
    9617  }
    9618  }
    9619  };
    9620 
    9621  // wrapper for "remove" operation; remove value at ptr
    9622  const auto operation_remove = [&result](json_pointer & ptr)
    9623  {
    9624  // get reference to parent of JSON pointer ptr
    9625  const auto last_path = ptr.pop_back();
    9626  basic_json& parent = result.at(ptr);
    9627 
    9628  // remove child
    9629  if (parent.is_object())
    9630  {
    9631  // perform range check
    9632  auto it = parent.find(last_path);
    9633  if (it != parent.end())
    9634  {
    9635  parent.erase(it);
    9636  }
    9637  else
    9638  {
    9639  throw std::out_of_range("key '" + last_path + "' not found");
    9640  }
    9641  }
    9642  else if (parent.is_array())
    9643  {
    9644  // note erase performs range check
    9645  parent.erase(static_cast<size_type>(std::stoi(last_path)));
    9646  }
    9647  };
    9648 
    9649  // type check
    9650  if (not json_patch.is_array())
    9651  {
    9652  // a JSON patch must be an array of objects
    9653  throw std::invalid_argument("JSON patch must be an array of objects");
    9654  }
    9655 
    9656  // iterate and apply th eoperations
    9657  for (const auto& val : json_patch)
    9658  {
    9659  // wrapper to get a value for an operation
    9660  const auto get_value = [&val](const std::string & op,
    9661  const std::string & member,
    9662  bool string_type) -> basic_json&
    9663  {
    9664  // find value
    9665  auto it = val.m_value.object->find(member);
    9666 
    9667  // context-sensitive error message
    9668  const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'";
    9669 
    9670  // check if desired value is present
    9671  if (it == val.m_value.object->end())
    9672  {
    9673  throw std::invalid_argument(error_msg + " must have member '" + member + "'");
    9674  }
    9675 
    9676  // check if result is of type string
    9677  if (string_type and not it->second.is_string())
    9678  {
    9679  throw std::invalid_argument(error_msg + " must have string member '" + member + "'");
    9680  }
    9681 
    9682  // no error: return value
    9683  return it->second;
    9684  };
    9685 
    9686  // type check
    9687  if (not val.is_object())
    9688  {
    9689  throw std::invalid_argument("JSON patch must be an array of objects");
    9690  }
    9691 
    9692  // collect mandatory members
    9693  const std::string op = get_value("op", "op", true);
    9694  const std::string path = get_value(op, "path", true);
    9695  json_pointer ptr(path);
    9696 
    9697  switch (get_op(op))
    9698  {
    9699  case patch_operations::add:
    9700  {
    9701  operation_add(ptr, get_value("add", "value", false));
    9702  break;
    9703  }
    9704 
    9705  case patch_operations::remove:
    9706  {
    9707  operation_remove(ptr);
    9708  break;
    9709  }
    9710 
    9711  case patch_operations::replace:
    9712  {
    9713  // the "path" location must exist - use at()
    9714  result.at(ptr) = get_value("replace", "value", false);
    9715  break;
    9716  }
    9717 
    9718  case patch_operations::move:
    9719  {
    9720  const std::string from_path = get_value("move", "from", true);
    9721  json_pointer from_ptr(from_path);
    9722 
    9723  // the "from" location must exist - use at()
    9724  basic_json v = result.at(from_ptr);
    9725 
    9726  // The move operation is functionally identical to a
    9727  // "remove" operation on the "from" location, followed
    9728  // immediately by an "add" operation at the target
    9729  // location with the value that was just removed.
    9730  operation_remove(from_ptr);
    9731  operation_add(ptr, v);
    9732  break;
    9733  }
    9734 
    9735  case patch_operations::copy:
    9736  {
    9737  const std::string from_path = get_value("copy", "from", true);;
    9738  const json_pointer from_ptr(from_path);
    9739 
    9740  // the "from" location must exist - use at()
    9741  result[ptr] = result.at(from_ptr);
    9742  break;
    9743  }
    9744 
    9745  case patch_operations::test:
    9746  {
    9747  bool success = false;
    9748  try
    9749  {
    9750  // check if "value" matches the one at "path"
    9751  // the "path" location must exist - use at()
    9752  success = (result.at(ptr) == get_value("test", "value", false));
    9753  }
    9754  catch (std::out_of_range&)
    9755  {
    9756  // ignore out of range errors: success remains false
    9757  }
    9758 
    9759  // throw an exception if test fails
    9760  if (not success)
    9761  {
    9762  throw std::domain_error("unsuccessful: " + val.dump());
    9763  }
    9764 
    9765  break;
    9766  }
    9767 
    9768  case patch_operations::invalid:
    9769  {
    9770  // op must be "add", "remove", "replace", "move", "copy", or
    9771  // "test"
    9772  throw std::invalid_argument("operation value '" + op + "' is invalid");
    9773  }
    9774  }
    9775  }
    9776 
    9777  return result;
    9778  }
    9779 
    9812  static basic_json diff(const basic_json& source,
    9813  const basic_json& target,
    9814  std::string path = "")
    9815  {
    9816  // the patch
    9817  basic_json result(value_t::array);
    9818 
    9819  // if the values are the same, return empty patch
    9820  if (source == target)
    9821  {
    9822  return result;
    9823  }
    9824 
    9825  if (source.type() != target.type())
    9826  {
    9827  // different types: replace value
    9828  result.push_back(
    9829  {
    9830  {"op", "replace"},
    9831  {"path", path},
    9832  {"value", target}
    9833  });
    9834  }
    9835  else
    9836  {
    9837  switch (source.type())
    9838  {
    9839  case value_t::array:
    9840  {
    9841  // first pass: traverse common elements
    9842  size_t i = 0;
    9843  while (i < source.size() and i < target.size())
    9844  {
    9845  // recursive call to compare array values at index i
    9846  auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
    9847  result.insert(result.end(), temp_diff.begin(), temp_diff.end());
    9848  ++i;
    9849  }
    9850 
    9851  // i now reached the end of at least one array
    9852  // in a second pass, traverse the remaining elements
    9853 
    9854  // remove my remaining elements
    9855  const auto end_index = static_cast<difference_type>(result.size());
    9856  while (i < source.size())
    9857  {
    9858  // add operations in reverse order to avoid invalid
    9859  // indices
    9860  result.insert(result.begin() + end_index, object(
    9861  {
    9862  {"op", "remove"},
    9863  {"path", path + "/" + std::to_string(i)}
    9864  }));
    9865  ++i;
    9866  }
    9867 
    9868  // add other remaining elements
    9869  while (i < target.size())
    9870  {
    9871  result.push_back(
    9872  {
    9873  {"op", "add"},
    9874  {"path", path + "/" + std::to_string(i)},
    9875  {"value", target[i]}
    9876  });
    9877  ++i;
    9878  }
    9879 
    9880  break;
    9881  }
    9882 
    9883  case value_t::object:
    9884  {
    9885  // first pass: traverse this object's elements
    9886  for (auto it = source.begin(); it != source.end(); ++it)
    9887  {
    9888  // escape the key name to be used in a JSON patch
    9889  const auto key = json_pointer::escape(it.key());
    9890 
    9891  if (target.find(it.key()) != target.end())
    9892  {
    9893  // recursive call to compare object values at key it
    9894  auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key);
    9895  result.insert(result.end(), temp_diff.begin(), temp_diff.end());
    9896  }
    9897  else
    9898  {
    9899  // found a key that is not in o -> remove it
    9900  result.push_back(object(
    9901  {
    9902  {"op", "remove"},
    9903  {"path", path + "/" + key}
    9904  }));
    9905  }
    9906  }
    9907 
    9908  // second pass: traverse other object's elements
    9909  for (auto it = target.begin(); it != target.end(); ++it)
    9910  {
    9911  if (source.find(it.key()) == source.end())
    9912  {
    9913  // found a key that is not in this -> add it
    9914  const auto key = json_pointer::escape(it.key());
    9915  result.push_back(
    9916  {
    9917  {"op", "add"},
    9918  {"path", path + "/" + key},
    9919  {"value", it.value()}
    9920  });
    9921  }
    9922  }
    9923 
    9924  break;
    9925  }
    9926 
    9927  default:
    9928  {
    9929  // both primitive type: replace value
    9930  result.push_back(
    9931  {
    9932  {"op", "replace"},
    9933  {"path", path},
    9934  {"value", target}
    9935  });
    9936  break;
    9937  }
    9938  }
    9939  }
    9940 
    9941  return result;
    9942  }
    9943 
    9945 };
    9946 
    9947 
    9949 // presets //
    9951 
    9960 using json = basic_json<>;
    9961 }
    9962 
    9963 
    9965 // nonmember support //
    9967 
    9968 // specialization of std::swap, and std::hash
    9969 namespace std
    9970 {
    9976 template <>
    9977 inline void swap(nlohmann::json& j1,
    9978  nlohmann::json& j2) noexcept(
    9979  is_nothrow_move_constructible<nlohmann::json>::value and
    9980  is_nothrow_move_assignable<nlohmann::json>::value
    9981  )
    9982 {
    9983  j1.swap(j2);
    9984 }
    9985 
    9987 template <>
    9988 struct hash<nlohmann::json>
    9989 {
    9995  std::size_t operator()(const nlohmann::json& j) const
    9996  {
    9997  // a naive hashing via the string representation
    9998  const auto& h = hash<nlohmann::json::string_t>();
    9999  return h(j.dump());
    10000  }
    10001 };
    10002 }
    10003 
    10016 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    10017 {
    10018  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    10019 }
    10020 
    10026 inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t)
    10027 {
    10028  return nlohmann::json::json_pointer(s);
    10029 }
    10030 
    10031 // restore GCC/clang diagnostic settings
    10032 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    10033  #pragma GCC diagnostic pop
    10034 #endif
    10035 
    10036 #endif
    const_iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6384
    +
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5571
    basic_json(const value_t value_type)
    create an empty value with a given type
    Definition: json.hpp:967
    basic_json(const array_t &val)
    create an array (explicit)
    Definition: json.hpp:1104
    -
    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:4079
    -
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:3270
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:7020
    -
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:7082
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4630
    -
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6670
    -
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:7076
    -
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3402
    -
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5782
    -
    constexpr bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2347
    -
    const_reverse_iterator rend() const noexcept
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4306
    -
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6978
    +
    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:4081
    +
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:3272
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:7024
    +
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:7086
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4632
    +
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6674
    +
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:7080
    +
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3404
    +
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5789
    +
    constexpr bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2349
    +
    const_reverse_iterator rend() const noexcept
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4308
    +
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6982
    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:1685
    -
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6796
    +
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6800
    BooleanType boolean_t
    a type for a boolean
    Definition: json.hpp:467
    -
    const_iterator cbegin() const noexcept
    returns a const iterator to the first element
    Definition: json.hpp:4160
    -
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4816
    -
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6936
    +
    const_iterator cbegin() const noexcept
    returns a const iterator to the first element
    Definition: json.hpp:4162
    +
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4818
    +
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6940
    basic_json(const typename string_t::value_type *val)
    create a string (explicit)
    Definition: json.hpp:1197
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:7118
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:4031
    -
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:5407
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:7122
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:4033
    +
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:5409
    basic_json(const string_t &val)
    create a string (explicit)
    Definition: json.hpp:1173
    -
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4742
    -
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3984
    +
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4744
    +
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3986
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:394
    -
    reference front()
    access the first element
    Definition: json.hpp:3641
    -
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:5163
    -
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:7104
    -
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6754
    +
    reference front()
    access the first element
    Definition: json.hpp:3643
    +
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:5165
    +
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:7108
    +
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6758
    a class to store JSON values
    Definition: json.hpp:187
    basic_json(const int val) noexcept
    create an integer number from an enum type (explicit)
    Definition: json.hpp:1308
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:7131
    -
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:5386
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:7135
    +
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:5388
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:539
    -
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4948
    -
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:3177
    -
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6788
    -
    constexpr bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2369
    -
    constexpr bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2291
    -
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6903
    -
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5744
    -
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6596
    -
    const_iterator cend() const noexcept
    returns a const iterator to one past the last element
    Definition: json.hpp:4231
    +
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4950
    +
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:3179
    +
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6792
    +
    constexpr bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2371
    +
    constexpr bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2293
    +
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6907
    +
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5751
    +
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6600
    +
    const_iterator cend() const noexcept
    returns a const iterator to one past the last element
    Definition: json.hpp:4233
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:348
    STL namespace.
    NumberUnsignedType number_unsigned_t
    a type for a number (unsigned)
    Definition: json.hpp:611
    typename std::allocator_traits< allocator_type >::const_pointer const_pointer
    the type of an element const pointer
    Definition: json.hpp:231
    basic_json(const number_integer_t val) noexcept
    create an integer number (explicit)
    Definition: json.hpp:1279
    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:1645
    -
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4393
    +
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4395
    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:2000
    -
    constexpr value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:2131
    -
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:6366
    -
    json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
    create reverse iterator from iterator
    Definition: json.hpp:7053
    -
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2891
    -
    constexpr bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2413
    -
    reference back()
    access the last element
    Definition: json.hpp:3683
    +
    constexpr value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:2133
    +
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:6370
    +
    json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
    create reverse iterator from iterator
    Definition: json.hpp:7057
    +
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2893
    +
    constexpr bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2415
    +
    reference back()
    access the last element
    Definition: json.hpp:3685
    const value_type & const_reference
    the type of an element const reference
    Definition: json.hpp:218
    -
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:6370
    -
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4792
    -
    void push_back(std::initializer_list< basic_json > init)
    add an object to an object
    Definition: json.hpp:4847
    -
    json_pointer(const std::string &s="")
    create JSON pointer
    Definition: json.hpp:8756
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5707
    -
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3437
    -
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:5001
    +
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:6374
    +
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4794
    +
    void push_back(std::initializer_list< basic_json > init)
    add an object to an object
    Definition: json.hpp:4849
    +
    json_pointer(const std::string &s="")
    create JSON pointer
    Definition: json.hpp:8760
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5714
    +
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3439
    +
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:5003
    basic_json(std::nullptr_t) noexcept
    create a null object (explicitly)
    Definition: json.hpp:1019
    basic_json(InputIT first, InputIT last)
    construct a JSON container given an iterator range
    Definition: json.hpp:1755
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:7014
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:7018
    static allocator_type get_allocator()
    returns the allocator associated with the container
    Definition: json.hpp:248
    -
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3359
    -
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3519
    -
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:7096
    -
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4441
    +
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3361
    +
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3521
    +
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:7100
    +
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4443
    std::size_t size_type
    a type to represent container sizes
    Definition: json.hpp:223
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:7124
    -
    const_iterator(const iterator &other) noexcept
    copy constructor given a nonconst iterator
    Definition: json.hpp:6408
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:7128
    +
    const_iterator(const iterator &other) noexcept
    copy constructor given a nonconst iterator
    Definition: json.hpp:6412
    basic_json(const CompatibleArrayType &val)
    create an array (implicit)
    Definition: json.hpp:1144
    -
    constexpr bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:2232
    -
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:3081
    +
    constexpr bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:2234
    +
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:3083
    basic_json(size_type cnt, const basic_json &val)
    construct an array with count copies of given value
    Definition: json.hpp:1709
    -
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:7048
    -
    const_reverse_iterator crbegin() const noexcept
    returns a const reverse iterator to the last element
    Definition: json.hpp:4335
    -
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:5060
    +
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:7052
    +
    const_reverse_iterator crbegin() const noexcept
    returns a const reverse iterator to the last element
    Definition: json.hpp:4337
    +
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:5062
    typename std::allocator_traits< allocator_type >::pointer pointer
    the type of an element pointer
    Definition: json.hpp:229
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4892
    -
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5613
    -
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:5468
    -
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6956
    -
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6706
    -
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6948
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4894
    +
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5615
    +
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:5470
    +
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6960
    +
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6710
    +
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6952
    basic_json(basic_json &&other) noexcept
    move constructor
    Definition: json.hpp:1968
    -
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6633
    -
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:3129
    -
    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:6924
    +
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6637
    +
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:3131
    +
    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:6928
    object (unordered set of name/value pairs)
    -
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4571
    +
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4573
    ~basic_json()
    destructor
    Definition: json.hpp:2028
    -
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6963
    -
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:7000
    -
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6641
    +
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6967
    +
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:7004
    +
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6645
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:2097
    basic_json value_type
    the type of elements in a basic_json container
    Definition: json.hpp:213
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:918
    AllocatorType< basic_json > allocator_type
    the allocator type
    Definition: json.hpp:226
    StringType string_t
    a type for a string
    Definition: json.hpp:441
    -
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4766
    -
    reference operator+=(std::initializer_list< basic_json > init)
    add an object to an object
    Definition: json.hpp:4864
    -
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6804
    +
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4768
    +
    reference operator+=(std::initializer_list< basic_json > init)
    add an object to an object
    Definition: json.hpp:4866
    +
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6808
    value_type & reference
    the type of an element reference
    Definition: json.hpp:216
    -
    const_reverse_iterator rbegin() const noexcept
    returns a const reverse iterator to the last element
    Definition: json.hpp:4269
    -
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5668
    -
    constexpr bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2440
    -
    const_iterator begin() const noexcept
    returns a const iterator to the first element
    Definition: json.hpp:4130
    -
    difference_type operator-(const iterator &other) const
    return difference
    Definition: json.hpp:7008
    -
    constexpr bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2391
    -
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6919
    +
    const_reverse_iterator rbegin() const noexcept
    returns a const reverse iterator to the last element
    Definition: json.hpp:4271
    +
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5675
    +
    constexpr bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2442
    +
    const_iterator begin() const noexcept
    returns a const iterator to the first element
    Definition: json.hpp:4132
    +
    difference_type operator-(const iterator &other) const
    return difference
    Definition: json.hpp:7012
    +
    constexpr bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2393
    +
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6923
    namespace for Niels Lohmann
    Definition: json.hpp:67
    -
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:6368
    -
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:5197
    +
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:6372
    +
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:5199
    basic_json(const CompatibleNumberIntegerType val) noexcept
    create an integer number (implicit)
    Definition: json.hpp:1345
    -
    const_reference front() const
    access the first element
    Definition: json.hpp:3649
    -
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6742
    -
    constexpr const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2906
    -
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6561
    - +
    const_reference front() const
    access the first element
    Definition: json.hpp:3651
    +
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6746
    +
    constexpr const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2908
    +
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6565
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:679
    -
    const_reverse_iterator crend() const noexcept
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4364
    -
    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:5098
    +
    const_reverse_iterator crend() const noexcept
    returns a const reverse iterator to one before the first
    Definition: json.hpp:4366
    +
    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:5100
    value_t
    the JSON type enumeration
    Definition: json.hpp:698
    -
    reverse_iterator rbegin() noexcept
    returns an iterator to the reverse-beginning
    Definition: json.hpp:4261
    -
    constexpr bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:2210
    +
    reverse_iterator rbegin() noexcept
    returns an iterator to the reverse-beginning
    Definition: json.hpp:4263
    +
    constexpr bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:2212
    std::ptrdiff_t difference_type
    a type to represent differences between iterators
    Definition: json.hpp:221
    -
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2807
    -
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:5129
    -
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3859
    -
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3586
    -
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:7050
    -
    const_reference back() const
    access the last element
    Definition: json.hpp:3693
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4706
    +
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2809
    +
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:5131
    +
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3861
    +
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3588
    +
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:7054
    +
    const_reference back() const
    access the last element
    Definition: json.hpp:3695
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4708
    array (ordered collection of values)
    -
    constexpr bool is_number_unsigned() const noexcept
    return whether value is an unsigned integer number
    Definition: json.hpp:2319
    -
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:7069
    -
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5736
    -
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:5278
    -
    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:3612
    -
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2957
    +
    constexpr bool is_number_unsigned() const noexcept
    return whether value is an unsigned integer number
    Definition: json.hpp:2321
    +
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:7073
    +
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5743
    +
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:5280
    +
    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:3614
    +
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2959
    basic_json(const CompatibleNumberUnsignedType val) noexcept
    create an unsigned number (implicit)
    Definition: json.hpp:1404
    -
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6521
    +
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6525
    -
    friend bool operator<(const value_t lhs, const value_t rhs) noexcept
    comparison operator for JSON types
    Definition: json.hpp:5231
    +
    friend bool operator<(const value_t lhs, const value_t rhs) noexcept
    comparison operator for JSON types
    Definition: json.hpp:5233
    basic_json(const number_float_t val) noexcept
    create a floating-point number (explicit)
    Definition: json.hpp:1433
    -
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:5430
    -
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6992
    +
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:5432
    +
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6996
    basic_json(const CompatibleNumberFloatType val) noexcept
    create an floating-point number (implicit)
    Definition: json.hpp:1480
    -
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6736
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3751
    +
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6740
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3753
    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:1553
    -
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6914
    -
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:5439
    -
    constexpr bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:2161
    -
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6604
    -
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6942
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6879
    -
    constexpr bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:2188
    -
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:6374
    +
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6918
    +
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:5441
    +
    constexpr bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:2163
    +
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6608
    +
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6946
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6883
    +
    constexpr bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:2190
    +
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:6378
    basic_json(boolean_t val) noexcept
    create a boolean (explicit)
    Definition: json.hpp:1246
    -
    iterator end() noexcept
    returns an iterator to one past the last element
    Definition: json.hpp:4191
    -
    reverse_iterator rend() noexcept
    returns an iterator to the reverse-end
    Definition: json.hpp:4298
    -
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:7112
    -
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:4048
    -
    iterator begin() noexcept
    returns an iterator to the first element
    Definition: json.hpp:4120
    +
    iterator end() noexcept
    returns an iterator to one past the last element
    Definition: json.hpp:4193
    +
    reverse_iterator rend() noexcept
    returns an iterator to the reverse-end
    Definition: json.hpp:4300
    +
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:7116
    +
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:4050
    +
    iterator begin() noexcept
    returns an iterator to the first element
    Definition: json.hpp:4122
    basic_json(const CompatibleObjectType &val)
    create an object (implicit)
    Definition: json.hpp:1077
    -
    const_iterator end() const noexcept
    returns a const iterator to one past the last element
    Definition: json.hpp:4201
    -
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5591
    -
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6748
    -
    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:6441
    -
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3946
    -
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3311
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6864
    -
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4732
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6828
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:6359
    -
    constexpr bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2262
    +
    const_iterator end() const noexcept
    returns a const iterator to one past the last element
    Definition: json.hpp:4203
    +
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5593
    +
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6752
    +
    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:6445
    +
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3948
    +
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3313
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6868
    +
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4734
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6832
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:6363
    +
    constexpr bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2264
    a template for a reverse iterator class
    Definition: json.hpp:202
    basic_json(std::istream &i, parser_callback_t cb=nullptr)
    construct a JSON value given an input stream
    Definition: json.hpp:1862
    -
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:6372
    -
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:7063
    -
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:5377
    -
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:3224
    -
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6700
    -
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:7089
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:3037
    -
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4505
    -
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4385
    -
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6985
    +
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:6376
    +
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:7067
    +
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:5379
    +
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:3226
    +
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6704
    +
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:7093
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:3039
    +
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4507
    +
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4387
    +
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6989
    basic_json(const object_t &val)
    create an object (explicit)
    Definition: json.hpp:1042
    basic_json(const number_unsigned_t val) noexcept
    create an unsigned integer number (explicit)
    Definition: json.hpp:1373
    -
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5772
    -
    json_reverse_iterator(const base_iterator &it) noexcept
    create reverse iterator from base class
    Definition: json.hpp:7058
    -
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5650
    -
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6436
    -
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6971
    -
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4919
    -
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2942
    -
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6782
    +
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5779
    +
    json_reverse_iterator(const base_iterator &it) noexcept
    create reverse iterator from base class
    Definition: json.hpp:7062
    +
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5652
    +
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6440
    +
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6975
    +
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4921
    +
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2944
    +
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6786
    basic_json(const CompatibleStringType &val)
    create a string (implicit)
    Definition: json.hpp:1228
    basic_json(const basic_json &other)
    copy constructor
    Definition: json.hpp:1893
    -
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3470
    +
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3472
    parse_event_t
    JSON callback events.
    Definition: json.hpp:853
    diff --git a/namespacemembers.html b/namespacemembers.html index fa04145f1..53a62c114 100644 --- a/namespacemembers.html +++ b/namespacemembers.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -94,7 +94,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    diff --git a/namespacemembers_type.html b/namespacemembers_type.html index 386719870..b81916dc4 100644 --- a/namespacemembers_type.html +++ b/namespacemembers_type.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -94,7 +94,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/namespacenlohmann.html b/namespacenlohmann.html index 5d01935c7..85321812c 100644 --- a/namespacenlohmann.html +++ b/namespacenlohmann.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -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 c1c0e4131..c2aba8ecf 100644 --- a/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html +++ b/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -108,7 +108,7 @@ Classes diff --git a/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html b/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html index 7e1d6fe75..29eeb7974 100644 --- a/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html +++ b/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -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 9960 of file json.hpp.

    +

    Definition at line 9964 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 da1db64f4..a6cc36f41 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 @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -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 e36929fe8..398c03853 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -111,11 +111,11 @@ Public Member Functions struct std::hash< nlohmann::json > -

    Definition at line 9988 of file json.hpp.

    +

    Definition at line 9992 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 8865ca741..bb5e72989 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 @@ -25,7 +25,7 @@
    JSON for Modern C++ -  2.0.0 +  2.0.1
    @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    Since
    version 1.0.0
    -

    Definition at line 9995 of file json.hpp.

    +

    Definition at line 9999 of file json.hpp.

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