From 03e077bccfaa6ee6eb5fa6ff933ed59df95030ff Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 24 Jan 2016 22:34:43 +0100 Subject: [PATCH] Update --- annotated.html | 2 +- classes.html | 2 +- classnlohmann_1_1basic__json-members.html | 2 +- classnlohmann_1_1basic__json.html | 4 +- ...asic__json_1_1const__iterator-members.html | 2 +- ...ann_1_1basic__json_1_1const__iterator.html | 4 +- ...tor_a019087161350d393f3e4ac841cdd3dbd.html | 4 +- ...tor_a17e5f5d3598e6901f3c1c1f7dc60589f.html | 4 +- ...tor_a1cba94e5a67ee52bc66b898a4e08359d.html | 4 +- ...tor_a211523a57024a43965862b497b89ab91.html | 4 +- ...tor_a301749e9779adafd395369ac36df93df.html | 4 +- ...tor_a36086a699b95e06976c11367b7d6ba53.html | 4 +- ...tor_a4632d8307fc315f21e2ecc9ba5aa6346.html | 4 +- ...tor_a4f7ac43b0ab34c387b1ae1a8e9c08467.html | 4 +- ...tor_a5aff013c03c1bdc248346c249bec7b67.html | 4 +- ...tor_a62cad59e006eb7fa594c2c5b65a76610.html | 4 +- ...tor_a67848d4b7bfa576434ad9807147b5870.html | 4 +- ...tor_a6b3e43d2f45fa611825dbdf4e88fffe2.html | 4 +- ...tor_a83454954e4e16be3d5316f9322e91a34.html | 4 +- ...tor_a86a1771e6658d0b14868df6c197d2353.html | 2 +- ...tor_a8d024cbc99db0d8106899f9fd9973735.html | 4 +- ...tor_ab74b39747a9dad60650a57133fca85b3.html | 4 +- ...tor_ab7dacd8e3ee9b3756bfcdb87dd55a515.html | 4 +- ...tor_ab9d31bf0d0b4d7310c858a04ce84a52f.html | 4 +- ...tor_abb1921cbf0ad4036c83bc6303e22171f.html | 4 +- ...tor_abbacd95955c602efc9a58ed1ffdb46c4.html | 4 +- ...tor_ac36b9187de43721a4bf1b052578bb80b.html | 4 +- ...tor_ac634a659837f5aebc97125e031de23b5.html | 4 +- ...tor_acea5b75d1087e2a92833946d9dc547ff.html | 4 +- ...tor_ada3100cdb8700566051828f1355fa745.html | 4 +- ...tor_adb50d6043ace464d9f694869724d7fb2.html | 4 +- ...tor_adda9a4bd7f0edb9cb39dc0dca3d4a286.html | 4 +- ...tor_adf6f9d3f8f8d8b1ccedabb4f04c098ad.html | 4 +- ...tor_ae480d5c86e5e1129d53d1e19782017a6.html | 4 +- ...tor_aebd099d9a70ffe760242ef24046c9002.html | 4 +- ...tor_af34f68f1ce670e7f25ce267b2b1e64ab.html | 4 +- ...tor_af55564e391b23e41abe78bc4bbe4edcb.html | 4 +- ...nn_1_1basic__json_1_1iterator-members.html | 2 +- classnlohmann_1_1basic__json_1_1iterator.html | 4 +- ...tor_a037e5f3de196ff4cea8a95a8a4e35882.html | 4 +- ...tor_a0a43bd93e6e46645ed0b93d3af7bfe22.html | 4 +- ...tor_a0c0acb68cc2a50a0e8782f860184883f.html | 4 +- ...tor_a0eb7ac9b746fb6f931ae728f70f92a8e.html | 4 +- ...tor_a1220b360a07b0605f7d2f4b3cfd16736.html | 4 +- ...tor_a21d32a4547ba4cbadd8b435a6a0d0e1b.html | 4 +- ...tor_a302d810a0685f8d39368eaa65c833acf.html | 4 +- ...tor_a33277dbf06ac5c1e7102e26f6b5e2c00.html | 4 +- ...tor_a4ae612fa9eb59784047b40f0419db65d.html | 4 +- ...tor_a4f6e03ae3bb674ebf0b727f74957c12f.html | 2 +- ...tor_a6e91e9d94a0e14d2fc28cfdf3beac2b1.html | 4 +- ...tor_a7031e759ee52d1283aada0ff81108a5e.html | 4 +- ...tor_a94285e2ade0bfef829b81377bbbca6cf.html | 4 +- ...tor_a9fcfda575b08d0c73b6274cdbbe7f184.html | 4 +- ...tor_aa2bd10afdcfc70acb8eaabbd2f6496f0.html | 4 +- ...tor_ab220a0cc3fe410fbae4524208bd5834f.html | 4 +- ...tor_ab5cf753cb2f8ce53b9f3e54c39e50ee3.html | 4 +- ...tor_abaebf4e21956dd20d9f862fa5647d32d.html | 4 +- ...tor_af64127418c567660d92b1afdfe9676db.html | 4 +- ...tor_afe65b5a0572c7bfdd7ccc942bb8e9fe2.html | 4 +- ...on_1_1json__reverse__iterator-members.html | 2 +- ...asic__json_1_1json__reverse__iterator.html | 4 +- ...tor_a03e542423284327d3801cf078f1c2b44.html | 4 +- ...tor_a0b494ef7570d031216f907d2c85ec323.html | 4 +- ...tor_a15e9cf4c5a43238e82ab69c4a295c491.html | 4 +- ...tor_a1c84e6d1f047ab4105fa665f455158a7.html | 4 +- ...tor_a2a1dc92fbec862883c8b89755c787c99.html | 4 +- ...tor_a5ee9ec91a6ddcd8d72278d681361626f.html | 4 +- ...tor_a61d31531e0dfc5448e7fa15678b05bbe.html | 4 +- ...tor_a6bd38ed124df0332ba3263a9176b0101.html | 4 +- ...tor_a70086e392779ecbbc9e6845b2be126a0.html | 4 +- ...tor_aa82b48aee07baee284f8340b37ec6864.html | 4 +- ...tor_ab6245ab29d8481ef2a2351c02cc31d4d.html | 4 +- ...tor_ac427d8f61858c13b7c16649bfbf75e76.html | 4 +- ...tor_ad3d6837b6f97065625c6c65f62f4b6d4.html | 4 +- ...tor_ae988bd36b7d098b1157871f83b2d6265.html | 4 +- ...tor_af972fce017b24906236ab235857a11a8.html | 4 +- ...son_a01a2643289b69cd71d9b3f3fc209b748.html | 10 +- ...son_a0703ae5cbd2daac5e6c0ae01d3a1b114.html | 10 +- ...son_a07c9c38a1f01675759e05d5d34627343.html | 12 +- ...son_a088460b5d95f384a4f2ec9e52f4f66ba.html | 10 +- ...son_a0afa4512f03406db0d0432657e9c7361.html | 10 +- ...son_a0ff73601e88f8ace62ff0b453ebb9043.html | 10 +- ...son_a114095c452ca2f4ba976548df3da68be.html | 10 +- ...son_a11c3dd843c21c58daa651e84046a82af.html | 10 +- ...son_a122640e7e2db1814fc7bbb3c122ec76e.html | 10 +- ...son_a13e5642dbfa1602c937d295a085413cc.html | 4 +- ...son_a1683189bd539313b5559f07961166c8b.html | 4 +- ...son_a16a275d0201e9aedc87c933c764b8869.html | 10 +- ...son_a1b058496e6a67565a096233cd113505b.html | 16 +- ...son_a1dc0c521042807e216d11110d2f002ff.html | 8 +- ...son_a231b02148577b69a154b2ce2c87a5522.html | 4 +- ...son_a234f03dce002783748ca401a42bc6472.html | 14 +- ...son_a26b7e4876af25eae5800ce43f93aaef2.html | 10 +- ...son_a2adfc8d24bea3908398cbf325b5dc1d7.html | 12 +- ...son_a2f07bcf7e75c34396476dd1790f26ce8.html | 10 +- ...son_a2f1f7ca08995781acb63bd66b26ad1c1.html | 16 +- ...son_a3173944e7b1809a333def4078a0b92a3.html | 10 +- ...son_a317b01b0fba3ac458561f1634759ea3b.html | 4 +- ...son_a3287df6546c905fb0a5786deb4b1cf32.html | 10 +- ...son_a33f1632cfdbf460b4913f4e8a43dd9e4.html | 8 +- ...son_a34d6a60dd99e9f33b8273a1c8db5669b.html | 8 +- ...son_a3d4e4bab95b24ccab42ed37e0ede2d98.html | 10 +- ...son_a42f9133f978dde4cce5851b2c2434a0c.html | 10 +- ...son_a4361aa791f3980abb239e4155a3450cb.html | 12 +- ...son_a457fec897d7b6283c60ca236ebb1f5e8.html | 10 +- ...son_a48c8d153bc2fd1af655063a4b984feac.html | 10 +- ...son_a4943b7f16ddc4e0df33c0cae7ef14471.html | 12 +- ...son_a4ad3f27ecece8f644e8dca69a97eb67f.html | 12 +- ...son_a4bf695ddf4a00ea8feea2c725ec847f1.html | 12 +- ...son_a4d688b5ff534d3ab4e284b3191061529.html | 12 +- ...son_a5114ed5eb394a2805da0bd1acba95ae2.html | 10 +- ...son_a53a2abfdd4f72c7df5aba1155bf03e48.html | 10 +- ...son_a57703688bee6b9736ab3a430d8d246f2.html | 8 +- ...son_a57a96ab3ff1ce7b48a754129fb12c982.html | 12 +- ...son_a5a2d4dbcdbc8ea065b87daf52cd786b9.html | 6 +- ...son_a5c8bb5200f5eac10d31e26be46e5b1ac.html | 8 +- ...son_a5d428360d75a52f6af74751d1cc912c6.html | 10 +- ...son_a5e34c5435e557d0bf666bd7311211405.html | 8 +- ...son_a5f0aad50ed7e8aec3128fe018c18b3fe.html | 10 +- ...son_a5fd8b54389698edf0c08e2dd001f610b.html | 4 +- ...son_a60ca396028b8d9714c6e10efbf475af6.html | 8 +- ...son_a63691315292df8e1522b00d37ebb1ffc.html | 7 +- ...son_a652414dd930cb3af3b6f454cc535a23e.html | 10 +- ...son_a656939a3dc9a6047e4afacd9e11b83a6.html | 14 +- ...son_a66f936cfbd252f85bd3dc2598e37a64b.html | 10 +- ...son_a6944904b3b59769b1cf62ac2532cbe33.html | 4 +- ...son_a696ced74d8edc0b63a000a72907ab109.html | 10 +- ...son_a6a7f45095675ac6fd1d018a0e41874be.html | 14 +- ...son_a6b7428e8c1169497f47b81667001cbfb.html | 12 +- ...son_a6bbd3e72a870f1ba81ff6886b063b0fe.html | 4 +- ...son_a6dff6a02a2be250b8f8dc2f47be65544.html | 10 +- ...son_a6e2e21da48f5d9471716cd868a068327.html | 10 +- ...son_a71eba33d906745e66f340952b79fbce3.html | 4 +- ...son_a72442ccbb378b4464a24a2da1e784041.html | 10 +- ...son_a72ba20783ecb3eec98bd6a3b870d565c.html | 12 +- ...son_a74472977b798c7b7989e6e7cb960ecff.html | 10 +- ...son_a74a943800c7f103d0990d7eef82c6453.html | 8 +- ...son_a74ccfa471a0c061876b247f820f3c741.html | 18 +- ...son_a75a1754e0d39f33095d3102a8bdb9881.html | 14 +- ...son_a76cfc5062bf6223396ab82c753cd4634.html | 14 +- ...son_a7c08f966200af98db0313a3b517ce0a9.html | 12 +- ...son_a7c19a5c3be6cc755377ee41eade78baf.html | 12 +- ...son_a7d0db3b728d820d4984df78d97d2b104.html | 4 +- ...son_a7d1b990f2c12fecb57db1504fdadd0bb.html | 10 +- ...son_a7dab69b10b98e7bc694339720e37fb2b.html | 12 +- ...son_a7f97a91ad8f1d5cf0b9213bd24f247c4.html | 8 +- ...son_a80ceaa3bdd346292273b309e08525c1c.html | 4 +- ...son_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html | 10 +- ...son_a87db51b6b936fb2ea293cdbc8702dcb8.html | 8 +- ...son_a8b526709d395142b68d21abfbfff17c3.html | 10 +- ...son_a8c40cd9ead4de7c82f28268bdf0ec98a.html | 12 +- ...son_a8e34088252a3ee6b2377f3a1f26dd1ba.html | 8 +- ...son_a8e4e11999b4e7faa8f31f21164ebd65a.html | 4 +- ...son_a8fa74698f4061e18ec664009f3af1ddf.html | 14 +- ...son_a930e14150ffa067bcf56d35cb00271e1.html | 8 +- ...son_a960962c683909619d1d2fbbe856c022e.html | 10 +- ...son_a9730b9f7bc2150e641fe20198d4477c7.html | 8 +- ...son_a98e05a2c9b8f74bd60442772cddeee52.html | 8 +- ...son_a9993148cb0473365e52998c7315f9ada.html | 10 +- ...son_a9a73d1b71c9e913aa2888d8b40c72ee9.html | 10 +- ...son_a9c26c5d0f4a519c7236149b9aeb3ef9e.html | 10 +- ...son_a9f17a0690155e3a5603246ccec81499e.html | 10 +- ...son_aa0422e861b4cbd7cdcaad7a11a1304a9.html | 18 +- ...son_aa1f3b3f1dca79392d6727b81f9668c6c.html | 10 +- ...son_aa5413178b8041f7ac685dec4b040dd2c.html | 12 +- ...son_aa6a24b176f9599a21d662cc5f8e1ca76.html | 4 +- ...son_aa6c32f669a2e523666072003d0ea46f4.html | 8 +- ...son_aa71e977d31f470689883ac60d16ea4ac.html | 12 +- ...son_aabe4661644ea549089f0886c2551d2ac.html | 4 +- ...son_aac185a137428a7337aa620de07bfbbd7.html | 4 +- ...son_aacd442b66140c764c594ac8ad7dfd5b3.html | 8 +- ...son_aacf6c869f6a9c66ac1bc99e93f310044.html | 4 +- ...son_aad7eff162b0b991ef233503c592c1e2a.html | 8 +- ...son_aaf363408931d76472ded14017e59c9e8.html | 8 +- ...son_aafa839f2a74dc1b5060314b3423143b8.html | 4 +- ...son_ab14e3503305622fb5ab01a7f490916e8.html | 12 +- ...son_ab2162bc76e10d8736cab9b2039956054.html | 12 +- ...son_ab74b2398f29acc6ffbf48f1b8974a848.html | 8 +- ...son_ab7d60fb6cb8e8f5740e588f9dc953819.html | 8 +- ...son_ab9a20bd1d391e9cb968db50c246f728d.html | 10 +- ...son_ab9da2afc6f77295f25252725fde142a6.html | 10 +- ...son_abe8f3224ca4041908ddb466cb9caecf1.html | 10 +- ...son_ac160789f17d206a5404981ca0957e303.html | 8 +- ...son_ac4011bd0781e51afe4994d2b09fd27e9.html | 4 +- ...son_ac8163abe518595f19dbee68db1caaaf7.html | 10 +- ...son_ac82abedf356d252e0589850c3d8b35ba.html | 4 +- ...son_ac943391891fcde0a71a15ce990e0f7f4.html | 8 +- ...son_acd08f9179c8c1e9f2cd7575a724ce27e.html | 10 +- ...son_acdf4445333649ec94198f09a62144884.html | 12 +- ...son_ace8338e57fdb11e1955c2a0c2d782069.html | 4 +- ...son_ad1f617d29e8923dd40c89153f792b1bc.html | 10 +- ...son_ad2c4513cef5d8db760c4b2d871eea42c.html | 4 +- ...son_ad497cbc4f80c8d79662ee6e19bf145dd.html | 16 +- ...son_ad6734c2b91b1b77aa2b43b65c3619c05.html | 8 +- ...son_ad8e0c5d04f016d1b3ac7369e5c73bedf.html | 12 +- ...son_ada8e01109a60088e4db2a670d4903b54.html | 12 +- ...son_adbd4c16c9ac641b2a4736bc2c6787d83.html | 4 +- ...son_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html | 8 +- ...son_ade7bd6e0fe221fec9d3fa9b430f5ce76.html | 10 +- ...son_adeaef2ab021997a11a826c378c2365e1.html | 8 +- ...son_adf5dea6fa9d7075ff89ca0796ab47a7e.html | 8 +- ...son_ae347859ec88176ef76a0cbe5b4514fcf.html | 8 +- ...son_ae50f22a1c646b8627e88f1313cceffd4.html | 14 +- ...son_ae7e36437700ef7353ad9961c8dd16a95.html | 10 +- ...son_ae874cfc1746b560c53a03bcf5b7bbeed.html | 10 +- ...son_ae928414b2805cf6ef56b4e4f8d235416.html | 4 +- ...son_ae960d2d6bc7b94fe39cc5e9f106edfa9.html | 10 +- ...son_aea1c863b719b4ca5b77188c171bbfafe.html | 4 +- ...son_af073eec08d2e68924098aef09e9a10ba.html | 10 +- ...son_af0ebd1757acb971a6504b4acabf88584.html | 12 +- ...son_af127fb69c580c17821da5f5be57e3585.html | 8 +- ...son_af1e3f9e079136abca2530c8191c56292.html | 10 +- ...son_af2730bc8ffa6b28916875c13ee7b83f5.html | 16 +- ...son_af661bc209bf22097e2f76607a11b56bf.html | 10 +- ...son_af6b6050ccd906dddf7c9f47fe3ad62a5.html | 10 +- ...son_af709c079de0ac3507143ea2c60699bd0.html | 8 +- ...son_af74581d177dafc38df5a126ccd358999.html | 8 +- ...son_af7d0adc984d04fc70c3d29fcd63e096a.html | 12 +- ...son_afc4223b5ad03b1b76e925374a8fff98e.html | 10 +- dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- functions.html | 2 +- functions_0x7e.html | 2 +- functions_b.html | 2 +- functions_c.html | 2 +- functions_d.html | 2 +- functions_e.html | 2 +- functions_enum.html | 2 +- functions_f.html | 2 +- functions_func.html | 2 +- functions_g.html | 2 +- functions_i.html | 2 +- functions_j.html | 2 +- functions_k.html | 2 +- functions_m.html | 2 +- functions_n.html | 2 +- functions_o.html | 2 +- functions_p.html | 2 +- functions_r.html | 2 +- functions_rela.html | 2 +- functions_s.html | 2 +- functions_t.html | 2 +- functions_type.html | 2 +- functions_v.html | 2 +- graph_legend.html | 2 +- hierarchy.html | 2 +- index.html | 2 +- json_8hpp_source.html | 408 +++++++++--------- namespacemembers.html | 2 +- namespacemembers_type.html | 2 +- namespacenlohmann.html | 2 +- ..._1anonymous__namespace_02json_8hpp_03.html | 2 +- ...ann_a2bfd99e845a2e5cd90aeaf1b1431f474.html | 4 +- ...ash_3_01nlohmann_1_1json_01_4-members.html | 2 +- ...std_1_1hash_3_01nlohmann_1_1json_01_4.html | 4 +- ...1_4_afd03f6ad53db22868ca4163a8200b2f9.html | 4 +- 255 files changed, 1056 insertions(+), 1055 deletions(-) diff --git a/annotated.html b/annotated.html index feddffdcf..718aece03 100644 --- a/annotated.html +++ b/annotated.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classes.html b/classes.html index 87f2543dc..7ff5e3ec5 100644 --- a/classes.html +++ b/classes.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json-members.html b/classnlohmann_1_1basic__json-members.html index f2410aba8..ef9752bc9 100644 --- a/classnlohmann_1_1basic__json-members.html +++ b/classnlohmann_1_1basic__json-members.html @@ -240,7 +240,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json.html b/classnlohmann_1_1basic__json.html index 0df9ca799..5de47b3b3 100644 --- a/classnlohmann_1_1basic__json.html +++ b/classnlohmann_1_1basic__json.html @@ -674,11 +674,11 @@ class nlohmann::basic_json
See also
RFC 7159 http://rfc7159.net/rfc7159
Since
version 1.0.0
-

Definition at line 188 of file json.hpp.

+

Definition at line 191 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1const__iterator-members.html b/classnlohmann_1_1basic__json_1_1const__iterator-members.html index baa7f0239..65877aa2d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator-members.html @@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1const__iterator.html b/classnlohmann_1_1basic__json_1_1const__iterator.html index 4a08f771f..ef1df9465 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator.html @@ -215,11 +215,11 @@ class nlohmann::basic_json::const_iterator
Since
version 1.0.0
-

Definition at line 5832 of file json.hpp.

+

Definition at line 5852 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a019087161350d393f3e4ac841cdd3dbd.html b/classnlohmann_1_1basic__json_1_1const__iterator_a019087161350d393f3e4ac841cdd3dbd.html index e5240d596..8e08bf806 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a019087161350d393f3e4ac841cdd3dbd.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a019087161350d393f3e4ac841cdd3dbd.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6104 of file json.hpp.

+

Definition at line 6124 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_a17e5f5d3598e6901f3c1c1f7dc60589f.html b/classnlohmann_1_1basic__json_1_1const__iterator_a17e5f5d3598e6901f3c1c1f7dc60589f.html index 453b24216..7247ae662 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a17e5f5d3598e6901f3c1c1f7dc60589f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a17e5f5d3598e6901f3c1c1f7dc60589f.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6213 of file json.hpp.

+

Definition at line 6233 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_a1cba94e5a67ee52bc66b898a4e08359d.html b/classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html index d0a4cf4f4..7842eb330 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6299 of file json.hpp.

+

Definition at line 6319 of file json.hpp.

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

Definition at line 5912 of file json.hpp.

+

Definition at line 5932 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_a301749e9779adafd395369ac36df93df.html b/classnlohmann_1_1basic__json_1_1const__iterator_a301749e9779adafd395369ac36df93df.html index 2840a0258..424e363c9 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a301749e9779adafd395369ac36df93df.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a301749e9779adafd395369ac36df93df.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6032 of file json.hpp.

+

Definition at line 6052 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_a36086a699b95e06976c11367b7d6ba53.html b/classnlohmann_1_1basic__json_1_1const__iterator_a36086a699b95e06976c11367b7d6ba53.html index 7ea640b74..9477cb898 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a36086a699b95e06976c11367b7d6ba53.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a36086a699b95e06976c11367b7d6ba53.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6141 of file json.hpp.

+

Definition at line 6161 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_a4632d8307fc315f21e2ecc9ba5aa6346.html b/classnlohmann_1_1basic__json_1_1const__iterator_a4632d8307fc315f21e2ecc9ba5aa6346.html index 12c0f7285..10f6438bd 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a4632d8307fc315f21e2ecc9ba5aa6346.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a4632d8307fc315f21e2ecc9ba5aa6346.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5992 of file json.hpp.

+

Definition at line 6012 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_a4f7ac43b0ab34c387b1ae1a8e9c08467.html b/classnlohmann_1_1basic__json_1_1const__iterator_a4f7ac43b0ab34c387b1ae1a8e9c08467.html index c43aa5f38..e9a8b098e 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a4f7ac43b0ab34c387b1ae1a8e9c08467.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a4f7ac43b0ab34c387b1ae1a8e9c08467.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5843 of file json.hpp.

+

Definition at line 5863 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_a5aff013c03c1bdc248346c249bec7b67.html b/classnlohmann_1_1basic__json_1_1const__iterator_a5aff013c03c1bdc248346c249bec7b67.html index 7fbb2cf36..2587287ae 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a5aff013c03c1bdc248346c249bec7b67.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a5aff013c03c1bdc248346c249bec7b67.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5880 of file json.hpp.

+

Definition at line 5900 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_a62cad59e006eb7fa594c2c5b65a76610.html b/classnlohmann_1_1basic__json_1_1const__iterator_a62cad59e006eb7fa594c2c5b65a76610.html index aaa921b79..d94cb4dd6 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a62cad59e006eb7fa594c2c5b65a76610.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a62cad59e006eb7fa594c2c5b65a76610.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6267 of file json.hpp.

+

Definition at line 6287 of file json.hpp.

@@ -153,7 +153,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a67848d4b7bfa576434ad9807147b5870.html b/classnlohmann_1_1basic__json_1_1const__iterator_a67848d4b7bfa576434ad9807147b5870.html index a40158e6a..11160900a 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a67848d4b7bfa576434ad9807147b5870.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a67848d4b7bfa576434ad9807147b5870.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5839 of file json.hpp.

+

Definition at line 5859 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_a6b3e43d2f45fa611825dbdf4e88fffe2.html b/classnlohmann_1_1basic__json_1_1const__iterator_a6b3e43d2f45fa611825dbdf4e88fffe2.html index b72b7de70..ff0531f10 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a6b3e43d2f45fa611825dbdf4e88fffe2.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a6b3e43d2f45fa611825dbdf4e88fffe2.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6219 of file json.hpp.

+

Definition at line 6239 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_a83454954e4e16be3d5316f9322e91a34.html b/classnlohmann_1_1basic__json_1_1const__iterator_a83454954e4e16be3d5316f9322e91a34.html index 0db82635e..26c255dad 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a83454954e4e16be3d5316f9322e91a34.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a83454954e4e16be3d5316f9322e91a34.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5853 of file json.hpp.

+

Definition at line 5873 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_a86a1771e6658d0b14868df6c197d2353.html b/classnlohmann_1_1basic__json_1_1const__iterator_a86a1771e6658d0b14868df6c197d2353.html index ad9d838ac..53b4b3afe 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a86a1771e6658d0b14868df6c197d2353.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a86a1771e6658d0b14868df6c197d2353.html @@ -150,7 +150,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1const__iterator_a8d024cbc99db0d8106899f9fd9973735.html b/classnlohmann_1_1basic__json_1_1const__iterator_a8d024cbc99db0d8106899f9fd9973735.html index cf03845c0..effc18ad3 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_a8d024cbc99db0d8106899f9fd9973735.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_a8d024cbc99db0d8106899f9fd9973735.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6335 of file json.hpp.

+

Definition at line 6355 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_ab74b39747a9dad60650a57133fca85b3.html b/classnlohmann_1_1basic__json_1_1const__iterator_ab74b39747a9dad60650a57133fca85b3.html index 746145126..52b7a7117 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab74b39747a9dad60650a57133fca85b3.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab74b39747a9dad60650a57133fca85b3.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6225 of file json.hpp.

+

Definition at line 6245 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_ab7dacd8e3ee9b3756bfcdb87dd55a515.html b/classnlohmann_1_1basic__json_1_1const__iterator_ab7dacd8e3ee9b3756bfcdb87dd55a515.html index 0d84e7e10..428e7fc0c 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab7dacd8e3ee9b3756bfcdb87dd55a515.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab7dacd8e3ee9b3756bfcdb87dd55a515.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6350 of file json.hpp.

+

Definition at line 6370 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_ab9d31bf0d0b4d7310c858a04ce84a52f.html b/classnlohmann_1_1basic__json_1_1const__iterator_ab9d31bf0d0b4d7310c858a04ce84a52f.html index 1351132a5..ee235ee4c 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ab9d31bf0d0b4d7310c858a04ce84a52f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ab9d31bf0d0b4d7310c858a04ce84a52f.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6171 of file json.hpp.

+

Definition at line 6191 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_abb1921cbf0ad4036c83bc6303e22171f.html b/classnlohmann_1_1basic__json_1_1const__iterator_abb1921cbf0ad4036c83bc6303e22171f.html index 23650c8e1..ade71c011 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_abb1921cbf0ad4036c83bc6303e22171f.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_abb1921cbf0ad4036c83bc6303e22171f.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6112 of file json.hpp.

+

Definition at line 6132 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_abbacd95955c602efc9a58ed1ffdb46c4.html b/classnlohmann_1_1basic__json_1_1const__iterator_abbacd95955c602efc9a58ed1ffdb46c4.html index 9a2a51f91..a5aaf3f5d 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_abbacd95955c602efc9a58ed1ffdb46c4.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_abbacd95955c602efc9a58ed1ffdb46c4.html @@ -142,7 +142,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6075 of file json.hpp.

+

Definition at line 6095 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_ac36b9187de43721a4bf1b052578bb80b.html b/classnlohmann_1_1basic__json_1_1const__iterator_ac36b9187de43721a4bf1b052578bb80b.html index e11ea6765..509a0096f 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac36b9187de43721a4bf1b052578bb80b.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac36b9187de43721a4bf1b052578bb80b.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5841 of file json.hpp.

+

Definition at line 5861 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_ac634a659837f5aebc97125e031de23b5.html b/classnlohmann_1_1basic__json_1_1const__iterator_ac634a659837f5aebc97125e031de23b5.html index 1e3f7dd1c..665c02f0c 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ac634a659837f5aebc97125e031de23b5.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ac634a659837f5aebc97125e031de23b5.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6259 of file json.hpp.

+

Definition at line 6279 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_acea5b75d1087e2a92833946d9dc547ff.html b/classnlohmann_1_1basic__json_1_1const__iterator_acea5b75d1087e2a92833946d9dc547ff.html index 31d594f04..c0bd1d25b 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_acea5b75d1087e2a92833946d9dc547ff.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_acea5b75d1087e2a92833946d9dc547ff.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6177 of file json.hpp.

+

Definition at line 6197 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 d1a3776d7..6843d1354 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ada3100cdb8700566051828f1355fa745.html @@ -139,7 +139,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5835 of file json.hpp.

+

Definition at line 5855 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_adb50d6043ace464d9f694869724d7fb2.html b/classnlohmann_1_1basic__json_1_1const__iterator_adb50d6043ace464d9f694869724d7fb2.html index 578a1a91f..d5677e5b6 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_adb50d6043ace464d9f694869724d7fb2.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_adb50d6043ace464d9f694869724d7fb2.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5845 of file json.hpp.

+

Definition at line 5865 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_adda9a4bd7f0edb9cb39dc0dca3d4a286.html b/classnlohmann_1_1basic__json_1_1const__iterator_adda9a4bd7f0edb9cb39dc0dca3d4a286.html index bad553415..9be406ce1 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_adda9a4bd7f0edb9cb39dc0dca3d4a286.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_adda9a4bd7f0edb9cb39dc0dca3d4a286.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6275 of file json.hpp.

+

Definition at line 6295 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_adf6f9d3f8f8d8b1ccedabb4f04c098ad.html b/classnlohmann_1_1basic__json_1_1const__iterator_adf6f9d3f8f8d8b1ccedabb4f04c098ad.html index 93297dfee..5e4279083 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_adf6f9d3f8f8d8b1ccedabb4f04c098ad.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_adf6f9d3f8f8d8b1ccedabb4f04c098ad.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6067 of file json.hpp.

+

Definition at line 6087 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_ae480d5c86e5e1129d53d1e19782017a6.html b/classnlohmann_1_1basic__json_1_1const__iterator_ae480d5c86e5e1129d53d1e19782017a6.html index da1a7e89f..64aaa7fc9 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_ae480d5c86e5e1129d53d1e19782017a6.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_ae480d5c86e5e1129d53d1e19782017a6.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5847 of file json.hpp.

+

Definition at line 5867 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_aebd099d9a70ffe760242ef24046c9002.html b/classnlohmann_1_1basic__json_1_1const__iterator_aebd099d9a70ffe760242ef24046c9002.html index 0dfeb1585..c228db113 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_aebd099d9a70ffe760242ef24046c9002.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_aebd099d9a70ffe760242ef24046c9002.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6207 of file json.hpp.

+

Definition at line 6227 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_af34f68f1ce670e7f25ce267b2b1e64ab.html b/classnlohmann_1_1basic__json_1_1const__iterator_af34f68f1ce670e7f25ce267b2b1e64ab.html index 7ec51dd54..1d97da602 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_af34f68f1ce670e7f25ce267b2b1e64ab.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_af34f68f1ce670e7f25ce267b2b1e64ab.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6253 of file json.hpp.

+

Definition at line 6273 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_af55564e391b23e41abe78bc4bbe4edcb.html b/classnlohmann_1_1basic__json_1_1const__iterator_af55564e391b23e41abe78bc4bbe4edcb.html index 3f9b8c168..c60065423 100644 --- a/classnlohmann_1_1basic__json_1_1const__iterator_af55564e391b23e41abe78bc4bbe4edcb.html +++ b/classnlohmann_1_1basic__json_1_1const__iterator_af55564e391b23e41abe78bc4bbe4edcb.html @@ -143,7 +143,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 5907 of file json.hpp.

+

Definition at line 5927 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 16966aedb..0e4bb86ab 100644 --- a/classnlohmann_1_1basic__json_1_1iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1iterator-members.html @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1iterator.html b/classnlohmann_1_1basic__json_1_1iterator.html index fbe7bd57d..f1095e3d5 100644 --- a/classnlohmann_1_1basic__json_1_1iterator.html +++ b/classnlohmann_1_1basic__json_1_1iterator.html @@ -266,11 +266,11 @@ class nlohmann::basic_json::iterator
Since
version 1.0.0
-

Definition at line 6374 of file json.hpp.

+

Definition at line 6394 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1iterator_a037e5f3de196ff4cea8a95a8a4e35882.html b/classnlohmann_1_1basic__json_1_1iterator_a037e5f3de196ff4cea8a95a8a4e35882.html index eb1e14fa7..2ffd208d7 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a037e5f3de196ff4cea8a95a8a4e35882.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a037e5f3de196ff4cea8a95a8a4e35882.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6427 of file json.hpp.

+

Definition at line 6447 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_a0a43bd93e6e46645ed0b93d3af7bfe22.html b/classnlohmann_1_1basic__json_1_1iterator_a0a43bd93e6e46645ed0b93d3af7bfe22.html index d6b56e228..41da08eb5 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a0a43bd93e6e46645ed0b93d3af7bfe22.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a0a43bd93e6e46645ed0b93d3af7bfe22.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6456 of file json.hpp.

+

Definition at line 6476 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_a0c0acb68cc2a50a0e8782f860184883f.html b/classnlohmann_1_1basic__json_1_1iterator_a0c0acb68cc2a50a0e8782f860184883f.html index d25193e92..d7a86b90d 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a0c0acb68cc2a50a0e8782f860184883f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a0c0acb68cc2a50a0e8782f860184883f.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6471 of file json.hpp.

+

Definition at line 6491 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_a0eb7ac9b746fb6f931ae728f70f92a8e.html b/classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html index a258179da..da9575e2c 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6484 of file json.hpp.

+

Definition at line 6504 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_a1220b360a07b0605f7d2f4b3cfd16736.html b/classnlohmann_1_1basic__json_1_1iterator_a1220b360a07b0605f7d2f4b3cfd16736.html index ece7f26bf..dca5dcf7a 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a1220b360a07b0605f7d2f4b3cfd16736.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a1220b360a07b0605f7d2f4b3cfd16736.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6413 of file json.hpp.

+

Definition at line 6433 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_a21d32a4547ba4cbadd8b435a6a0d0e1b.html b/classnlohmann_1_1basic__json_1_1iterator_a21d32a4547ba4cbadd8b435a6a0d0e1b.html index 95f0a5b2f..bde4e368e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a21d32a4547ba4cbadd8b435a6a0d0e1b.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a21d32a4547ba4cbadd8b435a6a0d0e1b.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6442 of file json.hpp.

+

Definition at line 6462 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_a302d810a0685f8d39368eaa65c833acf.html b/classnlohmann_1_1basic__json_1_1iterator_a302d810a0685f8d39368eaa65c833acf.html index 9b7a69ec2..74ad36651 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a302d810a0685f8d39368eaa65c833acf.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a302d810a0685f8d39368eaa65c833acf.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6478 of file json.hpp.

+

Definition at line 6498 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_a33277dbf06ac5c1e7102e26f6b5e2c00.html b/classnlohmann_1_1basic__json_1_1iterator_a33277dbf06ac5c1e7102e26f6b5e2c00.html index 849e59a5a..4f932e51e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a33277dbf06ac5c1e7102e26f6b5e2c00.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a33277dbf06ac5c1e7102e26f6b5e2c00.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6407 of file json.hpp.

+

Definition at line 6427 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_a4ae612fa9eb59784047b40f0419db65d.html b/classnlohmann_1_1basic__json_1_1iterator_a4ae612fa9eb59784047b40f0419db65d.html index 5ae566336..923913d63 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a4ae612fa9eb59784047b40f0419db65d.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a4ae612fa9eb59784047b40f0419db65d.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6434 of file json.hpp.

+

Definition at line 6454 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_a4f6e03ae3bb674ebf0b727f74957c12f.html b/classnlohmann_1_1basic__json_1_1iterator_a4f6e03ae3bb674ebf0b727f74957c12f.html index 6a3fd912f..2d03bccd0 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a4f6e03ae3bb674ebf0b727f74957c12f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a4f6e03ae3bb674ebf0b727f74957c12f.html @@ -139,7 +139,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_1_1iterator_a6e91e9d94a0e14d2fc28cfdf3beac2b1.html b/classnlohmann_1_1basic__json_1_1iterator_a6e91e9d94a0e14d2fc28cfdf3beac2b1.html index c202c34d5..4f268348e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a6e91e9d94a0e14d2fc28cfdf3beac2b1.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a6e91e9d94a0e14d2fc28cfdf3beac2b1.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6395 of file json.hpp.

+

Definition at line 6415 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_a7031e759ee52d1283aada0ff81108a5e.html b/classnlohmann_1_1basic__json_1_1iterator_a7031e759ee52d1283aada0ff81108a5e.html index 49fc506cf..682d60b87 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a7031e759ee52d1283aada0ff81108a5e.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a7031e759ee52d1283aada0ff81108a5e.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6449 of file json.hpp.

+

Definition at line 6469 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_a94285e2ade0bfef829b81377bbbca6cf.html b/classnlohmann_1_1basic__json_1_1iterator_a94285e2ade0bfef829b81377bbbca6cf.html index 3b7405f31..69244706e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a94285e2ade0bfef829b81377bbbca6cf.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a94285e2ade0bfef829b81377bbbca6cf.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6390 of file json.hpp.

+

Definition at line 6410 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_a9fcfda575b08d0c73b6274cdbbe7f184.html b/classnlohmann_1_1basic__json_1_1iterator_a9fcfda575b08d0c73b6274cdbbe7f184.html index 4eba072fe..18e3bc599 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_a9fcfda575b08d0c73b6274cdbbe7f184.html +++ b/classnlohmann_1_1basic__json_1_1iterator_a9fcfda575b08d0c73b6274cdbbe7f184.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6419 of file json.hpp.

+

Definition at line 6439 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_aa2bd10afdcfc70acb8eaabbd2f6496f0.html b/classnlohmann_1_1basic__json_1_1iterator_aa2bd10afdcfc70acb8eaabbd2f6496f0.html index a717ff799..8b6dfb658 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_aa2bd10afdcfc70acb8eaabbd2f6496f0.html +++ b/classnlohmann_1_1basic__json_1_1iterator_aa2bd10afdcfc70acb8eaabbd2f6496f0.html @@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6379 of file json.hpp.

+

Definition at line 6399 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_ab220a0cc3fe410fbae4524208bd5834f.html b/classnlohmann_1_1basic__json_1_1iterator_ab220a0cc3fe410fbae4524208bd5834f.html index f76cbd9eb..8232e511b 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab220a0cc3fe410fbae4524208bd5834f.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab220a0cc3fe410fbae4524208bd5834f.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6385 of file json.hpp.

+

Definition at line 6405 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_ab5cf753cb2f8ce53b9f3e54c39e50ee3.html b/classnlohmann_1_1basic__json_1_1iterator_ab5cf753cb2f8ce53b9f3e54c39e50ee3.html index e45f4e2be..a707cbd6e 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_ab5cf753cb2f8ce53b9f3e54c39e50ee3.html +++ b/classnlohmann_1_1basic__json_1_1iterator_ab5cf753cb2f8ce53b9f3e54c39e50ee3.html @@ -132,7 +132,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6463 of file json.hpp.

+

Definition at line 6483 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_abaebf4e21956dd20d9f862fa5647d32d.html b/classnlohmann_1_1basic__json_1_1iterator_abaebf4e21956dd20d9f862fa5647d32d.html index 07012287a..daf6787a1 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_abaebf4e21956dd20d9f862fa5647d32d.html +++ b/classnlohmann_1_1basic__json_1_1iterator_abaebf4e21956dd20d9f862fa5647d32d.html @@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6377 of file json.hpp.

+

Definition at line 6397 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_af64127418c567660d92b1afdfe9676db.html b/classnlohmann_1_1basic__json_1_1iterator_af64127418c567660d92b1afdfe9676db.html index 545998506..f2605b5ec 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_af64127418c567660d92b1afdfe9676db.html +++ b/classnlohmann_1_1basic__json_1_1iterator_af64127418c567660d92b1afdfe9676db.html @@ -131,7 +131,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6490 of file json.hpp.

+

Definition at line 6510 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_afe65b5a0572c7bfdd7ccc942bb8e9fe2.html b/classnlohmann_1_1basic__json_1_1iterator_afe65b5a0572c7bfdd7ccc942bb8e9fe2.html index 516615abc..6fc242a08 100644 --- a/classnlohmann_1_1basic__json_1_1iterator_afe65b5a0572c7bfdd7ccc942bb8e9fe2.html +++ b/classnlohmann_1_1basic__json_1_1iterator_afe65b5a0572c7bfdd7ccc942bb8e9fe2.html @@ -120,7 +120,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 6378 of file json.hpp.

+

Definition at line 6398 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_1json__reverse__iterator-members.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html index 986e01ce3..a4d655841 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator-members.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html index ae5a44c9e..0d39a1eba 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html @@ -170,11 +170,11 @@ class nlohmann::basic_json::json_reverse_iterator< Base >
Since
version 1.0.0
-

Definition at line 233 of file json.hpp.

+

Definition at line 234 of file json.hpp.

diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a03e542423284327d3801cf078f1c2b44.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a03e542423284327d3801cf078f1c2b44.html index 2c1282097..260f2cc28 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a03e542423284327d3801cf078f1c2b44.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a03e542423284327d3801cf078f1c2b44.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6574 of file json.hpp.

+

Definition at line 6594 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a0b494ef7570d031216f907d2c85ec323.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a0b494ef7570d031216f907d2c85ec323.html index 744049a59..ed92968e0 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a0b494ef7570d031216f907d2c85ec323.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a0b494ef7570d031216f907d2c85ec323.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6523 of file json.hpp.

+

Definition at line 6543 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a15e9cf4c5a43238e82ab69c4a295c491.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a15e9cf4c5a43238e82ab69c4a295c491.html index 4bc0d1efd..9c82d89dd 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a15e9cf4c5a43238e82ab69c4a295c491.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a15e9cf4c5a43238e82ab69c4a295c491.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6539 of file json.hpp.

+

Definition at line 6559 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a1c84e6d1f047ab4105fa665f455158a7.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a1c84e6d1f047ab4105fa665f455158a7.html index 47968bf45..e5806794c 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a1c84e6d1f047ab4105fa665f455158a7.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a1c84e6d1f047ab4105fa665f455158a7.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6566 of file json.hpp.

+

Definition at line 6586 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a2a1dc92fbec862883c8b89755c787c99.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a2a1dc92fbec862883c8b89755c787c99.html index 432aa21ef..d1382faf1 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a2a1dc92fbec862883c8b89755c787c99.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a2a1dc92fbec862883c8b89755c787c99.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6559 of file json.hpp.

+

Definition at line 6579 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a5ee9ec91a6ddcd8d72278d681361626f.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a5ee9ec91a6ddcd8d72278d681361626f.html index 2b8e53645..8b639b2e6 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a5ee9ec91a6ddcd8d72278d681361626f.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a5ee9ec91a6ddcd8d72278d681361626f.html @@ -117,7 +117,7 @@ template<typename Base >
-

Definition at line 6520 of file json.hpp.

+

Definition at line 6540 of file json.hpp.

@@ -127,7 +127,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a61d31531e0dfc5448e7fa15678b05bbe.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a61d31531e0dfc5448e7fa15678b05bbe.html index d097a1823..59f10577e 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a61d31531e0dfc5448e7fa15678b05bbe.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a61d31531e0dfc5448e7fa15678b05bbe.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6601 of file json.hpp.

+

Definition at line 6621 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a6bd38ed124df0332ba3263a9176b0101.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a6bd38ed124df0332ba3263a9176b0101.html index 6bfb83016..6c6aae3c6 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a6bd38ed124df0332ba3263a9176b0101.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a6bd38ed124df0332ba3263a9176b0101.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6546 of file json.hpp.

+

Definition at line 6566 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a70086e392779ecbbc9e6845b2be126a0.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a70086e392779ecbbc9e6845b2be126a0.html index 1592d1447..aa17a080b 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a70086e392779ecbbc9e6845b2be126a0.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a70086e392779ecbbc9e6845b2be126a0.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6528 of file json.hpp.

+

Definition at line 6548 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aa82b48aee07baee284f8340b37ec6864.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aa82b48aee07baee284f8340b37ec6864.html index 08d6dbcff..55bcf3218 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aa82b48aee07baee284f8340b37ec6864.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_aa82b48aee07baee284f8340b37ec6864.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6533 of file json.hpp.

+

Definition at line 6553 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ab6245ab29d8481ef2a2351c02cc31d4d.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ab6245ab29d8481ef2a2351c02cc31d4d.html index 6a8c02c72..c8323a56f 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ab6245ab29d8481ef2a2351c02cc31d4d.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ab6245ab29d8481ef2a2351c02cc31d4d.html @@ -117,7 +117,7 @@ template<typename Base >
-

Definition at line 6518 of file json.hpp.

+

Definition at line 6538 of file json.hpp.

@@ -127,7 +127,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac427d8f61858c13b7c16649bfbf75e76.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac427d8f61858c13b7c16649bfbf75e76.html index e742a4a3f..3cf614739 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac427d8f61858c13b7c16649bfbf75e76.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ac427d8f61858c13b7c16649bfbf75e76.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6582 of file json.hpp.

+

Definition at line 6602 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad3d6837b6f97065625c6c65f62f4b6d4.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad3d6837b6f97065625c6c65f62f4b6d4.html index bd3549bc4..82a886ce2 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad3d6837b6f97065625c6c65f62f4b6d4.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ad3d6837b6f97065625c6c65f62f4b6d4.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6552 of file json.hpp.

+

Definition at line 6572 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html index 8bcb3cb3b..003af2591 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html @@ -129,7 +129,7 @@ template<typename Base >
-

Definition at line 6588 of file json.hpp.

+

Definition at line 6608 of file json.hpp.

@@ -139,7 +139,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_af972fce017b24906236ab235857a11a8.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_af972fce017b24906236ab235857a11a8.html index 05fca118d..bac792e0b 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_af972fce017b24906236ab235857a11a8.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_af972fce017b24906236ab235857a11a8.html @@ -128,7 +128,7 @@ template<typename Base >
-

Definition at line 6594 of file json.hpp.

+

Definition at line 6614 of file json.hpp.

@@ -138,7 +138,7 @@ template<typename Base > diff --git a/classnlohmann_1_1basic__json_a01a2643289b69cd71d9b3f3fc209b748.html b/classnlohmann_1_1basic__json_a01a2643289b69cd71d9b3f3fc209b748.html index ef4a5e64d..a75271f74 100644 --- a/classnlohmann_1_1basic__json_a01a2643289b69cd71d9b3f3fc209b748.html +++ b/classnlohmann_1_1basic__json_a01a2643289b69cd71d9b3f3fc209b748.html @@ -263,15 +263,15 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
-
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:3730
+
Example
The example shows how count is used.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
+
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:3739
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 3730 of file json.hpp.

+

Definition at line 3739 of file json.hpp.

@@ -281,7 +281,7 @@ number of elements with key "three": 0 diff --git a/classnlohmann_1_1basic__json_a0703ae5cbd2daac5e6c0ae01d3a1b114.html b/classnlohmann_1_1basic__json_a0703ae5cbd2daac5e6c0ae01d3a1b114.html index 9026ea193..a8b94205f 100644 --- a/classnlohmann_1_1basic__json_a0703ae5cbd2daac5e6c0ae01d3a1b114.html +++ b/classnlohmann_1_1basic__json_a0703ae5cbd2daac5e6c0ae01d3a1b114.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4298
+
namespace for Niels Lohmann
Definition: json.hpp:88
Output (play with this example online):
{"one":1,"two":2}
 null
 {"four":4,"one":1,"three":3,"two":2}
@@ -278,7 +278,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 4399 of file json.hpp.

+

Definition at line 4408 of file json.hpp.

@@ -288,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html b/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html index 511385af3..56ca410c4 100644 --- a/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html +++ b/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html @@ -281,16 +281,16 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
iterator begin()
returns an iterator to the first element
Definition: json.hpp:3765
-
namespace for Niels Lohmann
Definition: json.hpp:79
-
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4427
+
Example
The example shows how insert is used.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
iterator begin()
returns an iterator to the first element
Definition: json.hpp:3774
+
namespace for Niels Lohmann
Definition: json.hpp:88
+
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4436
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 4454 of file json.hpp.

+

Definition at line 4463 of file json.hpp.

@@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a088460b5d95f384a4f2ec9e52f4f66ba.html b/classnlohmann_1_1basic__json_a088460b5d95f384a4f2ec9e52f4f66ba.html index 9cd57342d..a31d4c938 100644 --- a/classnlohmann_1_1basic__json_a088460b5d95f384a4f2ec9e52f4f66ba.html +++ b/classnlohmann_1_1basic__json_a088460b5d95f384a4f2ec9e52f4f66ba.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

Returns
true if type is string, false otherwise.
Complexity
Constant.
-
Example
The following code exemplifies is_string for all JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 is_string()
17  std::cout << std::boolalpha;
18  std::cout << j_null.is_string() << '\n';
19  std::cout << j_boolean.is_string() << '\n';
20  std::cout << j_number_integer.is_string() << '\n';
21  std::cout << j_number_float.is_string() << '\n';
22  std::cout << j_object.is_string() << '\n';
23  std::cout << j_array.is_string() << '\n';
24  std::cout << j_string.is_string() << '\n';
25 }
a class to store JSON values
Definition: json.hpp:188
-
bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:2114
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The following code exemplifies is_string for all JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 is_string()
17  std::cout << std::boolalpha;
18  std::cout << j_null.is_string() << '\n';
19  std::cout << j_boolean.is_string() << '\n';
20  std::cout << j_number_integer.is_string() << '\n';
21  std::cout << j_number_float.is_string() << '\n';
22  std::cout << j_object.is_string() << '\n';
23  std::cout << j_array.is_string() << '\n';
24  std::cout << j_string.is_string() << '\n';
25 }
a class to store JSON values
Definition: json.hpp:191
+
bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:2123
+
namespace for Niels Lohmann
Definition: json.hpp:88
Output (play with this example online):
false
 false
 false
@@ -269,7 +269,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 2114 of file json.hpp.

+

Definition at line 2123 of file json.hpp.

@@ -279,7 +279,7 @@ true diff --git a/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html b/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html index cdd10cfed..a4967d0c1 100644 --- a/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html +++ b/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html @@ -284,9 +284,9 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
+
Example
The following code shows the constructor for different value_t values
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
object (unordered set of name/value pairs)
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
namespace for Niels Lohmann
Definition: json.hpp:88
array (ordered collection of values)
@@ -296,7 +296,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Output (play with this example online):
null
 false
 0
-0
+0.0
 {}
 []
 ""
@@ -316,7 +316,7 @@ false
 basic_json(const number_integer_t) – create a number (integer) value
Since
version 1.0.0
-

Definition at line 867 of file json.hpp.

+

Definition at line 876 of file json.hpp.

@@ -326,7 +326,7 @@ false diff --git a/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html b/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html index b1600c2d7..e32fa0761 100644 --- a/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html +++ b/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html @@ -272,8 +272,8 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The example below shows how object elements can be read and written using the [] operator.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
Output (play with this example online):
2
 
 {
@@ -297,9 +297,9 @@ template<typename T > 
See also
at(const typename object_t::key_type&) for access by reference with range checking
value() for access by value with a default value
-
Since
version 1.0.1
+
Since
version 1.1.0
-

Definition at line 3152 of file json.hpp.

+

Definition at line 3161 of file json.hpp.

@@ -309,7 +309,7 @@ template<typename T > diff --git a/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html b/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html index 8b2840291..cfa3bcb47 100644 --- a/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html +++ b/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

This function returns true iff the JSON value is null.

Returns
true if type is null, false otherwise.
Complexity
Constant.
-
Example
The following code exemplifies is_null for all JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 is_null()
17  std::cout << std::boolalpha;
18  std::cout << j_null.is_null() << '\n';
19  std::cout << j_boolean.is_null() << '\n';
20  std::cout << j_number_integer.is_null() << '\n';
21  std::cout << j_number_float.is_null() << '\n';
22  std::cout << j_object.is_null() << '\n';
23  std::cout << j_array.is_null() << '\n';
24  std::cout << j_string.is_null() << '\n';
25 }
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
-
bool is_null() const noexcept
return whether value is null
Definition: json.hpp:1968
+
Example
The following code exemplifies is_null for all JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 is_null()
17  std::cout << std::boolalpha;
18  std::cout << j_null.is_null() << '\n';
19  std::cout << j_boolean.is_null() << '\n';
20  std::cout << j_number_integer.is_null() << '\n';
21  std::cout << j_number_float.is_null() << '\n';
22  std::cout << j_object.is_null() << '\n';
23  std::cout << j_array.is_null() << '\n';
24  std::cout << j_string.is_null() << '\n';
25 }
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
+
bool is_null() const noexcept
return whether value is null
Definition: json.hpp:1977
Output (play with this example online):
true
 false
 false
@@ -269,7 +269,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 1968 of file json.hpp.

+

Definition at line 1977 of file json.hpp.

@@ -279,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html b/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html index 6f263cb15..11d1f3139 100644 --- a/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html +++ b/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

Returns
true if type is array, false otherwise.
Complexity
Constant.
-
Example
The following code exemplifies is_array for all JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 is_array()
17  std::cout << std::boolalpha;
18  std::cout << j_null.is_array() << '\n';
19  std::cout << j_boolean.is_array() << '\n';
20  std::cout << j_number_integer.is_array() << '\n';
21  std::cout << j_number_float.is_array() << '\n';
22  std::cout << j_object.is_array() << '\n';
23  std::cout << j_array.is_array() << '\n';
24  std::cout << j_string.is_array() << '\n';
25 }
bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:2095
-
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The following code exemplifies is_array for all JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 is_array()
17  std::cout << std::boolalpha;
18  std::cout << j_null.is_array() << '\n';
19  std::cout << j_boolean.is_array() << '\n';
20  std::cout << j_number_integer.is_array() << '\n';
21  std::cout << j_number_float.is_array() << '\n';
22  std::cout << j_object.is_array() << '\n';
23  std::cout << j_array.is_array() << '\n';
24  std::cout << j_string.is_array() << '\n';
25 }
bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:2104
+
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
Output (play with this example online):
false
 false
 false
@@ -269,7 +269,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 2095 of file json.hpp.

+

Definition at line 2104 of file json.hpp.

@@ -279,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html index 20186b95f..fe8f64342 100644 --- a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html +++ b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html @@ -278,16 +278,16 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The example demonstrates comparing several JSON types.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
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
+17 == 17.0 true
 "foo" == "bar" false
 
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 4811 of file json.hpp.

+

Definition at line 4820 of file json.hpp.

@@ -297,7 +297,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a13e5642dbfa1602c937d295a085413cc.html b/classnlohmann_1_1basic__json_a13e5642dbfa1602c937d295a085413cc.html index a98370315..8040d3a68 100644 --- a/classnlohmann_1_1basic__json_a13e5642dbfa1602c937d295a085413cc.html +++ b/classnlohmann_1_1basic__json_a13e5642dbfa1602c937d295a085413cc.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 230 of file json.hpp.

+

Definition at line 231 of file json.hpp.

@@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a1683189bd539313b5559f07961166c8b.html b/classnlohmann_1_1basic__json_a1683189bd539313b5559f07961166c8b.html index e3f3e4535..a2aef4a80 100644 --- a/classnlohmann_1_1basic__json_a1683189bd539313b5559f07961166c8b.html +++ b/classnlohmann_1_1basic__json_a1683189bd539313b5559f07961166c8b.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
-

Definition at line 240 of file json.hpp.

+

Definition at line 241 of file json.hpp.

@@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a16a275d0201e9aedc87c933c764b8869.html b/classnlohmann_1_1basic__json_a16a275d0201e9aedc87c933c764b8869.html index dcf3d3e77..7fd0675f2 100644 --- a/classnlohmann_1_1basic__json_a16a275d0201e9aedc87c933c764b8869.html +++ b/classnlohmann_1_1basic__json_a16a275d0201e9aedc87c933c764b8869.html @@ -270,9 +270,9 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2720
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The example below shows how object elements can be read using at.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2729
+
namespace for Niels Lohmann
Definition: json.hpp:88
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 
@@ -281,7 +281,7 @@ out of range value() for access by value with a default value
Since
version 1.0.0
-

Definition at line 2860 of file json.hpp.

+

Definition at line 2869 of file json.hpp.

@@ -291,7 +291,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html b/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html index cb6067a02..779507cfb 100644 --- a/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html +++ b/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html @@ -271,17 +271,17 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:2625
-
namespace for Niels Lohmann
Definition: json.hpp:79
-
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:528
-
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:593
+
Example
The example shows several calls to get_ref().
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:2634
+
namespace for Niels Lohmann
Definition: json.hpp:88
+
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:537
+
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:602
Output (play with this example online):
17 17
 incompatible ReferenceType for get_ref, actual type is number
 
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/get_ref.cpp -o get_ref 
-
Since
version 1.0.1
+
Since
version 1.1.0
-

Definition at line 2625 of file json.hpp.

+

Definition at line 2634 of file json.hpp.

@@ -291,7 +291,7 @@ incompatible ReferenceType for get_ref, actual type is number diff --git a/classnlohmann_1_1basic__json_a1dc0c521042807e216d11110d2f002ff.html b/classnlohmann_1_1basic__json_a1dc0c521042807e216d11110d2f002ff.html index 4fc555d02..972467d32 100644 --- a/classnlohmann_1_1basic__json_a1dc0c521042807e216d11110d2f002ff.html +++ b/classnlohmann_1_1basic__json_a1dc0c521042807e216d11110d2f002ff.html @@ -276,8 +276,8 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The following code shows the construction of a string value from a compatible type.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
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
@@ -285,7 +285,7 @@ template<class CompatibleStringType , typename std::enable_if< basic_json(const typename string_t::value_type*) – create a string value from a character pointer
Since
version 1.0.0
-

Definition at line 1114 of file json.hpp.

+

Definition at line 1123 of file json.hpp.

@@ -295,7 +295,7 @@ template<class CompatibleStringType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html index bf3aaebda..de7fb9b99 100644 --- a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html +++ b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html @@ -279,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje -

Definition at line 612 of file json.hpp.

+

Definition at line 621 of file json.hpp.

@@ -289,7 +289,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a234f03dce002783748ca401a42bc6472.html b/classnlohmann_1_1basic__json_a234f03dce002783748ca401a42bc6472.html index 6689902e3..117b5d81f 100644 --- a/classnlohmann_1_1basic__json_a234f03dce002783748ca401a42bc6472.html +++ b/classnlohmann_1_1basic__json_a234f03dce002783748ca401a42bc6472.html @@ -265,17 +265,17 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
namespace for Niels Lohmann
Definition: json.hpp:79
-
PointerType get_ptr() noexcept
get a pointer value (implicit)
Definition: json.hpp:2574
-
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:528
-
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:593
+
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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
namespace for Niels Lohmann
Definition: json.hpp:88
+
PointerType get_ptr() noexcept
get a pointer value (implicit)
Definition: json.hpp:2583
+
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:537
+
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:602
Output (play with this example online):
17 17 17 17
 true
 
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr 
Since
version 1.0.0
-

Definition at line 2589 of file json.hpp.

+

Definition at line 2598 of file json.hpp.

@@ -285,7 +285,7 @@ true diff --git a/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html b/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html index 4c0e7321c..1e6197540 100644 --- a/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html +++ b/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html @@ -292,9 +292,9 @@ 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 namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:188
-
ValueType value(const typename object_t::key_type &key, ValueType default_value) const
access specified object element with default value
Definition: json.hpp:3268
-
namespace for Niels Lohmann
Definition: json.hpp:79
+
Example
The example below shows how object elements can be queried with a default value.
1 #include <json.hpp>
2 
3 using namespace nlohmann;
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 }
a class to store JSON values
Definition: json.hpp:191
+
ValueType value(const typename object_t::key_type &key, ValueType default_value) const
access specified object element with default value
Definition: json.hpp:3277
+
namespace for Niels Lohmann
Definition: json.hpp:88
Output (play with this example online):
1 42.23 oops false
 
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/basic_json__value.cpp -o basic_json__value 
See also
at(const typename object_t::key_type&) for access by reference with range checking
@@ -302,7 +302,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
Since
version 1.0.0
-

Definition at line 3268 of file json.hpp.

+

Definition at line 3277 of file json.hpp.

@@ -312,7 +312,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html b/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html index 8bb596670..913964199 100644 --- a/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html +++ b/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html @@ -264,15 +264,15 @@ 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 namespace nlohmann;
    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
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3944
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    +
    Example
    The following code shows an example for crbegin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3953
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crbegin.cpp -o crbegin 
    Since
    version 1.0.0
    -

    Definition at line 3890 of file json.hpp.

    +

    Definition at line 3899 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html b/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html index 5d09f95da..d4afdf042 100644 --- a/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html +++ b/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4289
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4298
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {"one":1,"two":2}
     null
     {"four":4,"one":1,"three":3,"two":2}
    @@ -278,7 +278,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 4375 of file json.hpp.

    +

    Definition at line 4384 of file json.hpp.

    @@ -288,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html b/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html index 5cd54b246..3b03528cf 100644 --- a/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html +++ b/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html @@ -271,17 +271,17 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2625
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:528
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:593
    +
    Example
    The example shows several calls to get_ref().
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2634
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:537
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:602
    Output (play with this example online):
    17 17
     incompatible ReferenceType for get_ref, actual type is number
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ref.cpp -o get_ref 
    -
    Since
    version 1.0.1
    +
    Since
    version 1.1.0
    -

    Definition at line 2640 of file json.hpp.

    +

    Definition at line 2649 of file json.hpp.

    @@ -291,7 +291,7 @@ incompatible ReferenceType for get_ref, actual type is number diff --git a/classnlohmann_1_1basic__json_a3173944e7b1809a333def4078a0b92a3.html b/classnlohmann_1_1basic__json_a3173944e7b1809a333def4078a0b92a3.html index 0c50a30ab..f3f28268b 100644 --- a/classnlohmann_1_1basic__json_a3173944e7b1809a333def4078a0b92a3.html +++ b/classnlohmann_1_1basic__json_a3173944e7b1809a333def4078a0b92a3.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4289
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4298
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -278,7 +278,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 4315 of file json.hpp.

    +

    Definition at line 4324 of file json.hpp.

    @@ -288,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html b/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html index 61523d41b..38e5ba962 100644 --- a/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html +++ b/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html @@ -257,7 +257,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 3988 of file json.hpp.

    +

    Definition at line 3997 of file json.hpp.

    @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a3287df6546c905fb0a5786deb4b1cf32.html b/classnlohmann_1_1basic__json_a3287df6546c905fb0a5786deb4b1cf32.html index 2a60380c9..6ae674cc3 100644 --- a/classnlohmann_1_1basic__json_a3287df6546c905fb0a5786deb4b1cf32.html +++ b/classnlohmann_1_1basic__json_a3287df6546c905fb0a5786deb4b1cf32.html @@ -277,11 +277,11 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code uses empty to check if a json object contains any elements.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    -
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4040
    +
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4049
    Output (play with this example online):
    true
     false
     false
    @@ -294,7 +294,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/empty.cpp -o empty 
    Since
    version 1.0.0
    -

    Definition at line 4040 of file json.hpp.

    +

    Definition at line 4049 of file json.hpp.

    @@ -304,7 +304,7 @@ false diff --git a/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html b/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html index 4a9b76e41..c38b25eaf 100644 --- a/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html +++ b/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html @@ -263,14 +263,14 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The code below shows the move constructor explicitly called via std::move.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    null
     23
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__moveconstructor.cpp -o basic_json__moveconstructor 
    Since
    version 1.0.0
    -

    Definition at line 1752 of file json.hpp.

    +

    Definition at line 1761 of file json.hpp.

    @@ -280,7 +280,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html index 915be803c..8e6cad0b9 100644 --- a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html +++ b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows the serialization with different parameters to width to adjust the indentation level.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -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/operator_serialize.cpp -o operator_serialize 
    Since
    version 1.0.0
    -

    Definition at line 5164 of file json.hpp.

    +

    Definition at line 5171 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_a3d4e4bab95b24ccab42ed37e0ede2d98.html b/classnlohmann_1_1basic__json_a3d4e4bab95b24ccab42ed37e0ede2d98.html index e957fd1fb..36737ee6d 100644 --- a/classnlohmann_1_1basic__json_a3d4e4bab95b24ccab42ed37e0ede2d98.html +++ b/classnlohmann_1_1basic__json_a3d4e4bab95b24ccab42ed37e0ede2d98.html @@ -268,15 +268,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:341
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor with an object_t parameter.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:350
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {"one":1,"two":2}
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__object_t.cpp -o basic_json__object_t 
    See also
    basic_json(const CompatibleObjectType&) – create an object value from a compatible STL container
    Since
    version 1.0.0
    -

    Definition at line 934 of file json.hpp.

    +

    Definition at line 943 of file json.hpp.

    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a42f9133f978dde4cce5851b2c2434a0c.html b/classnlohmann_1_1basic__json_a42f9133f978dde4cce5851b2c2434a0c.html index d5e9b075b..6a8366680 100644 --- a/classnlohmann_1_1basic__json_a42f9133f978dde4cce5851b2c2434a0c.html +++ b/classnlohmann_1_1basic__json_a42f9133f978dde4cce5851b2c2434a0c.html @@ -256,10 +256,10 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    the type of the JSON value
    Complexity
    Constant.
    -
    Example
    The following code exemplifies type() for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code exemplifies type() for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:1908
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:1917
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    @@ -276,7 +276,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 1908 of file json.hpp.

    +

    Definition at line 1917 of file json.hpp.

    @@ -286,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html b/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html index 826b32675..13dc67974 100644 --- a/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html +++ b/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html @@ -265,15 +265,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3799
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:5832
    +
    Example
    The following code shows an example for cbegin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3808
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:5852
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cbegin.cpp -o cbegin 
    Since
    version 1.0.0
    -

    Definition at line 3775 of file json.hpp.

    +

    Definition at line 3784 of file json.hpp.

    @@ -283,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html b/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html index 40ed716e9..2b7683adf 100644 --- a/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html +++ b/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html @@ -268,15 +268,15 @@ 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 namespace nlohmann;
    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 }
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:387
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor with an array_t parameter.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:396
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    ["one","two",3,4.5,false]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__array_t.cpp -o basic_json__array_t 
    See also
    basic_json(const CompatibleArrayType&) – create an array value from a compatible STL containers
    Since
    version 1.0.0
    -

    Definition at line 993 of file json.hpp.

    +

    Definition at line 1002 of file json.hpp.

    @@ -286,7 +286,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a48c8d153bc2fd1af655063a4b984feac.html b/classnlohmann_1_1basic__json_a48c8d153bc2fd1af655063a4b984feac.html index 4868238d5..d4e7fe165 100644 --- a/classnlohmann_1_1basic__json_a48c8d153bc2fd1af655063a4b984feac.html +++ b/classnlohmann_1_1basic__json_a48c8d153bc2fd1af655063a4b984feac.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    StringType string_t
    a type for a string
    Definition: json.hpp:434
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor with an string_t parameter.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    StringType string_t
    a type for a string
    Definition: json.hpp:443
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    "The quick brown fox jumps over the lazy doc"
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__string_t.cpp -o basic_json__string_t 
    See also
    basic_json(const typename string_t::value_type*) – create a string value from a character pointer
    @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje basic_json(const CompatibleStringType&) – create a string value from a compatible string container
    Since
    version 1.0.0
    -

    Definition at line 1059 of file json.hpp.

    +

    Definition at line 1068 of file json.hpp.

    @@ -288,7 +288,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a4943b7f16ddc4e0df33c0cae7ef14471.html b/classnlohmann_1_1basic__json_a4943b7f16ddc4e0df33c0cae7ef14471.html index 474ae9487..eb6c9b2a2 100644 --- a/classnlohmann_1_1basic__json_a4943b7f16ddc4e0df33c0cae7ef14471.html +++ b/classnlohmann_1_1basic__json_a4943b7f16ddc4e0df33c0cae7ef14471.html @@ -264,15 +264,15 @@ 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 namespace nlohmann;
    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
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3967
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    +
    Example
    The following code shows an example for crend.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3976
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crend.cpp -o crend 
    Since
    version 1.0.0
    -

    Definition at line 3967 of file json.hpp.

    +

    Definition at line 3976 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html b/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html index 322cd3d80..bd7117918 100644 --- a/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html +++ b/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html @@ -264,15 +264,15 @@ 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 namespace nlohmann;
    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
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3967
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    +
    Example
    The following code shows an example for crend.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3976
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crend.cpp -o crend 
    Since
    version 1.0.0
    -

    Definition at line 3921 of file json.hpp.

    +

    Definition at line 3930 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html b/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html index 2577cbd7d..67230c56c 100644 --- a/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html +++ b/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html @@ -268,16 +268,16 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:341
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    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:4632
    +
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:350
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    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:4641
    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 4697 of file json.hpp.

    +

    Definition at line 4706 of file json.hpp.

    @@ -287,7 +287,7 @@ object = {"one":"eins","two":"zwei"} diff --git a/classnlohmann_1_1basic__json_a4d688b5ff534d3ab4e284b3191061529.html b/classnlohmann_1_1basic__json_a4d688b5ff534d3ab4e284b3191061529.html index a0013f318..69d1afc28 100644 --- a/classnlohmann_1_1basic__json_a4d688b5ff534d3ab4e284b3191061529.html +++ b/classnlohmann_1_1basic__json_a4d688b5ff534d3ab4e284b3191061529.html @@ -264,15 +264,15 @@ 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 namespace nlohmann;
    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
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3944
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    +
    Example
    The following code shows an example for crbegin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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
    12 
    13  // serialize the element that the iterator points to
    14  std::cout << *it << '\n';
    15 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3953
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/crbegin.cpp -o crbegin 
    Since
    version 1.0.0
    -

    Definition at line 3944 of file json.hpp.

    +

    Definition at line 3953 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html b/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html index 445800850..390204990 100644 --- a/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html +++ b/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4289
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4298
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -278,7 +278,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 4325 of file json.hpp.

    +

    Definition at line 4334 of file json.hpp.

    @@ -288,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html b/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html index 6d322bbf9..1ff4787a1 100644 --- a/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html +++ b/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html @@ -257,9 +257,9 @@ template<template< typename U, typename V, typename...Args > class Obje
    Note
    This function will always be false for JSON values after parsing. That is, discarded values can only occur during parsing, but will be removed when inside a structured value or replaced by null in other cases.
    Returns
    true if type is discarded, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_discarded for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_discarded()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_discarded() << '\n';
    19  std::cout << j_boolean.is_discarded() << '\n';
    20  std::cout << j_number_integer.is_discarded() << '\n';
    21  std::cout << j_number_float.is_discarded() << '\n';
    22  std::cout << j_object.is_discarded() << '\n';
    23  std::cout << j_array.is_discarded() << '\n';
    24  std::cout << j_string.is_discarded() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2138
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code exemplifies is_discarded for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_discarded()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_discarded() << '\n';
    19  std::cout << j_boolean.is_discarded() << '\n';
    20  std::cout << j_number_integer.is_discarded() << '\n';
    21  std::cout << j_number_float.is_discarded() << '\n';
    22  std::cout << j_object.is_discarded() << '\n';
    23  std::cout << j_array.is_discarded() << '\n';
    24  std::cout << j_string.is_discarded() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2147
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    false
     false
     false
    @@ -270,7 +270,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 2138 of file json.hpp.

    +

    Definition at line 2147 of file json.hpp.

    @@ -280,7 +280,7 @@ false diff --git a/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html b/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html index 95c47ee10..29ee6b6c2 100644 --- a/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html +++ b/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html @@ -271,15 +271,15 @@ use operator[] with null"
    Complexity
    Constant if idx is in the range of the array. Otherwise linear in idx - size().
    -
    Example
    The example below shows how array elements can be read and written using [] operator. Note the addition of null values.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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 2907 of file json.hpp.

    +

    Definition at line 2916 of file json.hpp.

    @@ -289,7 +289,7 @@ use operator[] with null" diff --git a/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html b/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html index 7c8767cf2..e30cefee4 100644 --- a/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html +++ b/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html @@ -269,16 +269,16 @@ use swap() with boolean"
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    StringType string_t
    a type for a string
    Definition: json.hpp:434
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    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:4632
    +
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    StringType string_t
    a type for a string
    Definition: json.hpp:443
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    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:4641
    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 4731 of file json.hpp.

    +

    Definition at line 4740 of file json.hpp.

    @@ -288,7 +288,7 @@ string = the bad diff --git a/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html b/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html index d52c90efc..a30e290aa 100644 --- a/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html +++ b/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html @@ -260,8 +260,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor for a null JSON value.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -275,7 +275,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 3064b2f03..287e1b4cf 100644 --- a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html +++ b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -283,7 +283,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 5065 of file json.hpp.

    +

    Definition at line 5072 of file json.hpp.

    @@ -293,7 +293,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a5d428360d75a52f6af74751d1cc912c6.html b/classnlohmann_1_1basic__json_a5d428360d75a52f6af74751d1cc912c6.html index 667b75098..638bab32a 100644 --- a/classnlohmann_1_1basic__json_a5d428360d75a52f6af74751d1cc912c6.html +++ b/classnlohmann_1_1basic__json_a5d428360d75a52f6af74751d1cc912c6.html @@ -256,11 +256,11 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    the type of the JSON value
    Complexity
    Constant.
    -
    Example
    The following code exemplifies the value_t operator for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code exemplifies the value_t operator for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    -
    value_t
    the JSON type enumeration
    Definition: json.hpp:612
    +
    value_t
    the JSON type enumeration
    Definition: json.hpp:621
    array (ordered collection of values)
    number value (floating-point)
    @@ -276,7 +276,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 2158 of file json.hpp.

    +

    Definition at line 2167 of file json.hpp.

    @@ -286,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html index 87358446d..3e500f68b 100644 --- a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html +++ b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows the serialization with different parameters to width to adjust the indentation level.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {"one":1,"two":2}
     
     [1,2,4,8,16]
    @@ -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/operator_serialize.cpp -o operator_serialize 
    Since
    version 1.0.0
    -

    Definition at line 5146 of file json.hpp.

    +

    Definition at line 5153 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_a5f0aad50ed7e8aec3128fe018c18b3fe.html b/classnlohmann_1_1basic__json_a5f0aad50ed7e8aec3128fe018c18b3fe.html index e69a8eb8a..39df77858 100644 --- a/classnlohmann_1_1basic__json_a5f0aad50ed7e8aec3128fe018c18b3fe.html +++ b/classnlohmann_1_1basic__json_a5f0aad50ed7e8aec3128fe018c18b3fe.html @@ -270,9 +270,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2490
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2499
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -290,7 +290,7 @@ array: [1,2,3,4,5]
     get() for pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2490 of file json.hpp.

    +

    Definition at line 2499 of file json.hpp.

    @@ -300,7 +300,7 @@ array: [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_a5fd8b54389698edf0c08e2dd001f610b.html b/classnlohmann_1_1basic__json_a5fd8b54389698edf0c08e2dd001f610b.html index 6ed92caa2..c5308d077 100644 --- a/classnlohmann_1_1basic__json_a5fd8b54389698edf0c08e2dd001f610b.html +++ b/classnlohmann_1_1basic__json_a5fd8b54389698edf0c08e2dd001f610b.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 213 of file json.hpp.

    +

    Definition at line 216 of file json.hpp.

    @@ -253,7 +253,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 9befc5890..7a28458cf 100644 --- a/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html +++ b/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html @@ -280,8 +280,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -299,7 +299,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 5268 of file json.hpp.

    +

    Definition at line 5275 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_a63691315292df8e1522b00d37ebb1ffc.html b/classnlohmann_1_1basic__json_a63691315292df8e1522b00d37ebb1ffc.html index 65a9a2fb6..bc3c3ae54 100644 --- a/classnlohmann_1_1basic__json_a63691315292df8e1522b00d37ebb1ffc.html +++ b/classnlohmann_1_1basic__json_a63691315292df8e1522b00d37ebb1ffc.html @@ -272,9 +272,10 @@ template<template< typename U, typename V, typename...Args > class Obje

    Storage

    Objects are stored as pointers in a basic_json type. That is, for any access to object values, a pointer of type object_t* must be dereferenced.

    See also
    array_t – type for an array value
    -
    Since
    version 1.0.0
    +
    Since
    version 1.0.0
    +
    Note
    The order name/value pairs are added to the object is not preserved by the library. Therefore, iterating an object may return name/value pairs in a different order than they were originally stored. In fact, keys will be traversed in alphabetical order as std::map with std::less is used by default. Please note this behavior conforms to RFC 7159, because any order implements the specified "unordered" nature of JSON objects.
    -

    Definition at line 341 of file json.hpp.

    +

    Definition at line 350 of file json.hpp.

    @@ -284,7 +285,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a652414dd930cb3af3b6f454cc535a23e.html b/classnlohmann_1_1basic__json_a652414dd930cb3af3b6f454cc535a23e.html index 6964ab50a..5b20462d2 100644 --- a/classnlohmann_1_1basic__json_a652414dd930cb3af3b6f454cc535a23e.html +++ b/classnlohmann_1_1basic__json_a652414dd930cb3af3b6f454cc535a23e.html @@ -270,9 +270,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2720
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be read and written using at.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2729
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -282,7 +282,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 2812 of file json.hpp.

    +

    Definition at line 2821 of file json.hpp.

    @@ -292,7 +292,7 @@ out of range: key 'the fast' not found diff --git a/classnlohmann_1_1basic__json_a656939a3dc9a6047e4afacd9e11b83a6.html b/classnlohmann_1_1basic__json_a656939a3dc9a6047e4afacd9e11b83a6.html index 8724c0653..a46fdf60c 100644 --- a/classnlohmann_1_1basic__json_a656939a3dc9a6047e4afacd9e11b83a6.html +++ b/classnlohmann_1_1basic__json_a656939a3dc9a6047e4afacd9e11b83a6.html @@ -265,17 +265,17 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2574
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:528
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:593
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2583
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:537
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:602
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get_ptr.cpp -o get_ptr 
    Since
    version 1.0.0
    -

    Definition at line 2574 of file json.hpp.

    +

    Definition at line 2583 of file json.hpp.

    @@ -285,7 +285,7 @@ true diff --git a/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html b/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html index 80daa3ddf..79543468d 100644 --- a/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html +++ b/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4289
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4298
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -278,7 +278,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 4289 of file json.hpp.

    +

    Definition at line 4298 of file json.hpp.

    @@ -288,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html b/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html index 4ffb08ed6..5a7414d9d 100644 --- a/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html +++ b/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html @@ -268,7 +268,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    See also
    number_float_t – type for number values (floating-point)
    Since
    version 1.0.0
    -

    Definition at line 528 of file json.hpp.

    +

    Definition at line 537 of file json.hpp.

    @@ -278,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a696ced74d8edc0b63a000a72907ab109.html b/classnlohmann_1_1basic__json_a696ced74d8edc0b63a000a72907ab109.html index 275fcf579..0a5ce8114 100644 --- a/classnlohmann_1_1basic__json_a696ced74d8edc0b63a000a72907ab109.html +++ b/classnlohmann_1_1basic__json_a696ced74d8edc0b63a000a72907ab109.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is number (regardless whether integer or floating-type), false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_number()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_number() << '\n';
    19  std::cout << j_boolean.is_number() << '\n';
    20  std::cout << j_number_integer.is_number() << '\n';
    21  std::cout << j_number_float.is_number() << '\n';
    22  std::cout << j_object.is_number() << '\n';
    23  std::cout << j_array.is_number() << '\n';
    24  std::cout << j_string.is_number() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2011
    +
    Example
    The following code exemplifies is_number for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_number()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_number() << '\n';
    19  std::cout << j_boolean.is_number() << '\n';
    20  std::cout << j_number_integer.is_number() << '\n';
    21  std::cout << j_number_float.is_number() << '\n';
    22  std::cout << j_object.is_number() << '\n';
    23  std::cout << j_array.is_number() << '\n';
    24  std::cout << j_string.is_number() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2020
    Output (play with this example online):
    false
     false
     true
    @@ -272,7 +272,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 1.0.0
    -

    Definition at line 2011 of file json.hpp.

    +

    Definition at line 2020 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html b/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html index da3f02bd0..df6f5f494 100644 --- a/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html +++ b/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html @@ -295,18 +295,18 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3682
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows several ways to create JSON values by specifying a subrange with iterators.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3691
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    ["bravo","charly"]
     42
     {"one":"eins"}
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__InputIt_InputIt.cpp -o basic_json__InputIt_InputIt 
    Since
    version 1.0.0
    -

    Definition at line 1580 of file json.hpp.

    +

    Definition at line 1589 of file json.hpp.

    @@ -316,7 +316,7 @@ construct with iterators from null" diff --git a/classnlohmann_1_1basic__json_a6b7428e8c1169497f47b81667001cbfb.html b/classnlohmann_1_1basic__json_a6b7428e8c1169497f47b81667001cbfb.html index e41c1c902..be5859944 100644 --- a/classnlohmann_1_1basic__json_a6b7428e8c1169497f47b81667001cbfb.html +++ b/classnlohmann_1_1basic__json_a6b7428e8c1169497f47b81667001cbfb.html @@ -288,16 +288,16 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4427
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4436
    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 4483 of file json.hpp.

    +

    Definition at line 4492 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_a6bbd3e72a870f1ba81ff6886b063b0fe.html b/classnlohmann_1_1basic__json_a6bbd3e72a870f1ba81ff6886b063b0fe.html index 5d192e763..ace1039c0 100644 --- a/classnlohmann_1_1basic__json_a6bbd3e72a870f1ba81ff6886b063b0fe.html +++ b/classnlohmann_1_1basic__json_a6bbd3e72a870f1ba81ff6886b063b0fe.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 228 of file json.hpp.

    +

    Definition at line 229 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a6dff6a02a2be250b8f8dc2f47be65544.html b/classnlohmann_1_1basic__json_a6dff6a02a2be250b8f8dc2f47be65544.html index bd179ad8e..0032a8d53 100644 --- a/classnlohmann_1_1basic__json_a6dff6a02a2be250b8f8dc2f47be65544.html +++ b/classnlohmann_1_1basic__json_a6dff6a02a2be250b8f8dc2f47be65544.html @@ -270,9 +270,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3420
    +
    Example
    The example shows the effect of erase.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3429
    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
    @@ -282,7 +282,7 @@ range" erase(const typename object_t::key_type&) – removes the element from an object at the given key
    Since
    version 1.0.0
    -

    Definition at line 3646 of file json.hpp.

    +

    Definition at line 3655 of file json.hpp.

    @@ -292,7 +292,7 @@ range" diff --git a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html index 99365d2d2..eb4ebacc3 100644 --- a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html +++ b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html @@ -274,16 +274,16 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    +17 == 17.0 false
     "foo" == "bar" true
     
    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 4921 of file json.hpp.

    +

    Definition at line 4928 of file json.hpp.

    @@ -293,7 +293,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a71eba33d906745e66f340952b79fbce3.html b/classnlohmann_1_1basic__json_a71eba33d906745e66f340952b79fbce3.html index b130488fa..54cf60252 100644 --- a/classnlohmann_1_1basic__json_a71eba33d906745e66f340952b79fbce3.html +++ b/classnlohmann_1_1basic__json_a71eba33d906745e66f340952b79fbce3.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 242 of file json.hpp.

    +

    Definition at line 243 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a72442ccbb378b4464a24a2da1e784041.html b/classnlohmann_1_1basic__json_a72442ccbb378b4464a24a2da1e784041.html index 2d40839d7..3a6b1d3d7 100644 --- a/classnlohmann_1_1basic__json_a72442ccbb378b4464a24a2da1e784041.html +++ b/classnlohmann_1_1basic__json_a72442ccbb378b4464a24a2da1e784041.html @@ -290,9 +290,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3268
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be queried with a default value.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3277
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -300,7 +300,7 @@ value() with null" operator[](const typename object_t::key_type&) for unchecked access by reference
    Since
    version 1.0.0
    -

    Definition at line 3294 of file json.hpp.

    +

    Definition at line 3303 of file json.hpp.

    @@ -310,7 +310,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html b/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html index f8188697d..38e15f2a5 100644 --- a/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html +++ b/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html @@ -265,15 +265,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3858
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:5832
    +
    Example
    The following code shows an example for cend.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3867
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:5852
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cend.cpp -o cend 
    Since
    version 1.0.0
    -

    Definition at line 3858 of file json.hpp.

    +

    Definition at line 3867 of file json.hpp.

    @@ -283,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html b/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html index 9a8031f7f..6d1afa720 100644 --- a/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html +++ b/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html @@ -266,9 +266,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:593
    +
    Example
    The following example creates several floating-point values.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:602
    Output (play with this example online):
    3.14159265358979
     null
     null
    @@ -276,7 +276,7 @@ null
     
    See also
    basic_json(const CompatibleNumberFloatType) – create a number value (floating-point) from a compatible number type
    Since
    version 1.0.0
    -

    Definition at line 1259 of file json.hpp.

    +

    Definition at line 1268 of file json.hpp.

    @@ -286,7 +286,7 @@ null diff --git a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html index 9da378c9e..39c39a078 100644 --- a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html +++ b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -283,7 +283,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 5109 of file json.hpp.

    +

    Definition at line 5116 of file json.hpp.

    @@ -293,7 +293,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a74ccfa471a0c061876b247f820f3c741.html b/classnlohmann_1_1basic__json_a74ccfa471a0c061876b247f820f3c741.html index 2fa7f0cbb..72aefd90a 100644 --- a/classnlohmann_1_1basic__json_a74ccfa471a0c061876b247f820f3c741.html +++ b/classnlohmann_1_1basic__json_a74ccfa471a0c061876b247f820f3c741.html @@ -274,14 +274,14 @@ 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 namespace nlohmann;
    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:8114
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:820
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4219
    +
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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:8170
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:829
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4228
    the parser read a key of a value in an object
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5203
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:755
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5210
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:764
    Output (play with this example online):
    {
         "Image": {
             "Animated": false,
    @@ -320,7 +320,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 5232 of file json.hpp.

    +

    Definition at line 5239 of file json.hpp.

    @@ -330,7 +330,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a75a1754e0d39f33095d3102a8bdb9881.html b/classnlohmann_1_1basic__json_a75a1754e0d39f33095d3102a8bdb9881.html index b71d55f4d..700297d92 100644 --- a/classnlohmann_1_1basic__json_a75a1754e0d39f33095d3102a8bdb9881.html +++ b/classnlohmann_1_1basic__json_a75a1754e0d39f33095d3102a8bdb9881.html @@ -288,11 +288,11 @@ of range"
  • other types: constant
  • -
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3682
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3420
    +
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3691
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3429
    Output (play with this example online):
    null
     null
     null
    @@ -307,7 +307,7 @@ null
     erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3420 of file json.hpp.

    +

    Definition at line 3429 of file json.hpp.

    @@ -317,7 +317,7 @@ null diff --git a/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html b/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html index 3e20ff92f..f39a49257 100644 --- a/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html +++ b/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html @@ -265,18 +265,18 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2490
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:528
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:593
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2499
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:537
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:602
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get__PointerType.cpp -o get__PointerType 
    See also
    get_ptr() for explicit pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2539 of file json.hpp.

    +

    Definition at line 2548 of file json.hpp.

    @@ -286,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html b/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html index 2d9d1fc92..7f917fad0 100644 --- a/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html +++ b/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html @@ -264,15 +264,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:3913
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    +
    Example
    The following code shows an example for rend.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:3922
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/rend.cpp -o rend 
    Since
    version 1.0.0
    -

    Definition at line 3913 of file json.hpp.

    +

    Definition at line 3922 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html b/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html index 2b1eab4e8..ca294633c 100644 --- a/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html +++ b/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html @@ -263,17 +263,17 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3682
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example shows how find is used.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3691
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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 3699 of file json.hpp.

    +

    Definition at line 3708 of file json.hpp.

    @@ -283,7 +283,7 @@ value at key "two": 2 diff --git a/classnlohmann_1_1basic__json_a7d0db3b728d820d4984df78d97d2b104.html b/classnlohmann_1_1basic__json_a7d0db3b728d820d4984df78d97d2b104.html index 158b47c4d..7b4e61e58 100644 --- a/classnlohmann_1_1basic__json_a7d0db3b728d820d4984df78d97d2b104.html +++ b/classnlohmann_1_1basic__json_a7d0db3b728d820d4984df78d97d2b104.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 210 of file json.hpp.

    +

    Definition at line 213 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a7d1b990f2c12fecb57db1504fdadd0bb.html b/classnlohmann_1_1basic__json_a7d1b990f2c12fecb57db1504fdadd0bb.html index 02588fc72..ee2d8b3e4 100644 --- a/classnlohmann_1_1basic__json_a7d1b990f2c12fecb57db1504fdadd0bb.html +++ b/classnlohmann_1_1basic__json_a7d1b990f2c12fecb57db1504fdadd0bb.html @@ -269,9 +269,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3420
    +
    Example
    The example shows the effect of erase.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3429
    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 
    @@ -282,7 +282,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 3608 of file json.hpp.

    +

    Definition at line 3617 of file json.hpp.

    @@ -292,7 +292,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a7dab69b10b98e7bc694339720e37fb2b.html b/classnlohmann_1_1basic__json_a7dab69b10b98e7bc694339720e37fb2b.html index f9440f746..37e1cba70 100644 --- a/classnlohmann_1_1basic__json_a7dab69b10b98e7bc694339720e37fb2b.html +++ b/classnlohmann_1_1basic__json_a7dab69b10b98e7bc694339720e37fb2b.html @@ -263,17 +263,17 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3682
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example shows how find is used.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3691
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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 3682 of file json.hpp.

    +

    Definition at line 3691 of file json.hpp.

    @@ -283,7 +283,7 @@ value at key "two": 2 diff --git a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html index cbebe62cf..2a241213d 100644 --- a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html +++ b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88

    Output (play with this example online):

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

    +

    Definition at line 4960 of file json.hpp.

    @@ -293,7 +293,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html b/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html index ae90e7d59..d89228142 100644 --- a/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html +++ b/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 222 of file json.hpp.

    +

    Definition at line 223 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html b/classnlohmann_1_1basic__json_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html index 42c284b58..2741c6e19 100644 --- a/classnlohmann_1_1basic__json_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html +++ b/classnlohmann_1_1basic__json_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html @@ -263,10 +263,10 @@ 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 namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    reference front()
    access the first element
    Definition: json.hpp:3319
    -
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code shows an example for front.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    reference front()
    access the first element
    Definition: json.hpp:3328
    +
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    Output (play with this example online):
    true
     17
    @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/front.cpp -o front 
    Since
    version 1.0.0
    -

    Definition at line 3319 of file json.hpp.

    +

    Definition at line 3328 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html index d63424c39..919a370f7 100644 --- a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html +++ b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -283,7 +283,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 5087 of file json.hpp.

    +

    Definition at line 5094 of file json.hpp.

    @@ -293,7 +293,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a8b526709d395142b68d21abfbfff17c3.html b/classnlohmann_1_1basic__json_a8b526709d395142b68d21abfbfff17c3.html index 85058d4db..715819941 100644 --- a/classnlohmann_1_1basic__json_a8b526709d395142b68d21abfbfff17c3.html +++ b/classnlohmann_1_1basic__json_a8b526709d395142b68d21abfbfff17c3.html @@ -263,10 +263,10 @@ 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 namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    reference front()
    access the first element
    Definition: json.hpp:3319
    -
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code shows an example for front.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call front()
    19  //std::cout << j_null.front() << '\n'; // would throw
    20  std::cout << j_boolean.front() << '\n';
    21  std::cout << j_number_integer.front() << '\n';
    22  std::cout << j_number_float.front() << '\n';
    23  std::cout << j_object.front() << '\n';
    24  //std::cout << j_object_empty.front() << '\n'; // would throw
    25  std::cout << j_array.front() << '\n';
    26  //std::cout << j_array_empty.front() << '\n'; // would throw
    27  std::cout << j_string.front() << '\n';
    28 }
    reference front()
    access the first element
    Definition: json.hpp:3328
    +
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    Output (play with this example online):
    true
     17
    @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/front.cpp -o front 
    Since
    version 1.0.0
    -

    Definition at line 3327 of file json.hpp.

    +

    Definition at line 3336 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a8c40cd9ead4de7c82f28268bdf0ec98a.html b/classnlohmann_1_1basic__json_a8c40cd9ead4de7c82f28268bdf0ec98a.html index 80c77e488..25c21b39f 100644 --- a/classnlohmann_1_1basic__json_a8c40cd9ead4de7c82f28268bdf0ec98a.html +++ b/classnlohmann_1_1basic__json_a8c40cd9ead4de7c82f28268bdf0ec98a.html @@ -272,20 +272,20 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4219
    +
    Example
    The example below shows the effect of clear to different JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4228
    Output (play with this example online):
    null
     false
     0
    -0
    +0.0
     {}
     []
     ""
     
    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 4219 of file json.hpp.

    +

    Definition at line 4228 of file json.hpp.

    @@ -295,7 +295,7 @@ false diff --git a/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html b/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html index 11a1a3c25..10f34f6e4 100644 --- a/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html +++ b/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html @@ -271,8 +271,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -280,7 +280,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3041 of file json.hpp.

    +

    Definition at line 3050 of file json.hpp.

    @@ -290,7 +290,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html b/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html index 706b2f68a..399764933 100644 --- a/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html +++ b/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html @@ -257,7 +257,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 3996 of file json.hpp.

    +

    Definition at line 4005 of file json.hpp.

    @@ -267,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a8fa74698f4061e18ec664009f3af1ddf.html b/classnlohmann_1_1basic__json_a8fa74698f4061e18ec664009f3af1ddf.html index 442df04b9..c6a71e584 100644 --- a/classnlohmann_1_1basic__json_a8fa74698f4061e18ec664009f3af1ddf.html +++ b/classnlohmann_1_1basic__json_a8fa74698f4061e18ec664009f3af1ddf.html @@ -291,17 +291,17 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4427
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4436
    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 4536 of file json.hpp.

    +

    Definition at line 4545 of file json.hpp.

    @@ -311,7 +311,7 @@ belong to container" diff --git a/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html b/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html index 5e6b28408..dee938f02 100644 --- a/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html +++ b/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html @@ -256,14 +256,14 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Complexity
    Constant.
    -
    Example
    The following code shows the constructor with null pointer parameter.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor with null pointer parameter.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    null
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__nullptr_t.cpp -o basic_json__nullptr_t 
    See also
    basic_json() – default constructor (implicitly creating a null value)
    Since
    version 1.0.0
    -

    Definition at line 911 of file json.hpp.

    +

    Definition at line 920 of file json.hpp.

    @@ -273,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a960962c683909619d1d2fbbe856c022e.html b/classnlohmann_1_1basic__json_a960962c683909619d1d2fbbe856c022e.html index 281fa0ee5..606430e45 100644 --- a/classnlohmann_1_1basic__json_a960962c683909619d1d2fbbe856c022e.html +++ b/classnlohmann_1_1basic__json_a960962c683909619d1d2fbbe856c022e.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4289
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4298
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    [1,2,3,4,5]
     null
     [1,2,3,4,5,6,7]
    @@ -278,7 +278,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 4349 of file json.hpp.

    +

    Definition at line 4358 of file json.hpp.

    @@ -288,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html index 0b43ba940..4f1984b86 100644 --- a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html +++ b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88

    Output (play with this example online):

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

    +

    Definition at line 4898 of file json.hpp.

    @@ -293,7 +293,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html index d59da57c3..fc7a3acf6 100644 --- a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html +++ b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88

    Output (play with this example online):

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

    +

    Definition at line 4907 of file json.hpp.

    @@ -293,7 +293,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html b/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html index 617ea00d1..515391921 100644 --- a/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html +++ b/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is an integer number, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number_integer for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_number_integer()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_number_integer() << '\n';
    19  std::cout << j_boolean.is_number_integer() << '\n';
    20  std::cout << j_number_integer.is_number_integer() << '\n';
    21  std::cout << j_number_float.is_number_integer() << '\n';
    22  std::cout << j_object.is_number_integer() << '\n';
    23  std::cout << j_array.is_number_integer() << '\n';
    24  std::cout << j_string.is_number_integer() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2034
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code exemplifies is_number_integer for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_number_integer()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_number_integer() << '\n';
    19  std::cout << j_boolean.is_number_integer() << '\n';
    20  std::cout << j_number_integer.is_number_integer() << '\n';
    21  std::cout << j_number_float.is_number_integer() << '\n';
    22  std::cout << j_object.is_number_integer() << '\n';
    23  std::cout << j_array.is_number_integer() << '\n';
    24  std::cout << j_string.is_number_integer() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2043
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    false
     false
     true
    @@ -272,7 +272,7 @@ false
     is_number_float() – check if value is a floating-point number
    Since
    version 1.0.0
    -

    Definition at line 2034 of file json.hpp.

    +

    Definition at line 2043 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html b/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html index a91c9c7a8..3d22db12a 100644 --- a/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html +++ b/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html @@ -273,16 +273,16 @@ 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 namespace nlohmann;
    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:8114
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows examples for the basic_json(size_type, const basic_json&) constructor.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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:8170
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    []
     ["Hello"]
     ["Hello","Hello","Hello","Hello","Hello"]
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__size_type_basic_json.cpp -o basic_json__size_type_basic_json 
    Since
    version 1.0.0
    -

    Definition at line 1534 of file json.hpp.

    +

    Definition at line 1543 of file json.hpp.

    @@ -292,7 +292,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_a9c26c5d0f4a519c7236149b9aeb3ef9e.html b/classnlohmann_1_1basic__json_a9c26c5d0f4a519c7236149b9aeb3ef9e.html index b9bd00ad2..67ab8a5b5 100644 --- a/classnlohmann_1_1basic__json_a9c26c5d0f4a519c7236149b9aeb3ef9e.html +++ b/classnlohmann_1_1basic__json_a9c26c5d0f4a519c7236149b9aeb3ef9e.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is a floating-point number, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_number_float for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_number_float()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_number_float() << '\n';
    19  std::cout << j_boolean.is_number_float() << '\n';
    20  std::cout << j_number_integer.is_number_float() << '\n';
    21  std::cout << j_number_float.is_number_float() << '\n';
    22  std::cout << j_object.is_number_float() << '\n';
    23  std::cout << j_array.is_number_float() << '\n';
    24  std::cout << j_string.is_number_float() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2057
    +
    Example
    The following code exemplifies is_number_float for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_number_float()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_number_float() << '\n';
    19  std::cout << j_boolean.is_number_float() << '\n';
    20  std::cout << j_number_integer.is_number_float() << '\n';
    21  std::cout << j_number_float.is_number_float() << '\n';
    22  std::cout << j_object.is_number_float() << '\n';
    23  std::cout << j_array.is_number_float() << '\n';
    24  std::cout << j_string.is_number_float() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2066
    Output (play with this example online):
    false
     false
     false
    @@ -272,7 +272,7 @@ false
     is_number_integer() – check if value is an integer number
    Since
    version 1.0.0
    -

    Definition at line 2057 of file json.hpp.

    +

    Definition at line 2066 of file json.hpp.

    @@ -282,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html b/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html index 3e34ff68b..ea2bfcdbe 100644 --- a/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html +++ b/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is primitive (string, number, boolean, or null), false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_primitive for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_primitive()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_primitive() << '\n';
    19  std::cout << j_boolean.is_primitive() << '\n';
    20  std::cout << j_number_integer.is_primitive() << '\n';
    21  std::cout << j_number_float.is_primitive() << '\n';
    22  std::cout << j_object.is_primitive() << '\n';
    23  std::cout << j_array.is_primitive() << '\n';
    24  std::cout << j_string.is_primitive() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:1929
    +
    Example
    The following code exemplifies is_primitive for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_primitive()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_primitive() << '\n';
    19  std::cout << j_boolean.is_primitive() << '\n';
    20  std::cout << j_number_integer.is_primitive() << '\n';
    21  std::cout << j_number_float.is_primitive() << '\n';
    22  std::cout << j_object.is_primitive() << '\n';
    23  std::cout << j_array.is_primitive() << '\n';
    24  std::cout << j_string.is_primitive() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:1938
    Output (play with this example online):
    true
     true
     true
    @@ -269,7 +269,7 @@ true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_primitive.cpp -o is_primitive 
    Since
    version 1.0.0
    -

    Definition at line 1929 of file json.hpp.

    +

    Definition at line 1938 of file json.hpp.

    @@ -279,7 +279,7 @@ true diff --git a/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html b/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html index 7db3ae700..56936813d 100644 --- a/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html +++ b/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html @@ -274,14 +274,14 @@ 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 namespace nlohmann;
    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:8114
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:820
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4219
    +
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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:8170
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:829
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4228
    the parser read a key of a value in an object
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5203
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:755
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5210
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:764
    Output (play with this example online):
    {
         "Image": {
             "Animated": false,
    @@ -320,7 +320,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 5240 of file json.hpp.

    +

    Definition at line 5247 of file json.hpp.

    @@ -330,7 +330,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa1f3b3f1dca79392d6727b81f9668c6c.html b/classnlohmann_1_1basic__json_aa1f3b3f1dca79392d6727b81f9668c6c.html index 1b4621bb6..8e78b5626 100644 --- a/classnlohmann_1_1basic__json_aa1f3b3f1dca79392d6727b81f9668c6c.html +++ b/classnlohmann_1_1basic__json_aa1f3b3f1dca79392d6727b81f9668c6c.html @@ -263,11 +263,11 @@ 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 namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code shows an example for back.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    -
    reference back()
    access the last element
    Definition: json.hpp:3353
    +
    reference back()
    access the last element
    Definition: json.hpp:3362
    Output (play with this example online):
    true
     17
     23.42
    @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/back.cpp -o back 
    Since
    version 1.0.0
    -

    Definition at line 3353 of file json.hpp.

    +

    Definition at line 3362 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa5413178b8041f7ac685dec4b040dd2c.html b/classnlohmann_1_1basic__json_aa5413178b8041f7ac685dec4b040dd2c.html index 839004846..4279e4cbc 100644 --- a/classnlohmann_1_1basic__json_aa5413178b8041f7ac685dec4b040dd2c.html +++ b/classnlohmann_1_1basic__json_aa5413178b8041f7ac685dec4b040dd2c.html @@ -265,15 +265,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3858
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:5832
    +
    Example
    The following code shows an example for cend.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3867
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:5852
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cend.cpp -o cend 
    Since
    version 1.0.0
    -

    Definition at line 3834 of file json.hpp.

    +

    Definition at line 3843 of file json.hpp.

    @@ -283,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html b/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html index 0926ecc74..96c0edcbd 100644 --- a/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html +++ b/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html @@ -262,7 +262,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    -

    Definition at line 1808 of file json.hpp.

    +

    Definition at line 1817 of file json.hpp.

    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aa6c32f669a2e523666072003d0ea46f4.html b/classnlohmann_1_1basic__json_aa6c32f669a2e523666072003d0ea46f4.html index c27773ee7..ba500bb9d 100644 --- a/classnlohmann_1_1basic__json_aa6c32f669a2e523666072003d0ea46f4.html +++ b/classnlohmann_1_1basic__json_aa6c32f669a2e523666072003d0ea46f4.html @@ -276,8 +276,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor with several compatible object type parameters.
    1 #include <json.hpp>
    2 #include <unordered_map>
    3 
    4 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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}
    @@ -286,7 +286,7 @@ template<class CompatibleObjectType , typename std::enable_if<
     
    See also
    basic_json(const object_t&) – create an object value
    Since
    version 1.0.0
    -

    Definition at line 966 of file json.hpp.

    +

    Definition at line 975 of file json.hpp.

    @@ -296,7 +296,7 @@ template<class CompatibleObjectType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_aa71e977d31f470689883ac60d16ea4ac.html b/classnlohmann_1_1basic__json_aa71e977d31f470689883ac60d16ea4ac.html index e4a2425a3..3f311cdad 100644 --- a/classnlohmann_1_1basic__json_aa71e977d31f470689883ac60d16ea4ac.html +++ b/classnlohmann_1_1basic__json_aa71e977d31f470689883ac60d16ea4ac.html @@ -269,16 +269,16 @@ use swap() with string"
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:387
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    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:4632
    +
    Example
    The example below shows how JSON values can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:396
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    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:4641
    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 4663 of file json.hpp.

    +

    Definition at line 4672 of file json.hpp.

    @@ -288,7 +288,7 @@ array = [1,2,3,4] diff --git a/classnlohmann_1_1basic__json_aabe4661644ea549089f0886c2551d2ac.html b/classnlohmann_1_1basic__json_aabe4661644ea549089f0886c2551d2ac.html index 2751ca69a..87c5422f3 100644 --- a/classnlohmann_1_1basic__json_aabe4661644ea549089f0886c2551d2ac.html +++ b/classnlohmann_1_1basic__json_aabe4661644ea549089f0886c2551d2ac.html @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    See also
    parse(std::istream&, parser_callback_t) or parse(const string_t&, parser_callback_t) for examples
    Since
    version 1.0.0
    -

    Definition at line 820 of file json.hpp.

    +

    Definition at line 829 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html index 325d594f7..760b31369 100644 --- a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html +++ b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html @@ -270,7 +270,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    Since
    version 1.0.0
    -

    Definition at line 4765 of file json.hpp.

    +

    Definition at line 4774 of file json.hpp.

    @@ -280,7 +280,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html index 6fa7af20a..1faec0643 100644 --- a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html +++ b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html @@ -278,8 +278,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example demonstrates comparing several JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operator__less.cpp -o operator__less 
    Since
    version 1.0.0
    -

    Definition at line 4982 of file json.hpp.

    +

    Definition at line 4989 of file json.hpp.

    @@ -297,7 +297,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aacf6c869f6a9c66ac1bc99e93f310044.html b/classnlohmann_1_1basic__json_aacf6c869f6a9c66ac1bc99e93f310044.html index 3ba3fcf02..5c702ebdd 100644 --- a/classnlohmann_1_1basic__json_aacf6c869f6a9c66ac1bc99e93f310044.html +++ b/classnlohmann_1_1basic__json_aacf6c869f6a9c66ac1bc99e93f310044.html @@ -264,7 +264,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    See also
    number_integer_t – type for number values (integer)
    Since
    version 1.0.0
    -

    Definition at line 593 of file json.hpp.

    +

    Definition at line 602 of file json.hpp.

    @@ -274,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html b/classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html index 30ec69472..e10928e0b 100644 --- a/classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html +++ b/classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    2
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/operatorarray__key_type_const.cpp -o operatorarray__key_type_const 
    See also
    at(const typename object_t::key_type&) for access by reference with range checking
    @@ -283,7 +283,7 @@ operator[] with null" value() for access by value with a default value
    Since
    version 1.0.0
    -

    Definition at line 3119 of file json.hpp.

    +

    Definition at line 3128 of file json.hpp.

    @@ -293,7 +293,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html index d88060fff..cec315050 100644 --- a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html +++ b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html @@ -280,8 +280,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {
       "array": [
         1,
    @@ -299,7 +299,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 5278 of file json.hpp.

    +

    Definition at line 5285 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_aafa839f2a74dc1b5060314b3423143b8.html b/classnlohmann_1_1basic__json_aafa839f2a74dc1b5060314b3423143b8.html index 42b217bb3..4204e0f7e 100644 --- a/classnlohmann_1_1basic__json_aafa839f2a74dc1b5060314b3423143b8.html +++ b/classnlohmann_1_1basic__json_aafa839f2a74dc1b5060314b3423143b8.html @@ -250,7 +250,7 @@ template<template< typename U, typename V, typename...Args > class Obje

    Boolean values are stored directly inside a basic_json type.

    Since
    version 1.0.0
    -

    Definition at line 460 of file json.hpp.

    +

    Definition at line 469 of file json.hpp.

    @@ -260,7 +260,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab14e3503305622fb5ab01a7f490916e8.html b/classnlohmann_1_1basic__json_ab14e3503305622fb5ab01a7f490916e8.html index 79958c776..431c10990 100644 --- a/classnlohmann_1_1basic__json_ab14e3503305622fb5ab01a7f490916e8.html +++ b/classnlohmann_1_1basic__json_ab14e3503305622fb5ab01a7f490916e8.html @@ -281,16 +281,16 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4427
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4436
    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 4594 of file json.hpp.

    +

    Definition at line 4603 of file json.hpp.

    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ab2162bc76e10d8736cab9b2039956054.html b/classnlohmann_1_1basic__json_ab2162bc76e10d8736cab9b2039956054.html index d65ccfd1f..df73e419c 100644 --- a/classnlohmann_1_1basic__json_ab2162bc76e10d8736cab9b2039956054.html +++ b/classnlohmann_1_1basic__json_ab2162bc76e10d8736cab9b2039956054.html @@ -264,15 +264,15 @@ Illustration from cppreference.com
  • The complexity is constant.
  • -
    Example
    The following code shows an example for end.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6374
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows an example for end.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6394
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/end.cpp -o end 
    Since
    version 1.0.0
    -

    Definition at line 3824 of file json.hpp.

    +

    Definition at line 3833 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html b/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html index 7f7cac78d..d933d6db4 100644 --- a/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html +++ b/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html @@ -270,8 +270,8 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if<
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of several JSON integer number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows the construction of several JSON integer number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    42
     23
     1024
    @@ -283,7 +283,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if<
     basic_json(const int) – create a number value (integer)
    Since
    version 1.0.0
    -

    Definition at line 1230 of file json.hpp.

    +

    Definition at line 1239 of file json.hpp.

    @@ -293,7 +293,7 @@ template<typename CompatibleNumberIntegerType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_ab7d60fb6cb8e8f5740e588f9dc953819.html b/classnlohmann_1_1basic__json_ab7d60fb6cb8e8f5740e588f9dc953819.html index faa0039fd..e37527fb4 100644 --- a/classnlohmann_1_1basic__json_ab7d60fb6cb8e8f5740e588f9dc953819.html +++ b/classnlohmann_1_1basic__json_ab7d60fb6cb8e8f5740e588f9dc953819.html @@ -276,8 +276,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    [1,2,3,4]
     [1.2,2.3,3.4,5.6]
     [true,true,false,true]
    @@ -291,7 +291,7 @@ template<class CompatibleArrayType , typename std::enable_if<
     
    See also
    basic_json(const array_t&) – create an array value
    Since
    version 1.0.0
    -

    Definition at line 1030 of file json.hpp.

    +

    Definition at line 1039 of file json.hpp.

    @@ -301,7 +301,7 @@ template<class CompatibleArrayType , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_ab9a20bd1d391e9cb968db50c246f728d.html b/classnlohmann_1_1basic__json_ab9a20bd1d391e9cb968db50c246f728d.html index f06e07ebf..b5cd92adf 100644 --- a/classnlohmann_1_1basic__json_ab9a20bd1d391e9cb968db50c246f728d.html +++ b/classnlohmann_1_1basic__json_ab9a20bd1d391e9cb968db50c246f728d.html @@ -277,10 +277,10 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4098
    +
    Example
    The following code calls size on the different value types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4107
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    Output (play with this example online):
    0
     1
    @@ -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/size.cpp -o size 
    Since
    version 1.0.0
    -

    Definition at line 4098 of file json.hpp.

    +

    Definition at line 4107 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_ab9da2afc6f77295f25252725fde142a6.html b/classnlohmann_1_1basic__json_ab9da2afc6f77295f25252725fde142a6.html index 40e003aba..639e99a7f 100644 --- a/classnlohmann_1_1basic__json_ab9da2afc6f77295f25252725fde142a6.html +++ b/classnlohmann_1_1basic__json_ab9da2afc6f77295f25252725fde142a6.html @@ -263,11 +263,11 @@ 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 namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    a class to store JSON values
    Definition: json.hpp:188
    +
    Example
    The following code shows an example for back.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    4 
    5 int main()
    6 {
    7  // create JSON values
    8  json j_null;
    9  json j_boolean = true;
    10  json j_number_integer = 17;
    11  json j_number_float = 23.42;
    12  json j_object = {{"one", 1}, {"two", 2}};
    13  json j_object_empty(json::value_t::object);
    14  json j_array = {1, 2, 4, 8, 16};
    15  json j_array_empty(json::value_t::array);
    16  json j_string = "Hello, world";
    17 
    18  // call back()
    19  //std::cout << j_null.back() << '\n'; // would throw
    20  std::cout << j_boolean.back() << '\n';
    21  std::cout << j_number_integer.back() << '\n';
    22  std::cout << j_number_float.back() << '\n';
    23  std::cout << j_object.back() << '\n';
    24  //std::cout << j_object_empty.back() << '\n'; // would throw
    25  std::cout << j_array.back() << '\n';
    26  //std::cout << j_array_empty.back() << '\n'; // would throw
    27  std::cout << j_string.back() << '\n';
    28 }
    a class to store JSON values
    Definition: json.hpp:191
    object (unordered set of name/value pairs)
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    array (ordered collection of values)
    -
    reference back()
    access the last element
    Definition: json.hpp:3353
    +
    reference back()
    access the last element
    Definition: json.hpp:3362
    Output (play with this example online):
    true
     17
     23.42
    @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/back.cpp -o back 
    Since
    version 1.0.0
    -

    Definition at line 3363 of file json.hpp.

    +

    Definition at line 3372 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_abe8f3224ca4041908ddb466cb9caecf1.html b/classnlohmann_1_1basic__json_abe8f3224ca4041908ddb466cb9caecf1.html index 9dfaf026b..1a5a7129d 100644 --- a/classnlohmann_1_1basic__json_abe8f3224ca4041908ddb466cb9caecf1.html +++ b/classnlohmann_1_1basic__json_abe8f3224ca4041908ddb466cb9caecf1.html @@ -277,9 +277,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4160
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4169
    Output (play with this example online):
    0
     1
     1
    @@ -290,7 +290,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/max_size.cpp -o max_size 
    Since
    version 1.0.0
    -

    Definition at line 4160 of file json.hpp.

    +

    Definition at line 4169 of file json.hpp.

    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ac160789f17d206a5404981ca0957e303.html b/classnlohmann_1_1basic__json_ac160789f17d206a5404981ca0957e303.html index cbe0eda9c..ed6c90d09 100644 --- a/classnlohmann_1_1basic__json_ac160789f17d206a5404981ca0957e303.html +++ b/classnlohmann_1_1basic__json_ac160789f17d206a5404981ca0957e303.html @@ -263,8 +263,8 @@ template<template< typename U, typename V, typename...Args > class Obje
    Note
    This constructor allows to pass enums directly to a constructor. As C++ has no way of specifying the type of an anonymous enum explicitly, we can only rely on the fact that such values implicitly convert to int. As int may already be the same type of number_integer_t, we may need to switch off the constructor basic_json(const number_integer_t).
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of a JSON integer number value from an anonymous enum.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows the construction of a JSON integer number value from an anonymous enum.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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)
    @@ -272,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje basic_json(const CompatibleNumberIntegerType) – create a number value (integer) from a compatible number type
    Since
    version 1.0.0
    -

    Definition at line 1195 of file json.hpp.

    +

    Definition at line 1204 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_ac4011bd0781e51afe4994d2b09fd27e9.html b/classnlohmann_1_1basic__json_ac4011bd0781e51afe4994d2b09fd27e9.html index 79f9fe3cc..e07c3f17e 100644 --- a/classnlohmann_1_1basic__json_ac4011bd0781e51afe4994d2b09fd27e9.html +++ b/classnlohmann_1_1basic__json_ac4011bd0781e51afe4994d2b09fd27e9.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 216 of file json.hpp.

    +

    Definition at line 218 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ac8163abe518595f19dbee68db1caaaf7.html b/classnlohmann_1_1basic__json_ac8163abe518595f19dbee68db1caaaf7.html index 77e469872..ddf51516b 100644 --- a/classnlohmann_1_1basic__json_ac8163abe518595f19dbee68db1caaaf7.html +++ b/classnlohmann_1_1basic__json_ac8163abe518595f19dbee68db1caaaf7.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is object, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_object for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_object()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_object() << '\n';
    19  std::cout << j_boolean.is_object() << '\n';
    20  std::cout << j_number_integer.is_object() << '\n';
    21  std::cout << j_number_float.is_object() << '\n';
    22  std::cout << j_object.is_object() << '\n';
    23  std::cout << j_array.is_object() << '\n';
    24  std::cout << j_string.is_object() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2076
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code exemplifies is_object for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_object()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_object() << '\n';
    19  std::cout << j_boolean.is_object() << '\n';
    20  std::cout << j_number_integer.is_object() << '\n';
    21  std::cout << j_number_float.is_object() << '\n';
    22  std::cout << j_object.is_object() << '\n';
    23  std::cout << j_array.is_object() << '\n';
    24  std::cout << j_string.is_object() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2085
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    false
     false
     false
    @@ -269,7 +269,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 2076 of file json.hpp.

    +

    Definition at line 2085 of file json.hpp.

    @@ -279,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html b/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html index f1730aa3d..f15aa91ca 100644 --- a/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html +++ b/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html @@ -265,7 +265,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    See also
    object_t – type for an object value
    Since
    version 1.0.0
    -

    Definition at line 387 of file json.hpp.

    +

    Definition at line 396 of file json.hpp.

    @@ -275,7 +275,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ac943391891fcde0a71a15ce990e0f7f4.html b/classnlohmann_1_1basic__json_ac943391891fcde0a71a15ce990e0f7f4.html index 224c6309c..20d3625c4 100644 --- a/classnlohmann_1_1basic__json_ac943391891fcde0a71a15ce990e0f7f4.html +++ b/classnlohmann_1_1basic__json_ac943391891fcde0a71a15ce990e0f7f4.html @@ -273,14 +273,14 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows an example for the copy constructor.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    ["one","two",3,4.5,false] = ["one","two",3,4.5,false]
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__basic_json.cpp -o basic_json__basic_json 
    Since
    version 1.0.0
    -

    Definition at line 1683 of file json.hpp.

    +

    Definition at line 1692 of file json.hpp.

    @@ -290,7 +290,7 @@ true diff --git a/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html b/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html index a4397360e..51daf0b04 100644 --- a/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html +++ b/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html @@ -271,9 +271,9 @@ template<typename T , typename std::enable_if<
    Note
    This constructor would have the same signature as basic_json(const int value), so we need to switch this one off in case number_integer_t is the same as int. This is done via the helper type T.
    Complexity
    Constant.
    -
    Example
    The example below shows the construction of a JSON integer number value.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:528
    +
    Example
    The example below shows the construction of a JSON integer number value.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:537
    Output (play with this example online):
    42
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__number_integer_t.cpp -o basic_json__number_integer_t 
    See also
    basic_json(const int) – create a number value (integer)
    @@ -281,7 +281,7 @@ template<typename T , typename std::enable_if< basic_json(const CompatibleNumberIntegerType) – create a number value (integer) from a compatible number type
    Since
    version 1.0.0
    -

    Definition at line 1166 of file json.hpp.

    +

    Definition at line 1175 of file json.hpp.

    @@ -291,7 +291,7 @@ template<typename T , typename std::enable_if< diff --git a/classnlohmann_1_1basic__json_acdf4445333649ec94198f09a62144884.html b/classnlohmann_1_1basic__json_acdf4445333649ec94198f09a62144884.html index 445768339..d674e8459 100644 --- a/classnlohmann_1_1basic__json_acdf4445333649ec94198f09a62144884.html +++ b/classnlohmann_1_1basic__json_acdf4445333649ec94198f09a62144884.html @@ -264,15 +264,15 @@ Illustration from cppreference.com
  • The complexity is constant.
  • -
    Example
    The following code shows an example for begin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6374
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows an example for begin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6394
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/begin.cpp -o begin 
    Since
    version 1.0.0
    -

    Definition at line 3765 of file json.hpp.

    +

    Definition at line 3774 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html b/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html index 5f742e717..20a0ce817 100644 --- a/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html +++ b/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html @@ -263,7 +263,7 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Since
    version 1.0.0
    -

    Definition at line 434 of file json.hpp.

    +

    Definition at line 443 of file json.hpp.

    @@ -273,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ad1f617d29e8923dd40c89153f792b1bc.html b/classnlohmann_1_1basic__json_ad1f617d29e8923dd40c89153f792b1bc.html index afadc7870..4f92c5631 100644 --- a/classnlohmann_1_1basic__json_ad1f617d29e8923dd40c89153f792b1bc.html +++ b/classnlohmann_1_1basic__json_ad1f617d29e8923dd40c89153f792b1bc.html @@ -270,9 +270,9 @@ 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 namespace nlohmann;
    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:1510
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows an example for the object function.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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:1519
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {}
     {}
     {"one":1,"two":2}
    @@ -282,7 +282,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     array(std::initializer_list<basic_json>) – create a JSON array value from an initializer list
    Since
    version 1.0.0
    -

    Definition at line 1510 of file json.hpp.

    +

    Definition at line 1519 of file json.hpp.

    @@ -292,7 +292,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ad2c4513cef5d8db760c4b2d871eea42c.html b/classnlohmann_1_1basic__json_ad2c4513cef5d8db760c4b2d871eea42c.html index a5640c0a1..bcd7b90b3 100644 --- a/classnlohmann_1_1basic__json_ad2c4513cef5d8db760c4b2d871eea42c.html +++ b/classnlohmann_1_1basic__json_ad2c4513cef5d8db760c4b2d871eea42c.html @@ -254,7 +254,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 250 of file json.hpp.

    +

    Definition at line 251 of file json.hpp.

    @@ -264,7 +264,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ad497cbc4f80c8d79662ee6e19bf145dd.html b/classnlohmann_1_1basic__json_ad497cbc4f80c8d79662ee6e19bf145dd.html index 7a917c9c2..af9fde3df 100644 --- a/classnlohmann_1_1basic__json_ad497cbc4f80c8d79662ee6e19bf145dd.html +++ b/classnlohmann_1_1basic__json_ad497cbc4f80c8d79662ee6e19bf145dd.html @@ -298,12 +298,12 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3682
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3420
    +
    Example
    The example shows the result of erase for different JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3691
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3429
    Output (play with this example online):
    null
     null
     null
    @@ -318,7 +318,7 @@ null
     erase(const size_type) – removes the element from an array at the given index
    Since
    version 1.0.0
    -

    Definition at line 3525 of file json.hpp.

    +

    Definition at line 3534 of file json.hpp.

    @@ -328,7 +328,7 @@ null diff --git a/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html b/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html index 4983096de..6172f7ace 100644 --- a/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html +++ b/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html @@ -274,8 +274,8 @@ 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 JSON floating-point number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows the construction of several JSON floating-point number values from compatible types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    42.2299995422363
     null
     23.42
    @@ -283,7 +283,7 @@ null
     
    See also
    basic_json(const number_float_t) – create a number value (floating-point)
    Since
    version 1.0.0
    -

    Definition at line 1305 of file json.hpp.

    +

    Definition at line 1314 of file json.hpp.

    @@ -293,7 +293,7 @@ null diff --git a/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html b/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html index 27f3c05b2..ea952222e 100644 --- a/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html +++ b/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html @@ -265,15 +265,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3799
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:5832
    +
    Example
    The following code shows an example for cbegin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3808
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:5852
    Output (play with this example online):
    1
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/cbegin.cpp -o cbegin 
    Since
    version 1.0.0
    -

    Definition at line 3799 of file json.hpp.

    +

    Definition at line 3808 of file json.hpp.

    @@ -283,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html b/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html index 8891027a6..927172521 100644 --- a/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html +++ b/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html @@ -270,17 +270,17 @@ 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 namespace nlohmann;
    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 }
    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:1470
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2720
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how array elements can be read and written using at.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    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:1479
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2729
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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 2720 of file json.hpp.

    +

    Definition at line 2729 of file json.hpp.

    @@ -290,7 +290,7 @@ out of range: array index 5 is out of range diff --git a/classnlohmann_1_1basic__json_adbd4c16c9ac641b2a4736bc2c6787d83.html b/classnlohmann_1_1basic__json_adbd4c16c9ac641b2a4736bc2c6787d83.html index 84e30b16c..70db6e286 100644 --- a/classnlohmann_1_1basic__json_adbd4c16c9ac641b2a4736bc2c6787d83.html +++ b/classnlohmann_1_1basic__json_adbd4c16c9ac641b2a4736bc2c6787d83.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 219 of file json.hpp.

    +

    Definition at line 221 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html b/classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html index b4cbf975d..73e32d37f 100644 --- a/classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html +++ b/classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html @@ -272,8 +272,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    2
     
     {
    @@ -299,7 +299,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 3084 of file json.hpp.

    +

    Definition at line 3093 of file json.hpp.

    @@ -309,7 +309,7 @@ template<typename T , std::size_t n> diff --git a/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html b/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html index 8d00f0977..3796341a6 100644 --- a/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html +++ b/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html @@ -263,9 +263,9 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:1877
    +
    Example
    The following example shows the effect of different indent parameters to the result of the serialization.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:1886
    Output (play with this example online):
    {"one":1,"two":2}
     
     {"one":1,"two":2}
    @@ -304,7 +304,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     
    See also
    https://docs.python.org/2/library/json.html#json.dump
    Since
    version 1.0.0
    -

    Definition at line 1877 of file json.hpp.

    +

    Definition at line 1886 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_adeaef2ab021997a11a826c378c2365e1.html b/classnlohmann_1_1basic__json_adeaef2ab021997a11a826c378c2365e1.html index cf8bf581d..c804e03fe 100644 --- a/classnlohmann_1_1basic__json_adeaef2ab021997a11a826c378c2365e1.html +++ b/classnlohmann_1_1basic__json_adeaef2ab021997a11a826c378c2365e1.html @@ -262,14 +262,14 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below demonstrates boolean values.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    true
     false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__boolean_t.cpp -o basic_json__boolean_t 
    Since
    version 1.0.0
    -

    Definition at line 1132 of file json.hpp.

    +

    Definition at line 1141 of file json.hpp.

    @@ -279,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html b/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html index 68aec651f..f58025160 100644 --- a/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html +++ b/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html @@ -266,14 +266,14 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    23
     23
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/basic_json__copyassignment.cpp -o basic_json__copyassignment 
    Since
    version 1.0.0
    -

    Definition at line 1782 of file json.hpp.

    +

    Definition at line 1791 of file json.hpp.

    @@ -283,7 +283,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html index 6679f685f..6325664e3 100644 --- a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html +++ b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html @@ -274,8 +274,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88

    Output (play with this example online):

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

    +

    Definition at line 4951 of file json.hpp.

    @@ -293,7 +293,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html b/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html index b35b44790..9ce6acb7b 100644 --- a/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html +++ b/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html @@ -265,18 +265,18 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2490
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:528
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:593
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2499
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:537
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:602
    Output (play with this example online):
    17 17 17 17
     true
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/get__PointerType.cpp -o get__PointerType 
    See also
    get_ptr() for explicit pointer-member access
    Since
    version 1.0.0
    -

    Definition at line 2525 of file json.hpp.

    +

    Definition at line 2534 of file json.hpp.

    @@ -286,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html b/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html index f61c817ee..66ffac4fb 100644 --- a/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html +++ b/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html @@ -273,16 +273,16 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    value() for access by value with a default value
    -
    Since
    version 1.0.1
    +
    Since
    version 1.1.0
    -

    Definition at line 3201 of file json.hpp.

    +

    Definition at line 3210 of file json.hpp.

    @@ -292,7 +292,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html b/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html index 63cb409b9..c7f8bdbba 100644 --- a/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html +++ b/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is structured (array or object), false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_structured for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_structured()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_structured() << '\n';
    19  std::cout << j_boolean.is_structured() << '\n';
    20  std::cout << j_number_integer.is_structured() << '\n';
    21  std::cout << j_number_float.is_structured() << '\n';
    22  std::cout << j_object.is_structured() << '\n';
    23  std::cout << j_array.is_structured() << '\n';
    24  std::cout << j_string.is_structured() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:1949
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code exemplifies is_structured for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_structured()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_structured() << '\n';
    19  std::cout << j_boolean.is_structured() << '\n';
    20  std::cout << j_number_integer.is_structured() << '\n';
    21  std::cout << j_number_float.is_structured() << '\n';
    22  std::cout << j_object.is_structured() << '\n';
    23  std::cout << j_array.is_structured() << '\n';
    24  std::cout << j_string.is_structured() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:1958
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    false
     false
     false
    @@ -269,7 +269,7 @@ false
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/is_structured.cpp -o is_structured 
    Since
    version 1.0.0
    -

    Definition at line 1949 of file json.hpp.

    +

    Definition at line 1958 of file json.hpp.

    @@ -279,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html b/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html index 89151b305..aa0267868 100644 --- a/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html +++ b/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html @@ -243,7 +243,7 @@ template<template< typename U, typename V, typename...Args > class Obje
    -

    Definition at line 225 of file json.hpp.

    +

    Definition at line 226 of file json.hpp.

    @@ -253,7 +253,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html b/classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html index 38a3fc3ef..b370d4b0c 100644 --- a/classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html +++ b/classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html @@ -270,14 +270,14 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2720
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how array elements can be read using the [] operator.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2729
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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 2952 of file json.hpp.

    +

    Definition at line 2961 of file json.hpp.

    @@ -287,7 +287,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html index 686831d90..64ed86548 100644 --- a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html +++ b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html @@ -273,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje -

    Definition at line 755 of file json.hpp.

    +

    Definition at line 764 of file json.hpp.

    @@ -283,7 +283,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_af073eec08d2e68924098aef09e9a10ba.html b/classnlohmann_1_1basic__json_af073eec08d2e68924098aef09e9a10ba.html index 7e0b6908c..dd073fbbf 100644 --- a/classnlohmann_1_1basic__json_af073eec08d2e68924098aef09e9a10ba.html +++ b/classnlohmann_1_1basic__json_af073eec08d2e68924098aef09e9a10ba.html @@ -262,15 +262,15 @@ template<template< typename U, typename V, typename...Args > class Obje
    Complexity
    Constant.
    -
    Example
    The example below shows how JSON arrays can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    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:4632
    +
    Example
    The example below shows how JSON arrays can be swapped.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    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:4641
    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 4632 of file json.hpp.

    +

    Definition at line 4641 of file json.hpp.

    @@ -280,7 +280,7 @@ j2 = [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af0ebd1757acb971a6504b4acabf88584.html b/classnlohmann_1_1basic__json_af0ebd1757acb971a6504b4acabf88584.html index a0dd33438..06db306f6 100644 --- a/classnlohmann_1_1basic__json_af0ebd1757acb971a6504b4acabf88584.html +++ b/classnlohmann_1_1basic__json_af0ebd1757acb971a6504b4acabf88584.html @@ -264,15 +264,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:3882
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    +
    Example
    The following code shows an example for rbegin.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:3891
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    Output (play with this example online):
    5
     
    The example code above can be translated with
    g++ -std=c++11 -Isrc doc/examples/rbegin.cpp -o rbegin 
    Since
    version 1.0.0
    -

    Definition at line 3882 of file json.hpp.

    +

    Definition at line 3891 of file json.hpp.

    @@ -282,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html b/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html index 6488ff03f..086cd0d77 100644 --- a/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html +++ b/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html @@ -268,8 +268,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows the constructor with string literal parameter.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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
    @@ -277,7 +277,7 @@ template<template< typename U, typename V, typename...Args > class Obje basic_json(const CompatibleStringType&) – create a string value from a compatible string container
    Since
    version 1.0.0
    -

    Definition at line 1083 of file json.hpp.

    +

    Definition at line 1092 of file json.hpp.

    @@ -287,7 +287,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_af1e3f9e079136abca2530c8191c56292.html b/classnlohmann_1_1basic__json_af1e3f9e079136abca2530c8191c56292.html index 329547044..074acfbe9 100644 --- a/classnlohmann_1_1basic__json_af1e3f9e079136abca2530c8191c56292.html +++ b/classnlohmann_1_1basic__json_af1e3f9e079136abca2530c8191c56292.html @@ -304,9 +304,9 @@ 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 namespace nlohmann;
    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:8114
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how JSON values are created from initializer lists
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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:8170
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    {}
     {"one":1,"two":2}
     [1,2,3,4]
    @@ -318,7 +318,7 @@ initializer list"
     object(std::initializer_list<basic_json>) – create a JSON object value from an initializer list
    Since
    version 1.0.0
    -

    Definition at line 1378 of file json.hpp.

    +

    Definition at line 1387 of file json.hpp.

    @@ -328,7 +328,7 @@ initializer list" diff --git a/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html b/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html index 5cf30d62f..bb984a5e1 100644 --- a/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html +++ b/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html @@ -274,13 +274,13 @@ 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 namespace nlohmann;
    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:8114
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:820
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below demonstrates the parse function with and without callback function.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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:8170
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:829
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    the parser read a key of a value in an object
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5203
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:755
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5210
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:764
    Output (play with this example online):
    {
         "Image": {
             "Animated": false,
    @@ -319,7 +319,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 5203 of file json.hpp.

    +

    Definition at line 5210 of file json.hpp.

    @@ -329,7 +329,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_af661bc209bf22097e2f76607a11b56bf.html b/classnlohmann_1_1basic__json_af661bc209bf22097e2f76607a11b56bf.html index 3d9f15313..f0ffd5796 100644 --- a/classnlohmann_1_1basic__json_af661bc209bf22097e2f76607a11b56bf.html +++ b/classnlohmann_1_1basic__json_af661bc209bf22097e2f76607a11b56bf.html @@ -256,9 +256,9 @@ template<template< typename U, typename V, typename...Args > class Obje

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

    Returns
    true if type is boolean, false otherwise.
    Complexity
    Constant.
    -
    Example
    The following code exemplifies is_boolean for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_boolean()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_boolean() << '\n';
    19  std::cout << j_boolean.is_boolean() << '\n';
    20  std::cout << j_number_integer.is_boolean() << '\n';
    21  std::cout << j_number_float.is_boolean() << '\n';
    22  std::cout << j_object.is_boolean() << '\n';
    23  std::cout << j_array.is_boolean() << '\n';
    24  std::cout << j_string.is_boolean() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:1987
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code exemplifies is_boolean for all JSON types.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 is_boolean()
    17  std::cout << std::boolalpha;
    18  std::cout << j_null.is_boolean() << '\n';
    19  std::cout << j_boolean.is_boolean() << '\n';
    20  std::cout << j_number_integer.is_boolean() << '\n';
    21  std::cout << j_number_float.is_boolean() << '\n';
    22  std::cout << j_object.is_boolean() << '\n';
    23  std::cout << j_array.is_boolean() << '\n';
    24  std::cout << j_string.is_boolean() << '\n';
    25 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:1996
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    false
     true
     false
    @@ -269,7 +269,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 1987 of file json.hpp.

    +

    Definition at line 1996 of file json.hpp.

    @@ -279,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html b/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html index 5155e41ba..d48f5bd91 100644 --- a/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html +++ b/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html @@ -270,15 +270,15 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2720
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how array elements can be read using at.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2729
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    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 2764 of file json.hpp.

    +

    Definition at line 2773 of file json.hpp.

    @@ -288,7 +288,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html b/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html index 663a72bb1..782cb9636 100644 --- a/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html +++ b/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html @@ -270,8 +270,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    1
     42 42
     17.23 17
    @@ -286,7 +286,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 2682 of file json.hpp.

    +

    Definition at line 2691 of file json.hpp.

    @@ -296,7 +296,7 @@ array: [1,2,3,4,5] diff --git a/classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html b/classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html index 648544b7c..848c8eaaa 100644 --- a/classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html +++ b/classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html @@ -270,8 +270,8 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The example below shows how object elements can be read and written using the [] operator.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    2
     
     {
    @@ -297,7 +297,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 2993 of file json.hpp.

    +

    Definition at line 3002 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_af7d0adc984d04fc70c3d29fcd63e096a.html b/classnlohmann_1_1basic__json_af7d0adc984d04fc70c3d29fcd63e096a.html index 903dd3996..0f4b961ae 100644 --- a/classnlohmann_1_1basic__json_af7d0adc984d04fc70c3d29fcd63e096a.html +++ b/classnlohmann_1_1basic__json_af7d0adc984d04fc70c3d29fcd63e096a.html @@ -281,16 +281,16 @@ 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 namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:188
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4427
    +
    Example
    The example shows how insert is used.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    a class to store JSON values
    Definition: json.hpp:191
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4436
    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 4427 of file json.hpp.

    +

    Definition at line 4436 of file json.hpp.

    @@ -300,7 +300,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/classnlohmann_1_1basic__json_afc4223b5ad03b1b76e925374a8fff98e.html b/classnlohmann_1_1basic__json_afc4223b5ad03b1b76e925374a8fff98e.html index ddf9791b3..17bd05377 100644 --- a/classnlohmann_1_1basic__json_afc4223b5ad03b1b76e925374a8fff98e.html +++ b/classnlohmann_1_1basic__json_afc4223b5ad03b1b76e925374a8fff98e.html @@ -268,9 +268,9 @@ 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 namespace nlohmann;
    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 }
    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:1470
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    +
    Example
    The following code shows an example for the array function.
    1 #include <json.hpp>
    2 
    3 using namespace nlohmann;
    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 }
    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:1479
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    Output (play with this example online):
    []
     []
     [1,2,3,4]
    @@ -281,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
     object(std::initializer_list<basic_json>) – create a JSON object value from an initializer list
    Since
    version 1.0.0
    -

    Definition at line 1470 of file json.hpp.

    +

    Definition at line 1479 of file json.hpp.

    @@ -291,7 +291,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 2bb857098..09ad22129 100644 --- a/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -92,7 +92,7 @@ Files diff --git a/functions.html b/functions.html index ddab415b2..fcd372549 100644 --- a/functions.html +++ b/functions.html @@ -134,7 +134,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_0x7e.html b/functions_0x7e.html index 00caab95f..92d74ae4e 100644 --- a/functions_0x7e.html +++ b/functions_0x7e.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_b.html b/functions_b.html index 1b6079a17..532559287 100644 --- a/functions_b.html +++ b/functions_b.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_c.html b/functions_c.html index 876ca287d..9de96fd39 100644 --- a/functions_c.html +++ b/functions_c.html @@ -152,7 +152,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_d.html b/functions_d.html index df878037e..f6ed5494e 100644 --- a/functions_d.html +++ b/functions_d.html @@ -129,7 +129,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_e.html b/functions_e.html index 30075a3bd..7a899382b 100644 --- a/functions_e.html +++ b/functions_e.html @@ -131,7 +131,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_enum.html b/functions_enum.html index dc064af6c..8f0fcec2a 100644 --- a/functions_enum.html +++ b/functions_enum.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_f.html b/functions_f.html index 47cbf8f7d..cf148ad85 100644 --- a/functions_f.html +++ b/functions_f.html @@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func.html b/functions_func.html index 7b8e2c517..caf03fb2e 100644 --- a/functions_func.html +++ b/functions_func.html @@ -416,7 +416,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_g.html b/functions_g.html index 721ed0ead..44f7da8f3 100644 --- a/functions_g.html +++ b/functions_g.html @@ -134,7 +134,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_i.html b/functions_i.html index 108acfda3..80c91a8f6 100644 --- a/functions_i.html +++ b/functions_i.html @@ -167,7 +167,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_j.html b/functions_j.html index bebcc64e8..5413b9120 100644 --- a/functions_j.html +++ b/functions_j.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_k.html b/functions_k.html index ea482d1db..0dd43317c 100644 --- a/functions_k.html +++ b/functions_k.html @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_m.html b/functions_m.html index 5c160368c..b7eaba20c 100644 --- a/functions_m.html +++ b/functions_m.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_n.html b/functions_n.html index 420a3cf19..c8a1e36b4 100644 --- a/functions_n.html +++ b/functions_n.html @@ -128,7 +128,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_o.html b/functions_o.html index 613bf10fd..3d7466410 100644 --- a/functions_o.html +++ b/functions_o.html @@ -216,7 +216,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_p.html b/functions_p.html index f22cb6df7..2d65921de 100644 --- a/functions_p.html +++ b/functions_p.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_r.html b/functions_r.html index 200060f1f..d792c1caf 100644 --- a/functions_r.html +++ b/functions_r.html @@ -137,7 +137,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_rela.html b/functions_rela.html index abcab2073..da8b95d51 100644 --- a/functions_rela.html +++ b/functions_rela.html @@ -124,7 +124,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_s.html b/functions_s.html index 984dc3e0a..338362639 100644 --- a/functions_s.html +++ b/functions_s.html @@ -134,7 +134,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_t.html b/functions_t.html index 51d6a5e92..8a5cc2602 100644 --- a/functions_t.html +++ b/functions_t.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_type.html b/functions_type.html index 1757f9020..00c7e654b 100644 --- a/functions_type.html +++ b/functions_type.html @@ -162,7 +162,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_v.html b/functions_v.html index 75a49563c..dbe00f4f9 100644 --- a/functions_v.html +++ b/functions_v.html @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/graph_legend.html b/graph_legend.html index 66a5065ab..ca2284ff2 100644 --- a/graph_legend.html +++ b/graph_legend.html @@ -108,7 +108,7 @@ A yellow dashed arrow denotes a relation between a template instance and the tem diff --git a/hierarchy.html b/hierarchy.html index dcad75a46..f5e375482 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/index.html b/index.html index 39979c0b7..221c66a8e 100644 --- a/index.html +++ b/index.html @@ -92,7 +92,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/json_8hpp_source.html b/json_8hpp_source.html index 3eb653d9b..160cdb094 100644 --- a/json_8hpp_source.html +++ b/json_8hpp_source.html @@ -83,217 +83,217 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    json.hpp
    -
    1 
    38 #ifndef NLOHMANN_JSON_HPP
    39 #define NLOHMANN_JSON_HPP
    40 
    41 #include <algorithm>
    42 #include <array>
    43 #include <cassert>
    44 #include <ciso646>
    45 #include <cmath>
    46 #include <cstdio>
    47 #include <functional>
    48 #include <initializer_list>
    49 #include <iomanip>
    50 #include <iostream>
    51 #include <iterator>
    52 #include <limits>
    53 #include <map>
    54 #include <memory>
    55 #include <sstream>
    56 #include <string>
    57 #include <type_traits>
    58 #include <utility>
    59 #include <vector>
    60 
    61 // enable ssize_t on MinGW
    62 #ifdef __GNUC__
    63  #ifdef __MINGW32__
    64  #include <sys/types.h>
    65  #endif
    66 #endif
    67 
    68 // enable ssize_t for MSVC
    69 #ifdef _MSC_VER
    70  #include <basetsd.h>
    71  using ssize_t = SSIZE_T;
    72 #endif
    73 
    79 namespace nlohmann
    80 {
    81 
    82 
    87 namespace
    88 {
    93 template<typename T>
    94 struct has_mapped_type
    95 {
    96  private:
    97  template<typename C> static char test(typename C::mapped_type*);
    98  template<typename C> static char (&test(...))[2];
    99  public:
    100  static constexpr bool value = sizeof(test<T>(0)) == 1;
    101 };
    102 
    104 template<typename T>
    105 static bool approx(const T a, const T b)
    106 {
    107  return not (a > b or a < b);
    108 }
    109 }
    110 
    179 template <
    180  template<typename U, typename V, typename... Args> class ObjectType = std::map,
    181  template<typename U, typename... Args> class ArrayType = std::vector,
    182  class StringType = std::string,
    183  class BooleanType = bool,
    184  class NumberIntegerType = int64_t,
    185  class NumberFloatType = double,
    186  template<typename U> class AllocatorType = std::allocator
    187  >
    189 {
    190  private:
    192  using basic_json_t = basic_json<ObjectType,
    193  ArrayType,
    194  StringType,
    195  BooleanType,
    196  NumberIntegerType,
    197  NumberFloatType,
    198  AllocatorType>;
    199 
    200  public:
    201 
    203  // container types //
    205 
    208 
    211 
    214 
    216  using const_reference = const value_type&;
    217 
    219  using difference_type = std::ptrdiff_t;
    220 
    222  using size_type = std::size_t;
    223 
    225  using allocator_type = AllocatorType<basic_json>;
    226 
    228  using pointer = typename std::allocator_traits<allocator_type>::pointer;
    230  using const_pointer = typename std::allocator_traits<allocator_type>::const_pointer;
    231 
    232  // forward declaration
    233  template<typename Base> class json_reverse_iterator;
    234 
    236  class iterator;
    238  class const_iterator;
    243 
    245 
    246 
    251  {
    252  return allocator_type();
    253  }
    254 
    255 
    257  // JSON value data types //
    259 
    262 
    337  using object_t = ObjectType<StringType,
    338  basic_json,
    339  std::less<StringType>,
    340  AllocatorType<std::pair<const StringType,
    341  basic_json>>>;
    342 
    387  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
    388 
    434  using string_t = StringType;
    435 
    460  using boolean_t = BooleanType;
    461 
    528  using number_integer_t = NumberIntegerType;
    529 
    593  using number_float_t = NumberFloatType;
    594 
    596 
    597 
    599  // JSON type enumeration //
    601 
    612  enum class value_t : uint8_t
    613  {
    614  null,
    615  object,
    616  array,
    617  string,
    618  boolean,
    619  number_integer,
    620  number_float,
    621  discarded
    622  };
    623 
    624 
    625  private:
    627  template<typename T, typename... Args>
    628  static T* create(Args&& ... args)
    629  {
    630  AllocatorType<T> alloc;
    631  auto deleter = [&](T * object)
    632  {
    633  alloc.deallocate(object, 1);
    634  };
    635  std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
    636  alloc.construct(object.get(), std::forward<Args>(args)...);
    637  return object.release();
    638  }
    639 
    641  // JSON value storage //
    643 
    651  union json_value
    652  {
    654  object_t* object;
    656  array_t* array;
    658  string_t* string;
    660  boolean_t boolean;
    662  number_integer_t number_integer;
    664  number_float_t number_float;
    665 
    667  json_value() noexcept = default;
    669  json_value(boolean_t v) noexcept : boolean(v) {}
    671  json_value(number_integer_t v) noexcept : number_integer(v) {}
    673  json_value(number_float_t v) noexcept : number_float(v) {}
    675  json_value(value_t t)
    676  {
    677  switch (t)
    678  {
    679  case value_t::object:
    680  {
    681  object = create<object_t>();
    682  break;
    683  }
    684 
    685  case value_t::array:
    686  {
    687  array = create<array_t>();
    688  break;
    689  }
    690 
    691  case value_t::string:
    692  {
    693  string = create<string_t>("");
    694  break;
    695  }
    696 
    697  case value_t::boolean:
    698  {
    699  boolean = boolean_t(false);
    700  break;
    701  }
    702 
    703  case value_t::number_integer:
    704  {
    705  number_integer = number_integer_t(0);
    706  break;
    707  }
    708 
    709  case value_t::number_float:
    710  {
    711  number_float = number_float_t(0.0);
    712  break;
    713  }
    714 
    715  default:
    716  {
    717  break;
    718  }
    719  }
    720  }
    721 
    723  json_value(const string_t& value)
    724  {
    725  string = create<string_t>(value);
    726  }
    727 
    729  json_value(const object_t& value)
    730  {
    731  object = create<object_t>(value);
    732  }
    733 
    735  json_value(const array_t& value)
    736  {
    737  array = create<array_t>(value);
    738  }
    739  };
    740 
    741 
    742  public:
    744  // JSON parser callback //
    746 
    755  enum class parse_event_t : uint8_t
    756  {
    758  object_start,
    760  object_end,
    762  array_start,
    764  array_end,
    766  key,
    768  value
    769  };
    770 
    820  using parser_callback_t = std::function<bool(int depth, parse_event_t event, basic_json& parsed)>;
    821 
    822 
    824  // constructors //
    826 
    829 
    868  : m_type(value_type), m_value(value_type)
    869  {}
    870 
    890  basic_json() noexcept = default;
    891 
    911  basic_json(std::nullptr_t) noexcept
    912  : basic_json(value_t::null)
    913  {}
    914 
    934  basic_json(const object_t& val)
    935  : m_type(value_t::object), m_value(val)
    936  {}
    937 
    961  template <class CompatibleObjectType, typename
    962  std::enable_if<
    963  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    964  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    965  = 0>
    966  basic_json(const CompatibleObjectType& val)
    967  : m_type(value_t::object)
    968  {
    969  using std::begin;
    970  using std::end;
    971  m_value.object = create<object_t>(begin(val), end(val));
    972  }
    973 
    993  basic_json(const array_t& val)
    994  : m_type(value_t::array), m_value(val)
    995  {}
    996 
    1020  template <class CompatibleArrayType, typename
    1021  std::enable_if<
    1022  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1023  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1024  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1025  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1026  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1027  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1028  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1029  = 0>
    1030  basic_json(const CompatibleArrayType& val)
    1031  : m_type(value_t::array)
    1032  {
    1033  using std::begin;
    1034  using std::end;
    1035  m_value.array = create<array_t>(begin(val), end(val));
    1036  }
    1037 
    1059  basic_json(const string_t& val)
    1060  : m_type(value_t::string), m_value(val)
    1061  {}
    1062 
    1083  basic_json(const typename string_t::value_type* val)
    1084  : basic_json(string_t(val))
    1085  {}
    1086 
    1110  template <class CompatibleStringType, typename
    1111  std::enable_if<
    1112  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1113  = 0>
    1114  basic_json(const CompatibleStringType& val)
    1115  : basic_json(string_t(val))
    1116  {}
    1117 
    1133  : m_type(value_t::boolean), m_value(val)
    1134  {}
    1135 
    1161  template<typename T,
    1162  typename std::enable_if<
    1163  not (std::is_same<T, int>::value)
    1164  and std::is_same<T, number_integer_t>::value
    1165  , int>::type = 0>
    1167  : m_type(value_t::number_integer), m_value(val)
    1168  {}
    1169 
    1195  basic_json(const int val)
    1196  : m_type(value_t::number_integer),
    1197  m_value(static_cast<number_integer_t>(val))
    1198  {}
    1199 
    1225  template<typename CompatibleNumberIntegerType, typename
    1226  std::enable_if<
    1227  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1228  std::numeric_limits<CompatibleNumberIntegerType>::is_integer, CompatibleNumberIntegerType>::type
    1229  = 0>
    1230  basic_json(const CompatibleNumberIntegerType val) noexcept
    1231  : m_type(value_t::number_integer),
    1232  m_value(static_cast<number_integer_t>(val))
    1233  {}
    1234 
    1260  : m_type(value_t::number_float), m_value(val)
    1261  {
    1262  // replace infinity and NAN by null
    1263  if (not std::isfinite(val))
    1264  {
    1265  m_type = value_t::null;
    1266  m_value = json_value();
    1267  }
    1268  }
    1269 
    1300  template<typename CompatibleNumberFloatType, typename = typename
    1301  std::enable_if<
    1302  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1303  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1304  >
    1305  basic_json(const CompatibleNumberFloatType val) noexcept
    1306  : basic_json(number_float_t(val))
    1307  {}
    1308 
    1378  basic_json(std::initializer_list<basic_json> init,
    1379  bool type_deduction = true,
    1380  value_t manual_type = value_t::array)
    1381  {
    1382  // the initializer list could describe an object
    1383  bool is_an_object = true;
    1384 
    1385  // check if each element is an array with two elements whose first
    1386  // element is a string
    1387  for (const auto& element : init)
    1388  {
    1389  if (not element.is_array() or element.size() != 2
    1390  or not element[0].is_string())
    1391  {
    1392  // we found an element that makes it impossible to use the
    1393  // initializer list as object
    1394  is_an_object = false;
    1395  break;
    1396  }
    1397  }
    1398 
    1399  // adjust type if type deduction is not wanted
    1400  if (not type_deduction)
    1401  {
    1402  // if array is wanted, do not create an object though possible
    1403  if (manual_type == value_t::array)
    1404  {
    1405  is_an_object = false;
    1406  }
    1407 
    1408  // if object is wanted but impossible, throw an exception
    1409  if (manual_type == value_t::object and not is_an_object)
    1410  {
    1411  throw std::domain_error("cannot create object from initializer list");
    1412  }
    1413  }
    1414 
    1415  if (is_an_object)
    1416  {
    1417  // the initializer list is a list of pairs -> create object
    1418  m_type = value_t::object;
    1419  m_value = value_t::object;
    1420 
    1421  assert(m_value.object != nullptr);
    1422 
    1423  for (auto& element : init)
    1424  {
    1425  m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1]));
    1426  }
    1427  }
    1428  else
    1429  {
    1430  // the initializer list describes an array -> create array
    1431  m_type = value_t::array;
    1432  m_value.array = create<array_t>(std::move(init));
    1433  }
    1434  }
    1435 
    1470  static basic_json array(std::initializer_list<basic_json> init =
    1471  std::initializer_list<basic_json>())
    1472  {
    1473  return basic_json(init, false, value_t::array);
    1474  }
    1475 
    1510  static basic_json object(std::initializer_list<basic_json> init =
    1511  std::initializer_list<basic_json>())
    1512  {
    1513  return basic_json(init, false, value_t::object);
    1514  }
    1515 
    1534  basic_json(size_type cnt, const basic_json& val)
    1535  : m_type(value_t::array)
    1536  {
    1537  m_value.array = create<array_t>(cnt, val);
    1538  }
    1539 
    1574  template <class InputIT, typename
    1575  std::enable_if<
    1576  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1577  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1578  , int>::type
    1579  = 0>
    1580  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1581  {
    1582  // make sure iterator fits the current value
    1583  if (first.m_object != last.m_object)
    1584  {
    1585  throw std::domain_error("iterators are not compatible");
    1586  }
    1587 
    1588  // check if iterator range is complete for primitive values
    1589  switch (m_type)
    1590  {
    1591  case value_t::boolean:
    1592  case value_t::number_float:
    1593  case value_t::number_integer:
    1594  case value_t::string:
    1595  {
    1596  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1597  {
    1598  throw std::out_of_range("iterators out of range");
    1599  }
    1600  break;
    1601  }
    1602 
    1603  default:
    1604  {
    1605  break;
    1606  }
    1607  }
    1608 
    1609  switch (m_type)
    1610  {
    1611  case value_t::number_integer:
    1612  {
    1613  assert(first.m_object != nullptr);
    1614  m_value.number_integer = first.m_object->m_value.number_integer;
    1615  break;
    1616  }
    1617 
    1618  case value_t::number_float:
    1619  {
    1620  assert(first.m_object != nullptr);
    1621  m_value.number_float = first.m_object->m_value.number_float;
    1622  break;
    1623  }
    1624 
    1625  case value_t::boolean:
    1626  {
    1627  assert(first.m_object != nullptr);
    1628  m_value.boolean = first.m_object->m_value.boolean;
    1629  break;
    1630  }
    1631 
    1632  case value_t::string:
    1633  {
    1634  assert(first.m_object != nullptr);
    1635  m_value = *first.m_object->m_value.string;
    1636  break;
    1637  }
    1638 
    1639  case value_t::object:
    1640  {
    1641  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1642  break;
    1643  }
    1644 
    1645  case value_t::array:
    1646  {
    1647  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1648  break;
    1649  }
    1650 
    1651  default:
    1652  {
    1653  assert(first.m_object != nullptr);
    1654  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1655  }
    1656  }
    1657  }
    1658 
    1660  // other constructors and destructor //
    1662 
    1683  basic_json(const basic_json& other)
    1684  : m_type(other.m_type)
    1685  {
    1686  switch (m_type)
    1687  {
    1688  case value_t::object:
    1689  {
    1690  assert(other.m_value.object != nullptr);
    1691  m_value = *other.m_value.object;
    1692  break;
    1693  }
    1694 
    1695  case value_t::array:
    1696  {
    1697  assert(other.m_value.array != nullptr);
    1698  m_value = *other.m_value.array;
    1699  break;
    1700  }
    1701 
    1702  case value_t::string:
    1703  {
    1704  assert(other.m_value.string != nullptr);
    1705  m_value = *other.m_value.string;
    1706  break;
    1707  }
    1708 
    1709  case value_t::boolean:
    1710  {
    1711  m_value = other.m_value.boolean;
    1712  break;
    1713  }
    1714 
    1715  case value_t::number_integer:
    1716  {
    1717  m_value = other.m_value.number_integer;
    1718  break;
    1719  }
    1720 
    1721  case value_t::number_float:
    1722  {
    1723  m_value = other.m_value.number_float;
    1724  break;
    1725  }
    1726 
    1727  default:
    1728  {
    1729  break;
    1730  }
    1731  }
    1732  }
    1733 
    1752  basic_json(basic_json&& other) noexcept
    1753  : m_type(std::move(other.m_type)),
    1754  m_value(std::move(other.m_value))
    1755  {
    1756  // invalidate payload
    1757  other.m_type = value_t::null;
    1758  other.m_value = {};
    1759  }
    1760 
    1782  reference& operator=(basic_json other) noexcept (
    1783  std::is_nothrow_move_constructible<value_t>::value and
    1784  std::is_nothrow_move_assignable<value_t>::value and
    1785  std::is_nothrow_move_constructible<json_value>::value and
    1786  std::is_nothrow_move_assignable<json_value>::value
    1787  )
    1788  {
    1789  using std::swap;
    1790  swap(m_type, other.m_type);
    1791  swap(m_value, other.m_value);
    1792  return *this;
    1793  }
    1794 
    1809  {
    1810  switch (m_type)
    1811  {
    1812  case value_t::object:
    1813  {
    1814  AllocatorType<object_t> alloc;
    1815  alloc.destroy(m_value.object);
    1816  alloc.deallocate(m_value.object, 1);
    1817  break;
    1818  }
    1819 
    1820  case value_t::array:
    1821  {
    1822  AllocatorType<array_t> alloc;
    1823  alloc.destroy(m_value.array);
    1824  alloc.deallocate(m_value.array, 1);
    1825  break;
    1826  }
    1827 
    1828  case value_t::string:
    1829  {
    1830  AllocatorType<string_t> alloc;
    1831  alloc.destroy(m_value.string);
    1832  alloc.deallocate(m_value.string, 1);
    1833  break;
    1834  }
    1835 
    1836  default:
    1837  {
    1838  // all other types need no specific destructor
    1839  break;
    1840  }
    1841  }
    1842  }
    1843 
    1845 
    1846  public:
    1848  // object inspection //
    1850 
    1853 
    1877  string_t dump(const int indent = -1) const
    1878  {
    1879  std::stringstream ss;
    1880 
    1881  if (indent >= 0)
    1882  {
    1883  dump(ss, true, static_cast<unsigned int>(indent));
    1884  }
    1885  else
    1886  {
    1887  dump(ss, false, 0);
    1888  }
    1889 
    1890  return ss.str();
    1891  }
    1892 
    1908  value_t type() const noexcept
    1909  {
    1910  return m_type;
    1911  }
    1912 
    1929  bool is_primitive() const noexcept
    1930  {
    1931  return is_null() or is_string() or is_boolean() or is_number();
    1932  }
    1933 
    1949  bool is_structured() const noexcept
    1950  {
    1951  return is_array() or is_object();
    1952  }
    1953 
    1968  bool is_null() const noexcept
    1969  {
    1970  return m_type == value_t::null;
    1971  }
    1972 
    1987  bool is_boolean() const noexcept
    1988  {
    1989  return m_type == value_t::boolean;
    1990  }
    1991 
    2011  bool is_number() const noexcept
    2012  {
    2013  return is_number_integer() or is_number_float();
    2014  }
    2015 
    2034  bool is_number_integer() const noexcept
    2035  {
    2036  return m_type == value_t::number_integer;
    2037  }
    2038 
    2057  bool is_number_float() const noexcept
    2058  {
    2059  return m_type == value_t::number_float;
    2060  }
    2061 
    2076  bool is_object() const noexcept
    2077  {
    2078  return m_type == value_t::object;
    2079  }
    2080 
    2095  bool is_array() const noexcept
    2096  {
    2097  return m_type == value_t::array;
    2098  }
    2099 
    2114  bool is_string() const noexcept
    2115  {
    2116  return m_type == value_t::string;
    2117  }
    2118 
    2138  bool is_discarded() const noexcept
    2139  {
    2140  return m_type == value_t::discarded;
    2141  }
    2142 
    2158  operator value_t() const noexcept
    2159  {
    2160  return m_type;
    2161  }
    2162 
    2164 
    2165  private:
    2167  // value access //
    2169 
    2171  template <class T, typename
    2172  std::enable_if<
    2173  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2174  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2175  , int>::type = 0>
    2176  T get_impl(T*) const
    2177  {
    2178  if (is_object())
    2179  {
    2180  assert(m_value.object != nullptr);
    2181  return T(m_value.object->begin(), m_value.object->end());
    2182  }
    2183  else
    2184  {
    2185  throw std::domain_error("type must be object, but is " + type_name());
    2186  }
    2187  }
    2188 
    2190  object_t get_impl(object_t*) const
    2191  {
    2192  if (is_object())
    2193  {
    2194  assert(m_value.object != nullptr);
    2195  return *(m_value.object);
    2196  }
    2197  else
    2198  {
    2199  throw std::domain_error("type must be object, but is " + type_name());
    2200  }
    2201  }
    2202 
    2204  template <class T, typename
    2205  std::enable_if<
    2206  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2207  not std::is_same<basic_json_t, typename T::value_type>::value and
    2208  not std::is_arithmetic<T>::value and
    2209  not std::is_convertible<std::string, T>::value and
    2210  not has_mapped_type<T>::value
    2211  , int>::type = 0>
    2212  T get_impl(T*) const
    2213  {
    2214  if (is_array())
    2215  {
    2216  T to_vector;
    2217  assert(m_value.array != nullptr);
    2218  std::transform(m_value.array->begin(), m_value.array->end(),
    2219  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2220  {
    2221  return i.get<typename T::value_type>();
    2222  });
    2223  return to_vector;
    2224  }
    2225  else
    2226  {
    2227  throw std::domain_error("type must be array, but is " + type_name());
    2228  }
    2229  }
    2230 
    2232  template <class T, typename
    2233  std::enable_if<
    2234  std::is_convertible<basic_json_t, T>::value and
    2235  not std::is_same<basic_json_t, T>::value
    2236  , int>::type = 0>
    2237  std::vector<T> get_impl(std::vector<T>*) const
    2238  {
    2239  if (is_array())
    2240  {
    2241  std::vector<T> to_vector;
    2242  assert(m_value.array != nullptr);
    2243  to_vector.reserve(m_value.array->size());
    2244  std::transform(m_value.array->begin(), m_value.array->end(),
    2245  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2246  {
    2247  return i.get<T>();
    2248  });
    2249  return to_vector;
    2250  }
    2251  else
    2252  {
    2253  throw std::domain_error("type must be array, but is " + type_name());
    2254  }
    2255  }
    2256 
    2258  template <class T, typename
    2259  std::enable_if<
    2260  std::is_same<basic_json, typename T::value_type>::value and
    2261  not has_mapped_type<T>::value
    2262  , int>::type = 0>
    2263  T get_impl(T*) const
    2264  {
    2265  if (is_array())
    2266  {
    2267  assert(m_value.array != nullptr);
    2268  return T(m_value.array->begin(), m_value.array->end());
    2269  }
    2270  else
    2271  {
    2272  throw std::domain_error("type must be array, but is " + type_name());
    2273  }
    2274  }
    2275 
    2277  array_t get_impl(array_t*) const
    2278  {
    2279  if (is_array())
    2280  {
    2281  assert(m_value.array != nullptr);
    2282  return *(m_value.array);
    2283  }
    2284  else
    2285  {
    2286  throw std::domain_error("type must be array, but is " + type_name());
    2287  }
    2288  }
    2289 
    2291  template <typename T, typename
    2292  std::enable_if<
    2293  std::is_convertible<string_t, T>::value
    2294  , int>::type = 0>
    2295  T get_impl(T*) const
    2296  {
    2297  if (is_string())
    2298  {
    2299  assert(m_value.string != nullptr);
    2300  return *m_value.string;
    2301  }
    2302  else
    2303  {
    2304  throw std::domain_error("type must be string, but is " + type_name());
    2305  }
    2306  }
    2307 
    2309  template<typename T, typename
    2310  std::enable_if<
    2311  std::is_arithmetic<T>::value
    2312  , int>::type = 0>
    2313  T get_impl(T*) const
    2314  {
    2315  switch (m_type)
    2316  {
    2317  case value_t::number_integer:
    2318  {
    2319  return static_cast<T>(m_value.number_integer);
    2320  }
    2321 
    2322  case value_t::number_float:
    2323  {
    2324  return static_cast<T>(m_value.number_float);
    2325  }
    2326 
    2327  default:
    2328  {
    2329  throw std::domain_error("type must be number, but is " + type_name());
    2330  }
    2331  }
    2332  }
    2333 
    2335  boolean_t get_impl(boolean_t*) const
    2336  {
    2337  if (is_boolean())
    2338  {
    2339  return m_value.boolean;
    2340  }
    2341  else
    2342  {
    2343  throw std::domain_error("type must be boolean, but is " + type_name());
    2344  }
    2345  }
    2346 
    2348  object_t* get_impl_ptr(object_t*) noexcept
    2349  {
    2350  return is_object() ? m_value.object : nullptr;
    2351  }
    2352 
    2354  const object_t* get_impl_ptr(const object_t*) const noexcept
    2355  {
    2356  return is_object() ? m_value.object : nullptr;
    2357  }
    2358 
    2360  array_t* get_impl_ptr(array_t*) noexcept
    2361  {
    2362  return is_array() ? m_value.array : nullptr;
    2363  }
    2364 
    2366  const array_t* get_impl_ptr(const array_t*) const noexcept
    2367  {
    2368  return is_array() ? m_value.array : nullptr;
    2369  }
    2370 
    2372  string_t* get_impl_ptr(string_t*) noexcept
    2373  {
    2374  return is_string() ? m_value.string : nullptr;
    2375  }
    2376 
    2378  const string_t* get_impl_ptr(const string_t*) const noexcept
    2379  {
    2380  return is_string() ? m_value.string : nullptr;
    2381  }
    2382 
    2384  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2385  {
    2386  return is_boolean() ? &m_value.boolean : nullptr;
    2387  }
    2388 
    2390  const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2391  {
    2392  return is_boolean() ? &m_value.boolean : nullptr;
    2393  }
    2394 
    2396  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2397  {
    2398  return is_number_integer() ? &m_value.number_integer : nullptr;
    2399  }
    2400 
    2402  const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2403  {
    2404  return is_number_integer() ? &m_value.number_integer : nullptr;
    2405  }
    2406 
    2408  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2409  {
    2410  return is_number_float() ? &m_value.number_float : nullptr;
    2411  }
    2412 
    2414  const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2415  {
    2416  return is_number_float() ? &m_value.number_float : nullptr;
    2417  }
    2418 
    2430  template<typename ReferenceType, typename ThisType>
    2431  static ReferenceType get_ref_impl(ThisType& obj)
    2432  {
    2433  // delegate the call to get_ptr<>()
    2434  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2435  auto ptr = obj.template get_ptr<PointerType>();
    2436 
    2437  if (ptr != nullptr)
    2438  {
    2439  return *ptr;
    2440  }
    2441  else
    2442  {
    2443  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2444  obj.type_name());
    2445  }
    2446  }
    2447 
    2448  public:
    2449 
    2452 
    2486  template<typename ValueType, typename
    2487  std::enable_if<
    2488  not std::is_pointer<ValueType>::value
    2489  , int>::type = 0>
    2490  ValueType get() const
    2491  {
    2492  return get_impl(static_cast<ValueType*>(nullptr));
    2493  }
    2494 
    2521  template<typename PointerType, typename
    2522  std::enable_if<
    2523  std::is_pointer<PointerType>::value
    2524  , int>::type = 0>
    2525  PointerType get() noexcept
    2526  {
    2527  // delegate the call to get_ptr
    2528  return get_ptr<PointerType>();
    2529  }
    2530 
    2535  template<typename PointerType, typename
    2536  std::enable_if<
    2537  std::is_pointer<PointerType>::value
    2538  , int>::type = 0>
    2539  const PointerType get() const noexcept
    2540  {
    2541  // delegate the call to get_ptr
    2542  return get_ptr<PointerType>();
    2543  }
    2544 
    2570  template<typename PointerType, typename
    2571  std::enable_if<
    2572  std::is_pointer<PointerType>::value
    2573  , int>::type = 0>
    2574  PointerType get_ptr() noexcept
    2575  {
    2576  // delegate the call to get_impl_ptr<>()
    2577  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2578  }
    2579 
    2584  template<typename PointerType, typename
    2585  std::enable_if<
    2586  std::is_pointer<PointerType>::value
    2587  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2588  , int>::type = 0>
    2589  const PointerType get_ptr() const noexcept
    2590  {
    2591  // delegate the call to get_impl_ptr<>() const
    2592  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2593  }
    2594 
    2621  template<typename ReferenceType, typename
    2622  std::enable_if<
    2623  std::is_reference<ReferenceType>::value
    2624  , int>::type = 0>
    2625  ReferenceType get_ref()
    2626  {
    2627  // delegate call to get_ref_impl
    2628  return get_ref_impl<ReferenceType>(*this);
    2629  }
    2630 
    2635  template<typename ReferenceType, typename
    2636  std::enable_if<
    2637  std::is_reference<ReferenceType>::value
    2638  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2639  , int>::type = 0>
    2640  ReferenceType get_ref() const
    2641  {
    2642  // delegate call to get_ref_impl
    2643  return get_ref_impl<ReferenceType>(*this);
    2644  }
    2645 
    2674  template < typename ValueType, typename
    2675  std::enable_if <
    2676  not std::is_pointer<ValueType>::value
    2677  and not std::is_same<ValueType, typename string_t::value_type>::value
    2678 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2679  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2680 #endif
    2681  , int >::type = 0 >
    2682  operator ValueType() const
    2683  {
    2684  // delegate the call to get<>() const
    2685  return get<ValueType>();
    2686  }
    2687 
    2689 
    2690 
    2692  // element access //
    2694 
    2697 
    2721  {
    2722  // at only works for arrays
    2723  if (is_array())
    2724  {
    2725  try
    2726  {
    2727  assert(m_value.array != nullptr);
    2728  return m_value.array->at(idx);
    2729  }
    2730  catch (std::out_of_range&)
    2731  {
    2732  // create better exception explanation
    2733  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2734  }
    2735  }
    2736  else
    2737  {
    2738  throw std::domain_error("cannot use at() with " + type_name());
    2739  }
    2740  }
    2741 
    2765  {
    2766  // at only works for arrays
    2767  if (is_array())
    2768  {
    2769  try
    2770  {
    2771  assert(m_value.array != nullptr);
    2772  return m_value.array->at(idx);
    2773  }
    2774  catch (std::out_of_range&)
    2775  {
    2776  // create better exception explanation
    2777  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2778  }
    2779  }
    2780  else
    2781  {
    2782  throw std::domain_error("cannot use at() with " + type_name());
    2783  }
    2784  }
    2785 
    2812  reference at(const typename object_t::key_type& key)
    2813  {
    2814  // at only works for objects
    2815  if (is_object())
    2816  {
    2817  try
    2818  {
    2819  assert(m_value.object != nullptr);
    2820  return m_value.object->at(key);
    2821  }
    2822  catch (std::out_of_range&)
    2823  {
    2824  // create better exception explanation
    2825  throw std::out_of_range("key '" + key + "' not found");
    2826  }
    2827  }
    2828  else
    2829  {
    2830  throw std::domain_error("cannot use at() with " + type_name());
    2831  }
    2832  }
    2833 
    2860  const_reference at(const typename object_t::key_type& key) const
    2861  {
    2862  // at only works for objects
    2863  if (is_object())
    2864  {
    2865  try
    2866  {
    2867  assert(m_value.object != nullptr);
    2868  return m_value.object->at(key);
    2869  }
    2870  catch (std::out_of_range&)
    2871  {
    2872  // create better exception explanation
    2873  throw std::out_of_range("key '" + key + "' not found");
    2874  }
    2875  }
    2876  else
    2877  {
    2878  throw std::domain_error("cannot use at() with " + type_name());
    2879  }
    2880  }
    2881 
    2908  {
    2909  // implicitly convert null to object
    2910  if (is_null())
    2911  {
    2912  m_type = value_t::array;
    2913  m_value.array = create<array_t>();
    2914  }
    2915 
    2916  // [] only works for arrays
    2917  if (is_array())
    2918  {
    2919  assert(m_value.array != nullptr);
    2920  for (size_t i = m_value.array->size(); i <= idx; ++i)
    2921  {
    2922  m_value.array->push_back(basic_json());
    2923  }
    2924 
    2925  return m_value.array->operator[](idx);
    2926  }
    2927  else
    2928  {
    2929  throw std::domain_error("cannot use operator[] with " + type_name());
    2930  }
    2931  }
    2932 
    2953  {
    2954  // at only works for arrays
    2955  if (is_array())
    2956  {
    2957  assert(m_value.array != nullptr);
    2958  return m_value.array->operator[](idx);
    2959  }
    2960  else
    2961  {
    2962  throw std::domain_error("cannot use operator[] with " + type_name());
    2963  }
    2964  }
    2965 
    2993  reference operator[](const typename object_t::key_type& key)
    2994  {
    2995  // implicitly convert null to object
    2996  if (is_null())
    2997  {
    2998  m_type = value_t::object;
    2999  m_value.object = create<object_t>();
    3000  }
    3001 
    3002  // [] only works for objects
    3003  if (is_object())
    3004  {
    3005  assert(m_value.object != nullptr);
    3006  return m_value.object->operator[](key);
    3007  }
    3008  else
    3009  {
    3010  throw std::domain_error("cannot use operator[] with " + type_name());
    3011  }
    3012  }
    3013 
    3041  const_reference operator[](const typename object_t::key_type& key) const
    3042  {
    3043  // [] only works for objects
    3044  if (is_object())
    3045  {
    3046  assert(m_value.object != nullptr);
    3047  assert(m_value.object->find(key) != m_value.object->end());
    3048  return m_value.object->find(key)->second;
    3049  }
    3050  else
    3051  {
    3052  throw std::domain_error("cannot use operator[] with " + type_name());
    3053  }
    3054  }
    3055 
    3083  template<typename T, std::size_t n>
    3084  reference operator[](T * (&key)[n])
    3085  {
    3086  return operator[](static_cast<const T>(key));
    3087  }
    3088 
    3118  template<typename T, std::size_t n>
    3119  const_reference operator[](T * (&key)[n]) const
    3120  {
    3121  return operator[](static_cast<const T>(key));
    3122  }
    3123 
    3151  template<typename T>
    3153  {
    3154  // implicitly convert null to object
    3155  if (is_null())
    3156  {
    3157  m_type = value_t::object;
    3158  m_value = value_t::object;
    3159  }
    3160 
    3161  // at only works for objects
    3162  if (is_object())
    3163  {
    3164  assert(m_value.object != nullptr);
    3165  return m_value.object->operator[](key);
    3166  }
    3167  else
    3168  {
    3169  throw std::domain_error("cannot use operator[] with " + type_name());
    3170  }
    3171  }
    3172 
    3200  template<typename T>
    3202  {
    3203  // at only works for objects
    3204  if (is_object())
    3205  {
    3206  assert(m_value.object != nullptr);
    3207  assert(m_value.object->find(key) != m_value.object->end());
    3208  return m_value.object->find(key)->second;
    3209  }
    3210  else
    3211  {
    3212  throw std::domain_error("cannot use operator[] with " + type_name());
    3213  }
    3214  }
    3215 
    3264  template <class ValueType, typename
    3265  std::enable_if<
    3266  std::is_convertible<basic_json_t, ValueType>::value
    3267  , int>::type = 0>
    3268  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3269  {
    3270  // at only works for objects
    3271  if (is_object())
    3272  {
    3273  // if key is found, return value and given default value otherwise
    3274  const auto it = find(key);
    3275  if (it != end())
    3276  {
    3277  return *it;
    3278  }
    3279  else
    3280  {
    3281  return default_value;
    3282  }
    3283  }
    3284  else
    3285  {
    3286  throw std::domain_error("cannot use value() with " + type_name());
    3287  }
    3288  }
    3289 
    3294  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3295  {
    3296  return value(key, string_t(default_value));
    3297  }
    3298 
    3320  {
    3321  return *begin();
    3322  }
    3323 
    3328  {
    3329  return *cbegin();
    3330  }
    3331 
    3354  {
    3355  auto tmp = end();
    3356  --tmp;
    3357  return *tmp;
    3358  }
    3359 
    3364  {
    3365  auto tmp = cend();
    3366  --tmp;
    3367  return *tmp;
    3368  }
    3369 
    3414  template <class InteratorType, typename
    3415  std::enable_if<
    3416  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3417  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3418  , int>::type
    3419  = 0>
    3420  InteratorType erase(InteratorType pos)
    3421  {
    3422  // make sure iterator fits the current value
    3423  if (this != pos.m_object)
    3424  {
    3425  throw std::domain_error("iterator does not fit current value");
    3426  }
    3427 
    3428  InteratorType result = end();
    3429 
    3430  switch (m_type)
    3431  {
    3432  case value_t::boolean:
    3433  case value_t::number_float:
    3434  case value_t::number_integer:
    3435  case value_t::string:
    3436  {
    3437  if (not pos.m_it.primitive_iterator.is_begin())
    3438  {
    3439  throw std::out_of_range("iterator out of range");
    3440  }
    3441 
    3442  if (is_string())
    3443  {
    3444  delete m_value.string;
    3445  m_value.string = nullptr;
    3446  }
    3447 
    3448  m_type = value_t::null;
    3449  break;
    3450  }
    3451 
    3452  case value_t::object:
    3453  {
    3454  assert(m_value.object != nullptr);
    3455  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3456  break;
    3457  }
    3458 
    3459  case value_t::array:
    3460  {
    3461  assert(m_value.array != nullptr);
    3462  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3463  break;
    3464  }
    3465 
    3466  default:
    3467  {
    3468  throw std::domain_error("cannot use erase() with " + type_name());
    3469  }
    3470  }
    3471 
    3472  return result;
    3473  }
    3474 
    3519  template <class InteratorType, typename
    3520  std::enable_if<
    3521  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3522  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3523  , int>::type
    3524  = 0>
    3525  InteratorType erase(InteratorType first, InteratorType last)
    3526  {
    3527  // make sure iterator fits the current value
    3528  if (this != first.m_object or this != last.m_object)
    3529  {
    3530  throw std::domain_error("iterators do not fit current value");
    3531  }
    3532 
    3533  InteratorType result = end();
    3534 
    3535  switch (m_type)
    3536  {
    3537  case value_t::boolean:
    3538  case value_t::number_float:
    3539  case value_t::number_integer:
    3540  case value_t::string:
    3541  {
    3542  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3543  {
    3544  throw std::out_of_range("iterators out of range");
    3545  }
    3546 
    3547  if (is_string())
    3548  {
    3549  delete m_value.string;
    3550  m_value.string = nullptr;
    3551  }
    3552 
    3553  m_type = value_t::null;
    3554  break;
    3555  }
    3556 
    3557  case value_t::object:
    3558  {
    3559  assert(m_value.object != nullptr);
    3560  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3561  last.m_it.object_iterator);
    3562  break;
    3563  }
    3564 
    3565  case value_t::array:
    3566  {
    3567  assert(m_value.array != nullptr);
    3568  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3569  last.m_it.array_iterator);
    3570  break;
    3571  }
    3572 
    3573  default:
    3574  {
    3575  throw std::domain_error("cannot use erase() with " + type_name());
    3576  }
    3577  }
    3578 
    3579  return result;
    3580  }
    3581 
    3608  size_type erase(const typename object_t::key_type& key)
    3609  {
    3610  // this erase only works for objects
    3611  if (is_object())
    3612  {
    3613  assert(m_value.object != nullptr);
    3614  return m_value.object->erase(key);
    3615  }
    3616  else
    3617  {
    3618  throw std::domain_error("cannot use erase() with " + type_name());
    3619  }
    3620  }
    3621 
    3646  void erase(const size_type idx)
    3647  {
    3648  // this erase only works for arrays
    3649  if (is_array())
    3650  {
    3651  if (idx >= size())
    3652  {
    3653  throw std::out_of_range("index out of range");
    3654  }
    3655 
    3656  assert(m_value.array != nullptr);
    3657  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3658  }
    3659  else
    3660  {
    3661  throw std::domain_error("cannot use erase() with " + type_name());
    3662  }
    3663  }
    3664 
    3682  iterator find(typename object_t::key_type key)
    3683  {
    3684  auto result = end();
    3685 
    3686  if (is_object())
    3687  {
    3688  assert(m_value.object != nullptr);
    3689  result.m_it.object_iterator = m_value.object->find(key);
    3690  }
    3691 
    3692  return result;
    3693  }
    3694 
    3699  const_iterator find(typename object_t::key_type key) const
    3700  {
    3701  auto result = cend();
    3702 
    3703  if (is_object())
    3704  {
    3705  assert(m_value.object != nullptr);
    3706  result.m_it.object_iterator = m_value.object->find(key);
    3707  }
    3708 
    3709  return result;
    3710  }
    3711 
    3730  size_type count(typename object_t::key_type key) const
    3731  {
    3732  // return 0 for all nonobject types
    3733  assert(not is_object() or m_value.object != nullptr);
    3734  return is_object() ? m_value.object->count(key) : 0;
    3735  }
    3736 
    3738 
    3739 
    3741  // iterators //
    3743 
    3746 
    3766  {
    3767  iterator result(this);
    3768  result.set_begin();
    3769  return result;
    3770  }
    3771 
    3776  {
    3777  return cbegin();
    3778  }
    3779 
    3800  {
    3801  const_iterator result(this);
    3802  result.set_begin();
    3803  return result;
    3804  }
    3805 
    3825  {
    3826  iterator result(this);
    3827  result.set_end();
    3828  return result;
    3829  }
    3830 
    3835  {
    3836  return cend();
    3837  }
    3838 
    3859  {
    3860  const_iterator result(this);
    3861  result.set_end();
    3862  return result;
    3863  }
    3864 
    3883  {
    3884  return reverse_iterator(end());
    3885  }
    3886 
    3891  {
    3892  return crbegin();
    3893  }
    3894 
    3914  {
    3915  return reverse_iterator(begin());
    3916  }
    3917 
    3922  {
    3923  return crend();
    3924  }
    3925 
    3945  {
    3946  return const_reverse_iterator(cend());
    3947  }
    3948 
    3968  {
    3969  return const_reverse_iterator(cbegin());
    3970  }
    3971 
    3972  private:
    3973  // forward declaration
    3974  template<typename IteratorType> class iteration_proxy;
    3975 
    3976  public:
    3988  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    3989  {
    3990  return iteration_proxy<iterator>(cont);
    3991  }
    3992 
    3996  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    3997  {
    3998  return iteration_proxy<const_iterator>(cont);
    3999  }
    4000 
    4002 
    4003 
    4005  // capacity //
    4007 
    4010 
    4040  bool empty() const noexcept
    4041  {
    4042  switch (m_type)
    4043  {
    4044  case value_t::null:
    4045  {
    4046  // null values are empty
    4047  return true;
    4048  }
    4049 
    4050  case value_t::array:
    4051  {
    4052  assert(m_value.array != nullptr);
    4053  return m_value.array->empty();
    4054  }
    4055 
    4056  case value_t::object:
    4057  {
    4058  assert(m_value.object != nullptr);
    4059  return m_value.object->empty();
    4060  }
    4061 
    4062  default:
    4063  {
    4064  // all other types are nonempty
    4065  return false;
    4066  }
    4067  }
    4068  }
    4069 
    4098  size_type size() const noexcept
    4099  {
    4100  switch (m_type)
    4101  {
    4102  case value_t::null:
    4103  {
    4104  // null values are empty
    4105  return 0;
    4106  }
    4107 
    4108  case value_t::array:
    4109  {
    4110  assert(m_value.array != nullptr);
    4111  return m_value.array->size();
    4112  }
    4113 
    4114  case value_t::object:
    4115  {
    4116  assert(m_value.object != nullptr);
    4117  return m_value.object->size();
    4118  }
    4119 
    4120  default:
    4121  {
    4122  // all other types have size 1
    4123  return 1;
    4124  }
    4125  }
    4126  }
    4127 
    4160  size_type max_size() const noexcept
    4161  {
    4162  switch (m_type)
    4163  {
    4164  case value_t::array:
    4165  {
    4166  assert(m_value.array != nullptr);
    4167  return m_value.array->max_size();
    4168  }
    4169 
    4170  case value_t::object:
    4171  {
    4172  assert(m_value.object != nullptr);
    4173  return m_value.object->max_size();
    4174  }
    4175 
    4176  default:
    4177  {
    4178  // all other types have max_size() == size()
    4179  return size();
    4180  }
    4181  }
    4182  }
    4183 
    4185 
    4186 
    4188  // modifiers //
    4190 
    4193 
    4219  void clear() noexcept
    4220  {
    4221  switch (m_type)
    4222  {
    4223  case value_t::number_integer:
    4224  {
    4225  m_value.number_integer = 0;
    4226  break;
    4227  }
    4228 
    4229  case value_t::number_float:
    4230  {
    4231  m_value.number_float = 0.0;
    4232  break;
    4233  }
    4234 
    4235  case value_t::boolean:
    4236  {
    4237  m_value.boolean = false;
    4238  break;
    4239  }
    4240 
    4241  case value_t::string:
    4242  {
    4243  assert(m_value.string != nullptr);
    4244  m_value.string->clear();
    4245  break;
    4246  }
    4247 
    4248  case value_t::array:
    4249  {
    4250  assert(m_value.array != nullptr);
    4251  m_value.array->clear();
    4252  break;
    4253  }
    4254 
    4255  case value_t::object:
    4256  {
    4257  assert(m_value.object != nullptr);
    4258  m_value.object->clear();
    4259  break;
    4260  }
    4261 
    4262  default:
    4263  {
    4264  break;
    4265  }
    4266  }
    4267  }
    4268 
    4289  void push_back(basic_json&& val)
    4290  {
    4291  // push_back only works for null objects or arrays
    4292  if (not(is_null() or is_array()))
    4293  {
    4294  throw std::domain_error("cannot use push_back() with " + type_name());
    4295  }
    4296 
    4297  // transform null object into an array
    4298  if (is_null())
    4299  {
    4300  m_type = value_t::array;
    4301  m_value = value_t::array;
    4302  }
    4303 
    4304  // add element to array (move semantics)
    4305  assert(m_value.array != nullptr);
    4306  m_value.array->push_back(std::move(val));
    4307  // invalidate object
    4308  val.m_type = value_t::null;
    4309  }
    4310 
    4315  reference operator+=(basic_json&& val)
    4316  {
    4317  push_back(std::move(val));
    4318  return *this;
    4319  }
    4320 
    4325  void push_back(const basic_json& val)
    4326  {
    4327  // push_back only works for null objects or arrays
    4328  if (not(is_null() or is_array()))
    4329  {
    4330  throw std::domain_error("cannot use push_back() with " + type_name());
    4331  }
    4332 
    4333  // transform null object into an array
    4334  if (is_null())
    4335  {
    4336  m_type = value_t::array;
    4337  m_value = value_t::array;
    4338  }
    4339 
    4340  // add element to array
    4341  assert(m_value.array != nullptr);
    4342  m_value.array->push_back(val);
    4343  }
    4344 
    4349  reference operator+=(const basic_json& val)
    4350  {
    4351  push_back(val);
    4352  return *this;
    4353  }
    4354 
    4375  void push_back(const typename object_t::value_type& val)
    4376  {
    4377  // push_back only works for null objects or objects
    4378  if (not(is_null() or is_object()))
    4379  {
    4380  throw std::domain_error("cannot use push_back() with " + type_name());
    4381  }
    4382 
    4383  // transform null object into an object
    4384  if (is_null())
    4385  {
    4386  m_type = value_t::object;
    4387  m_value = value_t::object;
    4388  }
    4389 
    4390  // add element to array
    4391  assert(m_value.object != nullptr);
    4392  m_value.object->insert(val);
    4393  }
    4394 
    4399  reference operator+=(const typename object_t::value_type& val)
    4400  {
    4401  push_back(val);
    4402  return operator[](val.first);
    4403  }
    4404 
    4427  iterator insert(const_iterator pos, const basic_json& val)
    4428  {
    4429  // insert only works for arrays
    4430  if (is_array())
    4431  {
    4432  // check if iterator pos fits to this JSON value
    4433  if (pos.m_object != this)
    4434  {
    4435  throw std::domain_error("iterator does not fit current value");
    4436  }
    4437 
    4438  // insert to array and return iterator
    4439  iterator result(this);
    4440  assert(m_value.array != nullptr);
    4441  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4442  return result;
    4443  }
    4444  else
    4445  {
    4446  throw std::domain_error("cannot use insert() with " + type_name());
    4447  }
    4448  }
    4449 
    4454  iterator insert(const_iterator pos, basic_json&& val)
    4455  {
    4456  return insert(pos, val);
    4457  }
    4458 
    4483  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4484  {
    4485  // insert only works for arrays
    4486  if (is_array())
    4487  {
    4488  // check if iterator pos fits to this JSON value
    4489  if (pos.m_object != this)
    4490  {
    4491  throw std::domain_error("iterator does not fit current value");
    4492  }
    4493 
    4494  // insert to array and return iterator
    4495  iterator result(this);
    4496  assert(m_value.array != nullptr);
    4497  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4498  return result;
    4499  }
    4500  else
    4501  {
    4502  throw std::domain_error("cannot use insert() with " + type_name());
    4503  }
    4504  }
    4505 
    4537  {
    4538  // insert only works for arrays
    4539  if (not is_array())
    4540  {
    4541  throw std::domain_error("cannot use insert() with " + type_name());
    4542  }
    4543 
    4544  // check if iterator pos fits to this JSON value
    4545  if (pos.m_object != this)
    4546  {
    4547  throw std::domain_error("iterator does not fit current value");
    4548  }
    4549 
    4550  if (first.m_object != last.m_object)
    4551  {
    4552  throw std::domain_error("iterators do not fit");
    4553  }
    4554 
    4555  if (first.m_object == this or last.m_object == this)
    4556  {
    4557  throw std::domain_error("passed iterators may not belong to container");
    4558  }
    4559 
    4560  // insert to array and return iterator
    4561  iterator result(this);
    4562  assert(m_value.array != nullptr);
    4563  result.m_it.array_iterator = m_value.array->insert(
    4564  pos.m_it.array_iterator,
    4565  first.m_it.array_iterator,
    4566  last.m_it.array_iterator);
    4567  return result;
    4568  }
    4569 
    4594  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4595  {
    4596  // insert only works for arrays
    4597  if (not is_array())
    4598  {
    4599  throw std::domain_error("cannot use insert() with " + type_name());
    4600  }
    4601 
    4602  // check if iterator pos fits to this JSON value
    4603  if (pos.m_object != this)
    4604  {
    4605  throw std::domain_error("iterator does not fit current value");
    4606  }
    4607 
    4608  // insert to array and return iterator
    4609  iterator result(this);
    4610  assert(m_value.array != nullptr);
    4611  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4612  return result;
    4613  }
    4614 
    4632  void swap(reference other) noexcept (
    4633  std::is_nothrow_move_constructible<value_t>::value and
    4634  std::is_nothrow_move_assignable<value_t>::value and
    4635  std::is_nothrow_move_constructible<json_value>::value and
    4636  std::is_nothrow_move_assignable<json_value>::value
    4637  )
    4638  {
    4639  std::swap(m_type, other.m_type);
    4640  std::swap(m_value, other.m_value);
    4641  }
    4642 
    4663  void swap(array_t& other)
    4664  {
    4665  // swap only works for arrays
    4666  if (is_array())
    4667  {
    4668  assert(m_value.array != nullptr);
    4669  std::swap(*(m_value.array), other);
    4670  }
    4671  else
    4672  {
    4673  throw std::domain_error("cannot use swap() with " + type_name());
    4674  }
    4675  }
    4676 
    4697  void swap(object_t& other)
    4698  {
    4699  // swap only works for objects
    4700  if (is_object())
    4701  {
    4702  assert(m_value.object != nullptr);
    4703  std::swap(*(m_value.object), other);
    4704  }
    4705  else
    4706  {
    4707  throw std::domain_error("cannot use swap() with " + type_name());
    4708  }
    4709  }
    4710 
    4731  void swap(string_t& other)
    4732  {
    4733  // swap only works for strings
    4734  if (is_string())
    4735  {
    4736  assert(m_value.string != nullptr);
    4737  std::swap(*(m_value.string), other);
    4738  }
    4739  else
    4740  {
    4741  throw std::domain_error("cannot use swap() with " + type_name());
    4742  }
    4743  }
    4744 
    4746 
    4747 
    4749  // lexicographical comparison operators //
    4751 
    4754 
    4755  private:
    4765  friend bool operator<(const value_t lhs, const value_t rhs)
    4766  {
    4767  static constexpr std::array<uint8_t, 7> order = {{
    4768  0, // null
    4769  3, // object
    4770  4, // array
    4771  5, // string
    4772  1, // boolean
    4773  2, // integer
    4774  2 // float
    4775  }
    4776  };
    4777 
    4778  // discarded values are not comparable
    4779  if (lhs == value_t::discarded or rhs == value_t::discarded)
    4780  {
    4781  return false;
    4782  }
    4783 
    4784  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    4785  }
    4786 
    4787  public:
    4811  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    4812  {
    4813  const auto lhs_type = lhs.type();
    4814  const auto rhs_type = rhs.type();
    4815 
    4816  if (lhs_type == rhs_type)
    4817  {
    4818  switch (lhs_type)
    4819  {
    4820  case value_t::array:
    4821  {
    4822  assert(lhs.m_value.array != nullptr);
    4823  assert(rhs.m_value.array != nullptr);
    4824  return *lhs.m_value.array == *rhs.m_value.array;
    4825  }
    4826  case value_t::object:
    4827  {
    4828  assert(lhs.m_value.object != nullptr);
    4829  assert(rhs.m_value.object != nullptr);
    4830  return *lhs.m_value.object == *rhs.m_value.object;
    4831  }
    4832  case value_t::null:
    4833  {
    4834  return true;
    4835  }
    4836  case value_t::string:
    4837  {
    4838  assert(lhs.m_value.string != nullptr);
    4839  assert(rhs.m_value.string != nullptr);
    4840  return *lhs.m_value.string == *rhs.m_value.string;
    4841  }
    4842  case value_t::boolean:
    4843  {
    4844  return lhs.m_value.boolean == rhs.m_value.boolean;
    4845  }
    4846  case value_t::number_integer:
    4847  {
    4848  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    4849  }
    4850  case value_t::number_float:
    4851  {
    4852  return approx(lhs.m_value.number_float, rhs.m_value.number_float);
    4853  }
    4854  default:
    4855  {
    4856  return false;
    4857  }
    4858  }
    4859  }
    4860  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    4861  {
    4862  return approx(static_cast<number_float_t>(lhs.m_value.number_integer),
    4863  rhs.m_value.number_float);
    4864  }
    4865  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    4866  {
    4867  return approx(lhs.m_value.number_float,
    4868  static_cast<number_float_t>(rhs.m_value.number_integer));
    4869  }
    4870  return false;
    4871  }
    4872 
    4891  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    4892  {
    4893  return v.is_null();
    4894  }
    4895 
    4900  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    4901  {
    4902  return v.is_null();
    4903  }
    4904 
    4921  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    4922  {
    4923  return not (lhs == rhs);
    4924  }
    4925 
    4944  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    4945  {
    4946  return not v.is_null();
    4947  }
    4948 
    4953  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    4954  {
    4955  return not v.is_null();
    4956  }
    4957 
    4982  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    4983  {
    4984  const auto lhs_type = lhs.type();
    4985  const auto rhs_type = rhs.type();
    4986 
    4987  if (lhs_type == rhs_type)
    4988  {
    4989  switch (lhs_type)
    4990  {
    4991  case value_t::array:
    4992  {
    4993  assert(lhs.m_value.array != nullptr);
    4994  assert(rhs.m_value.array != nullptr);
    4995  return *lhs.m_value.array < *rhs.m_value.array;
    4996  }
    4997  case value_t::object:
    4998  {
    4999  assert(lhs.m_value.object != nullptr);
    5000  assert(rhs.m_value.object != nullptr);
    5001  return *lhs.m_value.object < *rhs.m_value.object;
    5002  }
    5003  case value_t::null:
    5004  {
    5005  return false;
    5006  }
    5007  case value_t::string:
    5008  {
    5009  assert(lhs.m_value.string != nullptr);
    5010  assert(rhs.m_value.string != nullptr);
    5011  return *lhs.m_value.string < *rhs.m_value.string;
    5012  }
    5013  case value_t::boolean:
    5014  {
    5015  return lhs.m_value.boolean < rhs.m_value.boolean;
    5016  }
    5017  case value_t::number_integer:
    5018  {
    5019  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5020  }
    5021  case value_t::number_float:
    5022  {
    5023  return lhs.m_value.number_float < rhs.m_value.number_float;
    5024  }
    5025  default:
    5026  {
    5027  return false;
    5028  }
    5029  }
    5030  }
    5031  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5032  {
    5033  return static_cast<number_float_t>(lhs.m_value.number_integer) <
    5034  rhs.m_value.number_float;
    5035  }
    5036  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5037  {
    5038  return lhs.m_value.number_float <
    5039  static_cast<number_float_t>(rhs.m_value.number_integer);
    5040  }
    5041 
    5042  // We only reach this line if we cannot compare values. In that case,
    5043  // we compare types. Note we have to call the operator explicitly,
    5044  // because MSVC has problems otherwise.
    5045  return operator<(lhs_type, rhs_type);
    5046  }
    5047 
    5065  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5066  {
    5067  return not (rhs < lhs);
    5068  }
    5069 
    5087  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5088  {
    5089  return not (lhs <= rhs);
    5090  }
    5091 
    5109  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5110  {
    5111  return not (lhs < rhs);
    5112  }
    5113 
    5115 
    5116 
    5118  // serialization //
    5120 
    5123 
    5146  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5147  {
    5148  // read width member and use it as indentation parameter if nonzero
    5149  const bool pretty_print = (o.width() > 0);
    5150  const auto indentation = (pretty_print ? o.width() : 0);
    5151 
    5152  // reset width to 0 for subsequent calls to this stream
    5153  o.width(0);
    5154 
    5155  // do the actual serialization
    5156  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5157  return o;
    5158  }
    5159 
    5164  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5165  {
    5166  return o << j;
    5167  }
    5168 
    5170 
    5171 
    5173  // deserialization //
    5175 
    5178 
    5203  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5204  {
    5205  return parser(s, cb).parse();
    5206  }
    5207 
    5232  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5233  {
    5234  return parser(i, cb).parse();
    5235  }
    5236 
    5240  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5241  {
    5242  return parser(i, cb).parse();
    5243  }
    5244 
    5268  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5269  {
    5270  j = parser(i).parse();
    5271  return i;
    5272  }
    5273 
    5278  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5279  {
    5280  j = parser(i).parse();
    5281  return i;
    5282  }
    5283 
    5285 
    5286 
    5287  private:
    5289  // convenience functions //
    5291 
    5293  string_t type_name() const
    5294  {
    5295  switch (m_type)
    5296  {
    5297  case value_t::null:
    5298  return "null";
    5299  case value_t::object:
    5300  return "object";
    5301  case value_t::array:
    5302  return "array";
    5303  case value_t::string:
    5304  return "string";
    5305  case value_t::boolean:
    5306  return "boolean";
    5307  case value_t::discarded:
    5308  return "discarded";
    5309  default:
    5310  return "number";
    5311  }
    5312  }
    5313 
    5322  static std::size_t extra_space(const string_t& s) noexcept
    5323  {
    5324  std::size_t result = 0;
    5325 
    5326  for (const auto& c : s)
    5327  {
    5328  switch (c)
    5329  {
    5330  case '"':
    5331  case '\\':
    5332  case '\b':
    5333  case '\f':
    5334  case '\n':
    5335  case '\r':
    5336  case '\t':
    5337  {
    5338  // from c (1 byte) to \x (2 bytes)
    5339  result += 1;
    5340  break;
    5341  }
    5342 
    5343  default:
    5344  {
    5345  if (c >= 0x00 and c <= 0x1f)
    5346  {
    5347  // from c (1 byte) to \uxxxx (6 bytes)
    5348  result += 5;
    5349  }
    5350  break;
    5351  }
    5352  }
    5353  }
    5354 
    5355  return result;
    5356  }
    5357 
    5371  static string_t escape_string(const string_t& s) noexcept
    5372  {
    5373  const auto space = extra_space(s);
    5374  if (space == 0)
    5375  {
    5376  return s;
    5377  }
    5378 
    5379  // create a result string of necessary size
    5380  string_t result(s.size() + space, '\\');
    5381  std::size_t pos = 0;
    5382 
    5383  for (const auto& c : s)
    5384  {
    5385  switch (c)
    5386  {
    5387  // quotation mark (0x22)
    5388  case '"':
    5389  {
    5390  result[pos + 1] = '"';
    5391  pos += 2;
    5392  break;
    5393  }
    5394 
    5395  // reverse solidus (0x5c)
    5396  case '\\':
    5397  {
    5398  // nothing to change
    5399  pos += 2;
    5400  break;
    5401  }
    5402 
    5403  // backspace (0x08)
    5404  case '\b':
    5405  {
    5406  result[pos + 1] = 'b';
    5407  pos += 2;
    5408  break;
    5409  }
    5410 
    5411  // formfeed (0x0c)
    5412  case '\f':
    5413  {
    5414  result[pos + 1] = 'f';
    5415  pos += 2;
    5416  break;
    5417  }
    5418 
    5419  // newline (0x0a)
    5420  case '\n':
    5421  {
    5422  result[pos + 1] = 'n';
    5423  pos += 2;
    5424  break;
    5425  }
    5426 
    5427  // carriage return (0x0d)
    5428  case '\r':
    5429  {
    5430  result[pos + 1] = 'r';
    5431  pos += 2;
    5432  break;
    5433  }
    5434 
    5435  // horizontal tab (0x09)
    5436  case '\t':
    5437  {
    5438  result[pos + 1] = 't';
    5439  pos += 2;
    5440  break;
    5441  }
    5442 
    5443  default:
    5444  {
    5445  if (c >= 0x00 and c <= 0x1f)
    5446  {
    5447  // convert a number 0..15 to its hex representation (0..f)
    5448  auto hexify = [](const char v) -> char
    5449  {
    5450  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5451  };
    5452 
    5453  // print character c as \uxxxx
    5454  for (const char m :
    5455  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5456  })
    5457  {
    5458  result[++pos] = m;
    5459  }
    5460 
    5461  ++pos;
    5462  }
    5463  else
    5464  {
    5465  // all other characters are added as-is
    5466  result[pos++] = c;
    5467  }
    5468  break;
    5469  }
    5470  }
    5471  }
    5472 
    5473  return result;
    5474  }
    5475 
    5493  void dump(std::ostream& o,
    5494  const bool pretty_print,
    5495  const unsigned int indent_step,
    5496  const unsigned int current_indent = 0) const
    5497  {
    5498  // variable to hold indentation for recursive calls
    5499  unsigned int new_indent = current_indent;
    5500 
    5501  switch (m_type)
    5502  {
    5503  case value_t::object:
    5504  {
    5505  assert(m_value.object != nullptr);
    5506 
    5507  if (m_value.object->empty())
    5508  {
    5509  o << "{}";
    5510  return;
    5511  }
    5512 
    5513  o << "{";
    5514 
    5515  // increase indentation
    5516  if (pretty_print)
    5517  {
    5518  new_indent += indent_step;
    5519  o << "\n";
    5520  }
    5521 
    5522  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5523  {
    5524  if (i != m_value.object->cbegin())
    5525  {
    5526  o << (pretty_print ? ",\n" : ",");
    5527  }
    5528  o << string_t(new_indent, ' ') << "\""
    5529  << escape_string(i->first) << "\":"
    5530  << (pretty_print ? " " : "");
    5531  i->second.dump(o, pretty_print, indent_step, new_indent);
    5532  }
    5533 
    5534  // decrease indentation
    5535  if (pretty_print)
    5536  {
    5537  new_indent -= indent_step;
    5538  o << "\n";
    5539  }
    5540 
    5541  o << string_t(new_indent, ' ') + "}";
    5542  return;
    5543  }
    5544 
    5545  case value_t::array:
    5546  {
    5547  assert(m_value.array != nullptr);
    5548 
    5549  if (m_value.array->empty())
    5550  {
    5551  o << "[]";
    5552  return;
    5553  }
    5554 
    5555  o << "[";
    5556 
    5557  // increase indentation
    5558  if (pretty_print)
    5559  {
    5560  new_indent += indent_step;
    5561  o << "\n";
    5562  }
    5563 
    5564  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5565  {
    5566  if (i != m_value.array->cbegin())
    5567  {
    5568  o << (pretty_print ? ",\n" : ",");
    5569  }
    5570  o << string_t(new_indent, ' ');
    5571  i->dump(o, pretty_print, indent_step, new_indent);
    5572  }
    5573 
    5574  // decrease indentation
    5575  if (pretty_print)
    5576  {
    5577  new_indent -= indent_step;
    5578  o << "\n";
    5579  }
    5580 
    5581  o << string_t(new_indent, ' ') << "]";
    5582  return;
    5583  }
    5584 
    5585  case value_t::string:
    5586  {
    5587  assert(m_value.string != nullptr);
    5588  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5589  return;
    5590  }
    5591 
    5592  case value_t::boolean:
    5593  {
    5594  o << (m_value.boolean ? "true" : "false");
    5595  return;
    5596  }
    5597 
    5598  case value_t::number_integer:
    5599  {
    5600  o << m_value.number_integer;
    5601  return;
    5602  }
    5603 
    5604  case value_t::number_float:
    5605  {
    5606  // 15 digits of precision allows round-trip IEEE 754
    5607  // string->double->string; to be safe, we read this value from
    5608  // std::numeric_limits<number_float_t>::digits10
    5609  o << std::setprecision(std::numeric_limits<number_float_t>::digits10) << m_value.number_float;
    5610  return;
    5611  }
    5612 
    5613  case value_t::discarded:
    5614  {
    5615  o << "<discarded>";
    5616  return;
    5617  }
    5618 
    5619  case value_t::null:
    5620  {
    5621  o << "null";
    5622  return;
    5623  }
    5624  }
    5625  }
    5626 
    5627  private:
    5629  // member variables //
    5631 
    5633  value_t m_type = value_t::null;
    5634 
    5636  json_value m_value = {};
    5637 
    5638 
    5639  private:
    5641  // iterators //
    5643 
    5653  class primitive_iterator_t
    5654  {
    5655  public:
    5657  void set_begin()
    5658  {
    5659  m_it = begin_value;
    5660  }
    5661 
    5663  void set_end()
    5664  {
    5665  m_it = end_value;
    5666  }
    5667 
    5669  bool is_begin() const
    5670  {
    5671  return (m_it == begin_value);
    5672  }
    5673 
    5675  bool is_end() const
    5676  {
    5677  return (m_it == end_value);
    5678  }
    5679 
    5681  operator difference_type& ()
    5682  {
    5683  return m_it;
    5684  }
    5685 
    5687  operator difference_type () const
    5688  {
    5689  return m_it;
    5690  }
    5691 
    5692  private:
    5693  static constexpr difference_type begin_value = 0;
    5694  static constexpr difference_type end_value = begin_value + 1;
    5695 
    5697  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    5698  };
    5699 
    5707  struct internal_iterator
    5708  {
    5710  typename object_t::iterator object_iterator;
    5712  typename array_t::iterator array_iterator;
    5714  primitive_iterator_t primitive_iterator;
    5715 
    5717  internal_iterator()
    5718  : object_iterator(), array_iterator(), primitive_iterator()
    5719  {}
    5720  };
    5721 
    5723  template<typename IteratorType>
    5724  class iteration_proxy
    5725  {
    5726  private:
    5728  class iteration_proxy_internal
    5729  {
    5730  private:
    5732  IteratorType anchor;
    5734  size_t array_index = 0;
    5735 
    5736  public:
    5737  iteration_proxy_internal(IteratorType it)
    5738  : anchor(it)
    5739  {}
    5740 
    5742  iteration_proxy_internal& operator*()
    5743  {
    5744  return *this;
    5745  }
    5746 
    5748  iteration_proxy_internal& operator++()
    5749  {
    5750  ++anchor;
    5751  ++array_index;
    5752 
    5753  return *this;
    5754  }
    5755 
    5757  bool operator!= (const iteration_proxy_internal& o) const
    5758  {
    5759  return anchor != o.anchor;
    5760  }
    5761 
    5763  typename basic_json::string_t key() const
    5764  {
    5765  assert(anchor.m_object != nullptr);
    5766 
    5767  switch (anchor.m_object->type())
    5768  {
    5769  // use integer array index as key
    5770  case value_t::array:
    5771  {
    5772  return std::to_string(array_index);
    5773  }
    5774 
    5775  // use key from the object
    5776  case value_t::object:
    5777  {
    5778  return anchor.key();
    5779  }
    5780 
    5781  // use an empty key for all primitive types
    5782  default:
    5783  {
    5784  return "";
    5785  }
    5786  }
    5787  }
    5788 
    5790  typename IteratorType::reference value() const
    5791  {
    5792  return anchor.value();
    5793  }
    5794  };
    5795 
    5797  typename IteratorType::reference container;
    5798 
    5799  public:
    5801  iteration_proxy(typename IteratorType::reference cont)
    5802  : container(cont)
    5803  {}
    5804 
    5806  iteration_proxy_internal begin()
    5807  {
    5808  return iteration_proxy_internal(container.begin());
    5809  }
    5810 
    5812  iteration_proxy_internal end()
    5813  {
    5814  return iteration_proxy_internal(container.end());
    5815  }
    5816  };
    5817 
    5818  public:
    5832  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    5833  {
    5835  friend class basic_json;
    5836 
    5837  public:
    5847  using iterator_category = std::bidirectional_iterator_tag;
    5848 
    5850  const_iterator() = default;
    5851 
    5853  const_iterator(pointer object) : m_object(object)
    5854  {
    5855  assert(m_object != nullptr);
    5856 
    5857  switch (m_object->m_type)
    5858  {
    5860  {
    5861  m_it.object_iterator = typename object_t::iterator();
    5862  break;
    5863  }
    5864 
    5866  {
    5867  m_it.array_iterator = typename array_t::iterator();
    5868  break;
    5869  }
    5870 
    5871  default:
    5872  {
    5873  m_it.primitive_iterator = primitive_iterator_t();
    5874  break;
    5875  }
    5876  }
    5877  }
    5878 
    5880  const_iterator(const iterator& other) : m_object(other.m_object)
    5881  {
    5882  assert(m_object != nullptr);
    5883 
    5884  switch (m_object->m_type)
    5885  {
    5887  {
    5888  m_it.object_iterator = other.m_it.object_iterator;
    5889  break;
    5890  }
    5891 
    5893  {
    5894  m_it.array_iterator = other.m_it.array_iterator;
    5895  break;
    5896  }
    5897 
    5898  default:
    5899  {
    5900  m_it.primitive_iterator = other.m_it.primitive_iterator;
    5901  break;
    5902  }
    5903  }
    5904  }
    5905 
    5907  const_iterator(const const_iterator& other) noexcept
    5908  : m_object(other.m_object), m_it(other.m_it)
    5909  {}
    5910 
    5913  std::is_nothrow_move_constructible<pointer>::value and
    5914  std::is_nothrow_move_assignable<pointer>::value and
    5915  std::is_nothrow_move_constructible<internal_iterator>::value and
    5916  std::is_nothrow_move_assignable<internal_iterator>::value
    5917  )
    5918  {
    5919  std::swap(m_object, other.m_object);
    5920  std::swap(m_it, other.m_it);
    5921  return *this;
    5922  }
    5923 
    5924  private:
    5926  void set_begin()
    5927  {
    5928  assert(m_object != nullptr);
    5929 
    5930  switch (m_object->m_type)
    5931  {
    5933  {
    5934  assert(m_object->m_value.object != nullptr);
    5935  m_it.object_iterator = m_object->m_value.object->begin();
    5936  break;
    5937  }
    5938 
    5940  {
    5941  assert(m_object->m_value.array != nullptr);
    5942  m_it.array_iterator = m_object->m_value.array->begin();
    5943  break;
    5944  }
    5945 
    5947  {
    5948  // set to end so begin()==end() is true: null is empty
    5949  m_it.primitive_iterator.set_end();
    5950  break;
    5951  }
    5952 
    5953  default:
    5954  {
    5955  m_it.primitive_iterator.set_begin();
    5956  break;
    5957  }
    5958  }
    5959  }
    5960 
    5962  void set_end()
    5963  {
    5964  assert(m_object != nullptr);
    5965 
    5966  switch (m_object->m_type)
    5967  {
    5969  {
    5970  assert(m_object->m_value.object != nullptr);
    5971  m_it.object_iterator = m_object->m_value.object->end();
    5972  break;
    5973  }
    5974 
    5976  {
    5977  assert(m_object->m_value.array != nullptr);
    5978  m_it.array_iterator = m_object->m_value.array->end();
    5979  break;
    5980  }
    5981 
    5982  default:
    5983  {
    5984  m_it.primitive_iterator.set_end();
    5985  break;
    5986  }
    5987  }
    5988  }
    5989 
    5990  public:
    5993  {
    5994  assert(m_object != nullptr);
    5995 
    5996  switch (m_object->m_type)
    5997  {
    5999  {
    6000  assert(m_object->m_value.object);
    6001  assert(m_it.object_iterator != m_object->m_value.object->end());
    6002  return m_it.object_iterator->second;
    6003  }
    6004 
    6006  {
    6007  assert(m_object->m_value.array);
    6008  assert(m_it.array_iterator != m_object->m_value.array->end());
    6009  return *m_it.array_iterator;
    6010  }
    6011 
    6013  {
    6014  throw std::out_of_range("cannot get value");
    6015  }
    6016 
    6017  default:
    6018  {
    6019  if (m_it.primitive_iterator.is_begin())
    6020  {
    6021  return *m_object;
    6022  }
    6023  else
    6024  {
    6025  throw std::out_of_range("cannot get value");
    6026  }
    6027  }
    6028  }
    6029  }
    6030 
    6033  {
    6034  assert(m_object != nullptr);
    6035 
    6036  switch (m_object->m_type)
    6037  {
    6039  {
    6040  assert(m_object->m_value.object);
    6041  assert(m_it.object_iterator != m_object->m_value.object->end());
    6042  return &(m_it.object_iterator->second);
    6043  }
    6044 
    6046  {
    6047  assert(m_object->m_value.array);
    6048  assert(m_it.array_iterator != m_object->m_value.array->end());
    6049  return &*m_it.array_iterator;
    6050  }
    6051 
    6052  default:
    6053  {
    6054  if (m_it.primitive_iterator.is_begin())
    6055  {
    6056  return m_object;
    6057  }
    6058  else
    6059  {
    6060  throw std::out_of_range("cannot get value");
    6061  }
    6062  }
    6063  }
    6064  }
    6065 
    6068  {
    6069  auto result = *this;
    6070  ++(*this);
    6071  return result;
    6072  }
    6073 
    6076  {
    6077  assert(m_object != nullptr);
    6078 
    6079  switch (m_object->m_type)
    6080  {
    6082  {
    6083  ++m_it.object_iterator;
    6084  break;
    6085  }
    6086 
    6088  {
    6089  ++m_it.array_iterator;
    6090  break;
    6091  }
    6092 
    6093  default:
    6094  {
    6095  ++m_it.primitive_iterator;
    6096  break;
    6097  }
    6098  }
    6099 
    6100  return *this;
    6101  }
    6102 
    6105  {
    6106  auto result = *this;
    6107  --(*this);
    6108  return result;
    6109  }
    6110 
    6113  {
    6114  assert(m_object != nullptr);
    6115 
    6116  switch (m_object->m_type)
    6117  {
    6119  {
    6120  --m_it.object_iterator;
    6121  break;
    6122  }
    6123 
    6125  {
    6126  --m_it.array_iterator;
    6127  break;
    6128  }
    6129 
    6130  default:
    6131  {
    6132  --m_it.primitive_iterator;
    6133  break;
    6134  }
    6135  }
    6136 
    6137  return *this;
    6138  }
    6139 
    6141  bool operator==(const const_iterator& other) const
    6142  {
    6143  // if objects are not the same, the comparison is undefined
    6144  if (m_object != other.m_object)
    6145  {
    6146  throw std::domain_error("cannot compare iterators of different containers");
    6147  }
    6148 
    6149  assert(m_object != nullptr);
    6150 
    6151  switch (m_object->m_type)
    6152  {
    6154  {
    6155  return (m_it.object_iterator == other.m_it.object_iterator);
    6156  }
    6157 
    6159  {
    6160  return (m_it.array_iterator == other.m_it.array_iterator);
    6161  }
    6162 
    6163  default:
    6164  {
    6165  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6166  }
    6167  }
    6168  }
    6169 
    6171  bool operator!=(const const_iterator& other) const
    6172  {
    6173  return not operator==(other);
    6174  }
    6175 
    6177  bool operator<(const const_iterator& other) const
    6178  {
    6179  // if objects are not the same, the comparison is undefined
    6180  if (m_object != other.m_object)
    6181  {
    6182  throw std::domain_error("cannot compare iterators of different containers");
    6183  }
    6184 
    6185  assert(m_object != nullptr);
    6186 
    6187  switch (m_object->m_type)
    6188  {
    6190  {
    6191  throw std::domain_error("cannot compare order of object iterators");
    6192  }
    6193 
    6195  {
    6196  return (m_it.array_iterator < other.m_it.array_iterator);
    6197  }
    6198 
    6199  default:
    6200  {
    6201  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6202  }
    6203  }
    6204  }
    6205 
    6207  bool operator<=(const const_iterator& other) const
    6208  {
    6209  return not other.operator < (*this);
    6210  }
    6211 
    6213  bool operator>(const const_iterator& other) const
    6214  {
    6215  return not operator<=(other);
    6216  }
    6217 
    6219  bool operator>=(const const_iterator& other) const
    6220  {
    6221  return not operator<(other);
    6222  }
    6223 
    6226  {
    6227  assert(m_object != nullptr);
    6228 
    6229  switch (m_object->m_type)
    6230  {
    6232  {
    6233  throw std::domain_error("cannot use offsets with object iterators");
    6234  }
    6235 
    6237  {
    6238  m_it.array_iterator += i;
    6239  break;
    6240  }
    6241 
    6242  default:
    6243  {
    6244  m_it.primitive_iterator += i;
    6245  break;
    6246  }
    6247  }
    6248 
    6249  return *this;
    6250  }
    6251 
    6254  {
    6255  return operator+=(-i);
    6256  }
    6257 
    6260  {
    6261  auto result = *this;
    6262  result += i;
    6263  return result;
    6264  }
    6265 
    6268  {
    6269  auto result = *this;
    6270  result -= i;
    6271  return result;
    6272  }
    6273 
    6276  {
    6277  assert(m_object != nullptr);
    6278 
    6279  switch (m_object->m_type)
    6280  {
    6282  {
    6283  throw std::domain_error("cannot use offsets with object iterators");
    6284  }
    6285 
    6287  {
    6288  return m_it.array_iterator - other.m_it.array_iterator;
    6289  }
    6290 
    6291  default:
    6292  {
    6293  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6294  }
    6295  }
    6296  }
    6297 
    6300  {
    6301  assert(m_object != nullptr);
    6302 
    6303  switch (m_object->m_type)
    6304  {
    6306  {
    6307  throw std::domain_error("cannot use operator[] for object iterators");
    6308  }
    6309 
    6311  {
    6312  return *(m_it.array_iterator + n);
    6313  }
    6314 
    6316  {
    6317  throw std::out_of_range("cannot get value");
    6318  }
    6319 
    6320  default:
    6321  {
    6322  if (m_it.primitive_iterator == -n)
    6323  {
    6324  return *m_object;
    6325  }
    6326  else
    6327  {
    6328  throw std::out_of_range("cannot get value");
    6329  }
    6330  }
    6331  }
    6332  }
    6333 
    6335  typename object_t::key_type key() const
    6336  {
    6337  assert(m_object != nullptr);
    6338 
    6339  if (m_object->is_object())
    6340  {
    6341  return m_it.object_iterator->first;
    6342  }
    6343  else
    6344  {
    6345  throw std::domain_error("cannot use key() for non-object iterators");
    6346  }
    6347  }
    6348 
    6351  {
    6352  return operator*();
    6353  }
    6354 
    6355  private:
    6357  pointer m_object = nullptr;
    6359  internal_iterator m_it = internal_iterator();
    6360  };
    6361 
    6374  class iterator : public const_iterator
    6375  {
    6376  public:
    6378  using pointer = typename basic_json::pointer;
    6380 
    6382  iterator() = default;
    6383 
    6385  iterator(pointer object) noexcept
    6386  : base_iterator(object)
    6387  {}
    6388 
    6390  iterator(const iterator& other) noexcept
    6391  : base_iterator(other)
    6392  {}
    6393 
    6395  iterator& operator=(iterator other) noexcept(
    6396  std::is_nothrow_move_constructible<pointer>::value and
    6397  std::is_nothrow_move_assignable<pointer>::value and
    6398  std::is_nothrow_move_constructible<internal_iterator>::value and
    6399  std::is_nothrow_move_assignable<internal_iterator>::value
    6400  )
    6401  {
    6402  base_iterator::operator=(other);
    6403  return *this;
    6404  }
    6405 
    6408  {
    6409  return const_cast<reference>(base_iterator::operator*());
    6410  }
    6411 
    6414  {
    6415  return const_cast<pointer>(base_iterator::operator->());
    6416  }
    6417 
    6420  {
    6421  iterator result = *this;
    6422  base_iterator::operator++();
    6423  return result;
    6424  }
    6425 
    6428  {
    6429  base_iterator::operator++();
    6430  return *this;
    6431  }
    6432 
    6435  {
    6436  iterator result = *this;
    6437  base_iterator::operator--();
    6438  return result;
    6439  }
    6440 
    6443  {
    6444  base_iterator::operator--();
    6445  return *this;
    6446  }
    6447 
    6450  {
    6451  base_iterator::operator+=(i);
    6452  return *this;
    6453  }
    6454 
    6457  {
    6458  base_iterator::operator-=(i);
    6459  return *this;
    6460  }
    6461 
    6464  {
    6465  auto result = *this;
    6466  result += i;
    6467  return result;
    6468  }
    6469 
    6472  {
    6473  auto result = *this;
    6474  result -= i;
    6475  return result;
    6476  }
    6477 
    6478  difference_type operator-(const iterator& other) const
    6479  {
    6480  return base_iterator::operator-(other);
    6481  }
    6482 
    6485  {
    6486  return const_cast<reference>(base_iterator::operator[](n));
    6487  }
    6488 
    6491  {
    6492  return const_cast<reference>(base_iterator::value());
    6493  }
    6494  };
    6495 
    6513  template<typename Base>
    6514  class json_reverse_iterator : public std::reverse_iterator<Base>
    6515  {
    6516  public:
    6518  using base_iterator = std::reverse_iterator<Base>;
    6520  using reference = typename Base::reference;
    6521 
    6523  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6524  : base_iterator(it)
    6525  {}
    6526 
    6529  : base_iterator(it)
    6530  {}
    6531 
    6534  {
    6535  return base_iterator::operator++(1);
    6536  }
    6537 
    6540  {
    6541  base_iterator::operator++();
    6542  return *this;
    6543  }
    6544 
    6547  {
    6548  return base_iterator::operator--(1);
    6549  }
    6550 
    6553  {
    6554  base_iterator::operator--();
    6555  return *this;
    6556  }
    6557 
    6560  {
    6561  base_iterator::operator+=(i);
    6562  return *this;
    6563  }
    6564 
    6567  {
    6568  auto result = *this;
    6569  result += i;
    6570  return result;
    6571  }
    6572 
    6575  {
    6576  auto result = *this;
    6577  result -= i;
    6578  return result;
    6579  }
    6580 
    6583  {
    6584  return this->base() - other.base();
    6585  }
    6586 
    6589  {
    6590  return *(this->operator+(n));
    6591  }
    6592 
    6594  typename object_t::key_type key() const
    6595  {
    6596  auto it = --this->base();
    6597  return it.key();
    6598  }
    6599 
    6602  {
    6603  auto it = --this->base();
    6604  return it.operator * ();
    6605  }
    6606  };
    6607 
    6608 
    6609  private:
    6611  // lexer and parser //
    6613 
    6621  class lexer
    6622  {
    6623  public:
    6625  enum class token_type
    6626  {
    6627  uninitialized,
    6628  literal_true,
    6629  literal_false,
    6630  literal_null,
    6631  value_string,
    6632  value_number,
    6633  begin_array,
    6634  begin_object,
    6635  end_array,
    6636  end_object,
    6637  name_separator,
    6638  value_separator,
    6639  parse_error,
    6640  end_of_input
    6641  };
    6642 
    6644  using lexer_char_t = unsigned char;
    6645 
    6647  explicit lexer(const string_t& s) noexcept
    6648  : m_stream(nullptr), m_buffer(s)
    6649  {
    6650  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    6651  assert(m_content != nullptr);
    6652  m_start = m_cursor = m_content;
    6653  m_limit = m_content + s.size();
    6654  }
    6655 
    6657  explicit lexer(std::istream* s) noexcept
    6658  : m_stream(s), m_buffer()
    6659  {
    6660  assert(m_stream != nullptr);
    6661  getline(*m_stream, m_buffer);
    6662  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    6663  assert(m_content != nullptr);
    6664  m_start = m_cursor = m_content;
    6665  m_limit = m_content + m_buffer.size();
    6666  }
    6667 
    6669  lexer() = default;
    6670 
    6671  // switch off unwanted functions
    6672  lexer(const lexer&) = delete;
    6673  lexer operator=(const lexer&) = delete;
    6674 
    6690  static string_t to_unicode(const std::size_t codepoint1,
    6691  const std::size_t codepoint2 = 0)
    6692  {
    6693  string_t result;
    6694 
    6695  // calculate the codepoint from the given code points
    6696  std::size_t codepoint = codepoint1;
    6697 
    6698  // check if codepoint1 is a high surrogate
    6699  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    6700  {
    6701  // check if codepoint2 is a low surrogate
    6702  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    6703  {
    6704  codepoint =
    6705  // high surrogate occupies the most significant 22 bits
    6706  (codepoint1 << 10)
    6707  // low surrogate occupies the least significant 15 bits
    6708  + codepoint2
    6709  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    6710  // in the result so we have to subtract with:
    6711  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    6712  - 0x35FDC00;
    6713  }
    6714  else
    6715  {
    6716  throw std::invalid_argument("missing or wrong low surrogate");
    6717  }
    6718  }
    6719 
    6720  if (codepoint < 0x80)
    6721  {
    6722  // 1-byte characters: 0xxxxxxx (ASCII)
    6723  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    6724  }
    6725  else if (codepoint <= 0x7ff)
    6726  {
    6727  // 2-byte characters: 110xxxxx 10xxxxxx
    6728  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    6729  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6730  }
    6731  else if (codepoint <= 0xffff)
    6732  {
    6733  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    6734  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    6735  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    6736  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6737  }
    6738  else if (codepoint <= 0x10ffff)
    6739  {
    6740  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    6741  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    6742  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    6743  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    6744  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6745  }
    6746  else
    6747  {
    6748  throw std::out_of_range("code points above 0x10FFFF are invalid");
    6749  }
    6750 
    6751  return result;
    6752  }
    6753 
    6755  static std::string token_type_name(token_type t)
    6756  {
    6757  switch (t)
    6758  {
    6759  case token_type::uninitialized:
    6760  return "<uninitialized>";
    6761  case token_type::literal_true:
    6762  return "true literal";
    6763  case token_type::literal_false:
    6764  return "false literal";
    6765  case token_type::literal_null:
    6766  return "null literal";
    6767  case token_type::value_string:
    6768  return "string literal";
    6769  case token_type::value_number:
    6770  return "number literal";
    6771  case token_type::begin_array:
    6772  return "'['";
    6773  case token_type::begin_object:
    6774  return "'{'";
    6775  case token_type::end_array:
    6776  return "']'";
    6777  case token_type::end_object:
    6778  return "'}'";
    6779  case token_type::name_separator:
    6780  return "':'";
    6781  case token_type::value_separator:
    6782  return "','";
    6783  case token_type::parse_error:
    6784  return "<parse error>";
    6785  case token_type::end_of_input:
    6786  return "end of input";
    6787  default:
    6788  {
    6789  // catch non-enum values
    6790  return "unknown token"; // LCOV_EXCL_LINE
    6791  }
    6792  }
    6793  }
    6794 
    6805  token_type scan() noexcept
    6806  {
    6807  // pointer for backtracking information
    6808  m_marker = nullptr;
    6809 
    6810  // remember the begin of the token
    6811  m_start = m_cursor;
    6812  assert(m_start != nullptr);
    6813 
    6814 
    6815  {
    6816  lexer_char_t yych;
    6817  unsigned int yyaccept = 0;
    6818  static const unsigned char yybm[] =
    6819  {
    6820  0, 0, 0, 0, 0, 0, 0, 0,
    6821  0, 32, 32, 0, 0, 32, 0, 0,
    6822  64, 64, 64, 64, 64, 64, 64, 64,
    6823  64, 64, 64, 64, 64, 64, 64, 64,
    6824  96, 64, 0, 64, 64, 64, 64, 64,
    6825  64, 64, 64, 64, 64, 64, 64, 64,
    6826  192, 192, 192, 192, 192, 192, 192, 192,
    6827  192, 192, 64, 64, 64, 64, 64, 64,
    6828  64, 64, 64, 64, 64, 64, 64, 64,
    6829  64, 64, 64, 64, 64, 64, 64, 64,
    6830  64, 64, 64, 64, 64, 64, 64, 64,
    6831  64, 64, 64, 64, 0, 64, 64, 64,
    6832  64, 64, 64, 64, 64, 64, 64, 64,
    6833  64, 64, 64, 64, 64, 64, 64, 64,
    6834  64, 64, 64, 64, 64, 64, 64, 64,
    6835  64, 64, 64, 64, 64, 64, 64, 64,
    6836  64, 64, 64, 64, 64, 64, 64, 64,
    6837  64, 64, 64, 64, 64, 64, 64, 64,
    6838  64, 64, 64, 64, 64, 64, 64, 64,
    6839  64, 64, 64, 64, 64, 64, 64, 64,
    6840  64, 64, 64, 64, 64, 64, 64, 64,
    6841  64, 64, 64, 64, 64, 64, 64, 64,
    6842  64, 64, 64, 64, 64, 64, 64, 64,
    6843  64, 64, 64, 64, 64, 64, 64, 64,
    6844  64, 64, 64, 64, 64, 64, 64, 64,
    6845  64, 64, 64, 64, 64, 64, 64, 64,
    6846  64, 64, 64, 64, 64, 64, 64, 64,
    6847  64, 64, 64, 64, 64, 64, 64, 64,
    6848  64, 64, 64, 64, 64, 64, 64, 64,
    6849  64, 64, 64, 64, 64, 64, 64, 64,
    6850  64, 64, 64, 64, 64, 64, 64, 64,
    6851  64, 64, 64, 64, 64, 64, 64, 64,
    6852  };
    6853  if ((m_limit - m_cursor) < 5)
    6854  {
    6855  yyfill(); // LCOV_EXCL_LINE;
    6856  }
    6857  yych = *m_cursor;
    6858  if (yych <= ':')
    6859  {
    6860  if (yych <= ' ')
    6861  {
    6862  if (yych <= '\n')
    6863  {
    6864  if (yych <= 0x00)
    6865  {
    6866  goto basic_json_parser_28;
    6867  }
    6868  if (yych <= 0x08)
    6869  {
    6870  goto basic_json_parser_30;
    6871  }
    6872  if (yych >= '\n')
    6873  {
    6874  goto basic_json_parser_4;
    6875  }
    6876  }
    6877  else
    6878  {
    6879  if (yych == '\r')
    6880  {
    6881  goto basic_json_parser_2;
    6882  }
    6883  if (yych <= 0x1F)
    6884  {
    6885  goto basic_json_parser_30;
    6886  }
    6887  }
    6888  }
    6889  else
    6890  {
    6891  if (yych <= ',')
    6892  {
    6893  if (yych == '"')
    6894  {
    6895  goto basic_json_parser_27;
    6896  }
    6897  if (yych <= '+')
    6898  {
    6899  goto basic_json_parser_30;
    6900  }
    6901  goto basic_json_parser_16;
    6902  }
    6903  else
    6904  {
    6905  if (yych <= '/')
    6906  {
    6907  if (yych <= '-')
    6908  {
    6909  goto basic_json_parser_23;
    6910  }
    6911  goto basic_json_parser_30;
    6912  }
    6913  else
    6914  {
    6915  if (yych <= '0')
    6916  {
    6917  goto basic_json_parser_24;
    6918  }
    6919  if (yych <= '9')
    6920  {
    6921  goto basic_json_parser_26;
    6922  }
    6923  goto basic_json_parser_18;
    6924  }
    6925  }
    6926  }
    6927  }
    6928  else
    6929  {
    6930  if (yych <= 'n')
    6931  {
    6932  if (yych <= ']')
    6933  {
    6934  if (yych == '[')
    6935  {
    6936  goto basic_json_parser_8;
    6937  }
    6938  if (yych <= '\\')
    6939  {
    6940  goto basic_json_parser_30;
    6941  }
    6942  goto basic_json_parser_10;
    6943  }
    6944  else
    6945  {
    6946  if (yych == 'f')
    6947  {
    6948  goto basic_json_parser_22;
    6949  }
    6950  if (yych <= 'm')
    6951  {
    6952  goto basic_json_parser_30;
    6953  }
    6954  goto basic_json_parser_20;
    6955  }
    6956  }
    6957  else
    6958  {
    6959  if (yych <= '{')
    6960  {
    6961  if (yych == 't')
    6962  {
    6963  goto basic_json_parser_21;
    6964  }
    6965  if (yych <= 'z')
    6966  {
    6967  goto basic_json_parser_30;
    6968  }
    6969  goto basic_json_parser_12;
    6970  }
    6971  else
    6972  {
    6973  if (yych <= '}')
    6974  {
    6975  if (yych <= '|')
    6976  {
    6977  goto basic_json_parser_30;
    6978  }
    6979  goto basic_json_parser_14;
    6980  }
    6981  else
    6982  {
    6983  if (yych == 0xEF)
    6984  {
    6985  goto basic_json_parser_6;
    6986  }
    6987  goto basic_json_parser_30;
    6988  }
    6989  }
    6990  }
    6991  }
    6992 basic_json_parser_2:
    6993  ++m_cursor;
    6994  yych = *m_cursor;
    6995  goto basic_json_parser_5;
    6996 basic_json_parser_3:
    6997  {
    6998  return scan();
    6999  }
    7000 basic_json_parser_4:
    7001  ++m_cursor;
    7002  if (m_limit <= m_cursor)
    7003  {
    7004  yyfill(); // LCOV_EXCL_LINE;
    7005  }
    7006  yych = *m_cursor;
    7007 basic_json_parser_5:
    7008  if (yybm[0 + yych] & 32)
    7009  {
    7010  goto basic_json_parser_4;
    7011  }
    7012  goto basic_json_parser_3;
    7013 basic_json_parser_6:
    7014  yyaccept = 0;
    7015  yych = *(m_marker = ++m_cursor);
    7016  if (yych == 0xBB)
    7017  {
    7018  goto basic_json_parser_64;
    7019  }
    7020 basic_json_parser_7:
    7021  {
    7022  return token_type::parse_error;
    7023  }
    7024 basic_json_parser_8:
    7025  ++m_cursor;
    7026  {
    7027  return token_type::begin_array;
    7028  }
    7029 basic_json_parser_10:
    7030  ++m_cursor;
    7031  {
    7032  return token_type::end_array;
    7033  }
    7034 basic_json_parser_12:
    7035  ++m_cursor;
    7036  {
    7037  return token_type::begin_object;
    7038  }
    7039 basic_json_parser_14:
    7040  ++m_cursor;
    7041  {
    7042  return token_type::end_object;
    7043  }
    7044 basic_json_parser_16:
    7045  ++m_cursor;
    7046  {
    7047  return token_type::value_separator;
    7048  }
    7049 basic_json_parser_18:
    7050  ++m_cursor;
    7051  {
    7052  return token_type::name_separator;
    7053  }
    7054 basic_json_parser_20:
    7055  yyaccept = 0;
    7056  yych = *(m_marker = ++m_cursor);
    7057  if (yych == 'u')
    7058  {
    7059  goto basic_json_parser_60;
    7060  }
    7061  goto basic_json_parser_7;
    7062 basic_json_parser_21:
    7063  yyaccept = 0;
    7064  yych = *(m_marker = ++m_cursor);
    7065  if (yych == 'r')
    7066  {
    7067  goto basic_json_parser_56;
    7068  }
    7069  goto basic_json_parser_7;
    7070 basic_json_parser_22:
    7071  yyaccept = 0;
    7072  yych = *(m_marker = ++m_cursor);
    7073  if (yych == 'a')
    7074  {
    7075  goto basic_json_parser_51;
    7076  }
    7077  goto basic_json_parser_7;
    7078 basic_json_parser_23:
    7079  yych = *++m_cursor;
    7080  if (yych <= '/')
    7081  {
    7082  goto basic_json_parser_7;
    7083  }
    7084  if (yych <= '0')
    7085  {
    7086  goto basic_json_parser_50;
    7087  }
    7088  if (yych <= '9')
    7089  {
    7090  goto basic_json_parser_41;
    7091  }
    7092  goto basic_json_parser_7;
    7093 basic_json_parser_24:
    7094  yyaccept = 1;
    7095  yych = *(m_marker = ++m_cursor);
    7096  if (yych <= 'D')
    7097  {
    7098  if (yych == '.')
    7099  {
    7100  goto basic_json_parser_43;
    7101  }
    7102  }
    7103  else
    7104  {
    7105  if (yych <= 'E')
    7106  {
    7107  goto basic_json_parser_44;
    7108  }
    7109  if (yych == 'e')
    7110  {
    7111  goto basic_json_parser_44;
    7112  }
    7113  }
    7114 basic_json_parser_25:
    7115  {
    7116  return token_type::value_number;
    7117  }
    7118 basic_json_parser_26:
    7119  yyaccept = 1;
    7120  yych = *(m_marker = ++m_cursor);
    7121  goto basic_json_parser_42;
    7122 basic_json_parser_27:
    7123  yyaccept = 0;
    7124  yych = *(m_marker = ++m_cursor);
    7125  if (yych <= 0x0F)
    7126  {
    7127  goto basic_json_parser_7;
    7128  }
    7129  goto basic_json_parser_32;
    7130 basic_json_parser_28:
    7131  ++m_cursor;
    7132  {
    7133  return token_type::end_of_input;
    7134  }
    7135 basic_json_parser_30:
    7136  yych = *++m_cursor;
    7137  goto basic_json_parser_7;
    7138 basic_json_parser_31:
    7139  ++m_cursor;
    7140  if (m_limit <= m_cursor)
    7141  {
    7142  yyfill(); // LCOV_EXCL_LINE;
    7143  }
    7144  yych = *m_cursor;
    7145 basic_json_parser_32:
    7146  if (yybm[0 + yych] & 64)
    7147  {
    7148  goto basic_json_parser_31;
    7149  }
    7150  if (yych <= 0x0F)
    7151  {
    7152  goto basic_json_parser_33;
    7153  }
    7154  if (yych <= '"')
    7155  {
    7156  goto basic_json_parser_35;
    7157  }
    7158  goto basic_json_parser_34;
    7159 basic_json_parser_33:
    7160  m_cursor = m_marker;
    7161  if (yyaccept == 0)
    7162  {
    7163  goto basic_json_parser_7;
    7164  }
    7165  else
    7166  {
    7167  goto basic_json_parser_25;
    7168  }
    7169 basic_json_parser_34:
    7170  ++m_cursor;
    7171  if (m_limit <= m_cursor)
    7172  {
    7173  yyfill(); // LCOV_EXCL_LINE;
    7174  }
    7175  yych = *m_cursor;
    7176  if (yych <= 'e')
    7177  {
    7178  if (yych <= '/')
    7179  {
    7180  if (yych == '"')
    7181  {
    7182  goto basic_json_parser_31;
    7183  }
    7184  if (yych <= '.')
    7185  {
    7186  goto basic_json_parser_33;
    7187  }
    7188  goto basic_json_parser_31;
    7189  }
    7190  else
    7191  {
    7192  if (yych <= '\\')
    7193  {
    7194  if (yych <= '[')
    7195  {
    7196  goto basic_json_parser_33;
    7197  }
    7198  goto basic_json_parser_31;
    7199  }
    7200  else
    7201  {
    7202  if (yych == 'b')
    7203  {
    7204  goto basic_json_parser_31;
    7205  }
    7206  goto basic_json_parser_33;
    7207  }
    7208  }
    7209  }
    7210  else
    7211  {
    7212  if (yych <= 'q')
    7213  {
    7214  if (yych <= 'f')
    7215  {
    7216  goto basic_json_parser_31;
    7217  }
    7218  if (yych == 'n')
    7219  {
    7220  goto basic_json_parser_31;
    7221  }
    7222  goto basic_json_parser_33;
    7223  }
    7224  else
    7225  {
    7226  if (yych <= 's')
    7227  {
    7228  if (yych <= 'r')
    7229  {
    7230  goto basic_json_parser_31;
    7231  }
    7232  goto basic_json_parser_33;
    7233  }
    7234  else
    7235  {
    7236  if (yych <= 't')
    7237  {
    7238  goto basic_json_parser_31;
    7239  }
    7240  if (yych <= 'u')
    7241  {
    7242  goto basic_json_parser_37;
    7243  }
    7244  goto basic_json_parser_33;
    7245  }
    7246  }
    7247  }
    7248 basic_json_parser_35:
    7249  ++m_cursor;
    7250  {
    7251  return token_type::value_string;
    7252  }
    7253 basic_json_parser_37:
    7254  ++m_cursor;
    7255  if (m_limit <= m_cursor)
    7256  {
    7257  yyfill(); // LCOV_EXCL_LINE;
    7258  }
    7259  yych = *m_cursor;
    7260  if (yych <= '@')
    7261  {
    7262  if (yych <= '/')
    7263  {
    7264  goto basic_json_parser_33;
    7265  }
    7266  if (yych >= ':')
    7267  {
    7268  goto basic_json_parser_33;
    7269  }
    7270  }
    7271  else
    7272  {
    7273  if (yych <= 'F')
    7274  {
    7275  goto basic_json_parser_38;
    7276  }
    7277  if (yych <= '`')
    7278  {
    7279  goto basic_json_parser_33;
    7280  }
    7281  if (yych >= 'g')
    7282  {
    7283  goto basic_json_parser_33;
    7284  }
    7285  }
    7286 basic_json_parser_38:
    7287  ++m_cursor;
    7288  if (m_limit <= m_cursor)
    7289  {
    7290  yyfill(); // LCOV_EXCL_LINE;
    7291  }
    7292  yych = *m_cursor;
    7293  if (yych <= '@')
    7294  {
    7295  if (yych <= '/')
    7296  {
    7297  goto basic_json_parser_33;
    7298  }
    7299  if (yych >= ':')
    7300  {
    7301  goto basic_json_parser_33;
    7302  }
    7303  }
    7304  else
    7305  {
    7306  if (yych <= 'F')
    7307  {
    7308  goto basic_json_parser_39;
    7309  }
    7310  if (yych <= '`')
    7311  {
    7312  goto basic_json_parser_33;
    7313  }
    7314  if (yych >= 'g')
    7315  {
    7316  goto basic_json_parser_33;
    7317  }
    7318  }
    7319 basic_json_parser_39:
    7320  ++m_cursor;
    7321  if (m_limit <= m_cursor)
    7322  {
    7323  yyfill(); // LCOV_EXCL_LINE;
    7324  }
    7325  yych = *m_cursor;
    7326  if (yych <= '@')
    7327  {
    7328  if (yych <= '/')
    7329  {
    7330  goto basic_json_parser_33;
    7331  }
    7332  if (yych >= ':')
    7333  {
    7334  goto basic_json_parser_33;
    7335  }
    7336  }
    7337  else
    7338  {
    7339  if (yych <= 'F')
    7340  {
    7341  goto basic_json_parser_40;
    7342  }
    7343  if (yych <= '`')
    7344  {
    7345  goto basic_json_parser_33;
    7346  }
    7347  if (yych >= 'g')
    7348  {
    7349  goto basic_json_parser_33;
    7350  }
    7351  }
    7352 basic_json_parser_40:
    7353  ++m_cursor;
    7354  if (m_limit <= m_cursor)
    7355  {
    7356  yyfill(); // LCOV_EXCL_LINE;
    7357  }
    7358  yych = *m_cursor;
    7359  if (yych <= '@')
    7360  {
    7361  if (yych <= '/')
    7362  {
    7363  goto basic_json_parser_33;
    7364  }
    7365  if (yych <= '9')
    7366  {
    7367  goto basic_json_parser_31;
    7368  }
    7369  goto basic_json_parser_33;
    7370  }
    7371  else
    7372  {
    7373  if (yych <= 'F')
    7374  {
    7375  goto basic_json_parser_31;
    7376  }
    7377  if (yych <= '`')
    7378  {
    7379  goto basic_json_parser_33;
    7380  }
    7381  if (yych <= 'f')
    7382  {
    7383  goto basic_json_parser_31;
    7384  }
    7385  goto basic_json_parser_33;
    7386  }
    7387 basic_json_parser_41:
    7388  yyaccept = 1;
    7389  m_marker = ++m_cursor;
    7390  if ((m_limit - m_cursor) < 3)
    7391  {
    7392  yyfill(); // LCOV_EXCL_LINE;
    7393  }
    7394  yych = *m_cursor;
    7395 basic_json_parser_42:
    7396  if (yybm[0 + yych] & 128)
    7397  {
    7398  goto basic_json_parser_41;
    7399  }
    7400  if (yych <= 'D')
    7401  {
    7402  if (yych != '.')
    7403  {
    7404  goto basic_json_parser_25;
    7405  }
    7406  }
    7407  else
    7408  {
    7409  if (yych <= 'E')
    7410  {
    7411  goto basic_json_parser_44;
    7412  }
    7413  if (yych == 'e')
    7414  {
    7415  goto basic_json_parser_44;
    7416  }
    7417  goto basic_json_parser_25;
    7418  }
    7419 basic_json_parser_43:
    7420  yych = *++m_cursor;
    7421  if (yych <= '/')
    7422  {
    7423  goto basic_json_parser_33;
    7424  }
    7425  if (yych <= '9')
    7426  {
    7427  goto basic_json_parser_48;
    7428  }
    7429  goto basic_json_parser_33;
    7430 basic_json_parser_44:
    7431  yych = *++m_cursor;
    7432  if (yych <= ',')
    7433  {
    7434  if (yych != '+')
    7435  {
    7436  goto basic_json_parser_33;
    7437  }
    7438  }
    7439  else
    7440  {
    7441  if (yych <= '-')
    7442  {
    7443  goto basic_json_parser_45;
    7444  }
    7445  if (yych <= '/')
    7446  {
    7447  goto basic_json_parser_33;
    7448  }
    7449  if (yych <= '9')
    7450  {
    7451  goto basic_json_parser_46;
    7452  }
    7453  goto basic_json_parser_33;
    7454  }
    7455 basic_json_parser_45:
    7456  yych = *++m_cursor;
    7457  if (yych <= '/')
    7458  {
    7459  goto basic_json_parser_33;
    7460  }
    7461  if (yych >= ':')
    7462  {
    7463  goto basic_json_parser_33;
    7464  }
    7465 basic_json_parser_46:
    7466  ++m_cursor;
    7467  if (m_limit <= m_cursor)
    7468  {
    7469  yyfill(); // LCOV_EXCL_LINE;
    7470  }
    7471  yych = *m_cursor;
    7472  if (yych <= '/')
    7473  {
    7474  goto basic_json_parser_25;
    7475  }
    7476  if (yych <= '9')
    7477  {
    7478  goto basic_json_parser_46;
    7479  }
    7480  goto basic_json_parser_25;
    7481 basic_json_parser_48:
    7482  yyaccept = 1;
    7483  m_marker = ++m_cursor;
    7484  if ((m_limit - m_cursor) < 3)
    7485  {
    7486  yyfill(); // LCOV_EXCL_LINE;
    7487  }
    7488  yych = *m_cursor;
    7489  if (yych <= 'D')
    7490  {
    7491  if (yych <= '/')
    7492  {
    7493  goto basic_json_parser_25;
    7494  }
    7495  if (yych <= '9')
    7496  {
    7497  goto basic_json_parser_48;
    7498  }
    7499  goto basic_json_parser_25;
    7500  }
    7501  else
    7502  {
    7503  if (yych <= 'E')
    7504  {
    7505  goto basic_json_parser_44;
    7506  }
    7507  if (yych == 'e')
    7508  {
    7509  goto basic_json_parser_44;
    7510  }
    7511  goto basic_json_parser_25;
    7512  }
    7513 basic_json_parser_50:
    7514  yyaccept = 1;
    7515  yych = *(m_marker = ++m_cursor);
    7516  if (yych <= 'D')
    7517  {
    7518  if (yych == '.')
    7519  {
    7520  goto basic_json_parser_43;
    7521  }
    7522  goto basic_json_parser_25;
    7523  }
    7524  else
    7525  {
    7526  if (yych <= 'E')
    7527  {
    7528  goto basic_json_parser_44;
    7529  }
    7530  if (yych == 'e')
    7531  {
    7532  goto basic_json_parser_44;
    7533  }
    7534  goto basic_json_parser_25;
    7535  }
    7536 basic_json_parser_51:
    7537  yych = *++m_cursor;
    7538  if (yych != 'l')
    7539  {
    7540  goto basic_json_parser_33;
    7541  }
    7542  yych = *++m_cursor;
    7543  if (yych != 's')
    7544  {
    7545  goto basic_json_parser_33;
    7546  }
    7547  yych = *++m_cursor;
    7548  if (yych != 'e')
    7549  {
    7550  goto basic_json_parser_33;
    7551  }
    7552  ++m_cursor;
    7553  {
    7554  return token_type::literal_false;
    7555  }
    7556 basic_json_parser_56:
    7557  yych = *++m_cursor;
    7558  if (yych != 'u')
    7559  {
    7560  goto basic_json_parser_33;
    7561  }
    7562  yych = *++m_cursor;
    7563  if (yych != 'e')
    7564  {
    7565  goto basic_json_parser_33;
    7566  }
    7567  ++m_cursor;
    7568  {
    7569  return token_type::literal_true;
    7570  }
    7571 basic_json_parser_60:
    7572  yych = *++m_cursor;
    7573  if (yych != 'l')
    7574  {
    7575  goto basic_json_parser_33;
    7576  }
    7577  yych = *++m_cursor;
    7578  if (yych != 'l')
    7579  {
    7580  goto basic_json_parser_33;
    7581  }
    7582  ++m_cursor;
    7583  {
    7584  return token_type::literal_null;
    7585  }
    7586 basic_json_parser_64:
    7587  yych = *++m_cursor;
    7588  if (yych != 0xBF)
    7589  {
    7590  goto basic_json_parser_33;
    7591  }
    7592  ++m_cursor;
    7593  {
    7594  return scan();
    7595  }
    7596  }
    7597 
    7598 
    7599  }
    7600 
    7602  void yyfill() noexcept
    7603  {
    7604  if (m_stream == nullptr or not * m_stream)
    7605  {
    7606  return;
    7607  }
    7608 
    7609  const ssize_t offset_start = m_start - m_content;
    7610  const ssize_t offset_marker = m_marker - m_start;
    7611  const ssize_t offset_cursor = m_cursor - m_start;
    7612 
    7613  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7614  std::string line;
    7615  assert(m_stream != nullptr);
    7616  std::getline(*m_stream, line);
    7617  m_buffer += "\n" + line; // add line with newline symbol
    7618 
    7619  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7620  assert(m_content != nullptr);
    7621  m_start = m_content;
    7622  m_marker = m_start + offset_marker;
    7623  m_cursor = m_start + offset_cursor;
    7624  m_limit = m_start + m_buffer.size() - 1;
    7625  }
    7626 
    7628  string_t get_token() const noexcept
    7629  {
    7630  assert(m_start != nullptr);
    7631  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7632  static_cast<size_t>(m_cursor - m_start));
    7633  }
    7634 
    7656  string_t get_string() const
    7657  {
    7658  string_t result;
    7659  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    7660 
    7661  // iterate the result between the quotes
    7662  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    7663  {
    7664  // process escaped characters
    7665  if (*i == '\\')
    7666  {
    7667  // read next character
    7668  ++i;
    7669 
    7670  switch (*i)
    7671  {
    7672  // the default escapes
    7673  case 't':
    7674  {
    7675  result += "\t";
    7676  break;
    7677  }
    7678  case 'b':
    7679  {
    7680  result += "\b";
    7681  break;
    7682  }
    7683  case 'f':
    7684  {
    7685  result += "\f";
    7686  break;
    7687  }
    7688  case 'n':
    7689  {
    7690  result += "\n";
    7691  break;
    7692  }
    7693  case 'r':
    7694  {
    7695  result += "\r";
    7696  break;
    7697  }
    7698  case '\\':
    7699  {
    7700  result += "\\";
    7701  break;
    7702  }
    7703  case '/':
    7704  {
    7705  result += "/";
    7706  break;
    7707  }
    7708  case '"':
    7709  {
    7710  result += "\"";
    7711  break;
    7712  }
    7713 
    7714  // unicode
    7715  case 'u':
    7716  {
    7717  // get code xxxx from uxxxx
    7718  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    7719  4).c_str(), nullptr, 16);
    7720 
    7721  // check if codepoint is a high surrogate
    7722  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    7723  {
    7724  // make sure there is a subsequent unicode
    7725  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    7726  {
    7727  throw std::invalid_argument("missing low surrogate");
    7728  }
    7729 
    7730  // get code yyyy from uxxxx\uyyyy
    7731  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    7732  (i + 7), 4).c_str(), nullptr, 16);
    7733  result += to_unicode(codepoint, codepoint2);
    7734  // skip the next 10 characters (xxxx\uyyyy)
    7735  i += 10;
    7736  }
    7737  else
    7738  {
    7739  // add unicode character(s)
    7740  result += to_unicode(codepoint);
    7741  // skip the next four characters (xxxx)
    7742  i += 4;
    7743  }
    7744  break;
    7745  }
    7746  }
    7747  }
    7748  else
    7749  {
    7750  // all other characters are just copied to the end of the
    7751  // string
    7752  result.append(1, static_cast<typename string_t::value_type>(*i));
    7753  }
    7754  }
    7755 
    7756  return result;
    7757  }
    7758 
    7776  long double get_number() const
    7777  {
    7778  // conversion
    7779  typename string_t::value_type* endptr;
    7780  assert(m_start != nullptr);
    7781  const auto float_val = std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7782  &endptr);
    7783 
    7784  // return float_val if the whole number was translated and NAN
    7785  // otherwise
    7786  return (reinterpret_cast<lexer_char_t*>(endptr) == m_cursor) ? float_val : NAN;
    7787  }
    7788 
    7789  private:
    7791  std::istream* m_stream = nullptr;
    7793  string_t m_buffer;
    7795  const lexer_char_t* m_content = nullptr;
    7797  const lexer_char_t* m_start = nullptr;
    7799  const lexer_char_t* m_marker = nullptr;
    7801  const lexer_char_t* m_cursor = nullptr;
    7803  const lexer_char_t* m_limit = nullptr;
    7804  };
    7805 
    7811  class parser
    7812  {
    7813  public:
    7815  parser(const string_t& s, parser_callback_t cb = nullptr)
    7816  : callback(cb), m_lexer(s)
    7817  {
    7818  // read first token
    7819  get_token();
    7820  }
    7821 
    7823  parser(std::istream& _is, parser_callback_t cb = nullptr)
    7824  : callback(cb), m_lexer(&_is)
    7825  {
    7826  // read first token
    7827  get_token();
    7828  }
    7829 
    7831  basic_json parse()
    7832  {
    7833  basic_json result = parse_internal(true);
    7834 
    7835  expect(lexer::token_type::end_of_input);
    7836 
    7837  // return parser result and replace it with null in case the
    7838  // top-level value was discarded by the callback function
    7839  return result.is_discarded() ? basic_json() : result;
    7840  }
    7841 
    7842  private:
    7844  basic_json parse_internal(bool keep)
    7845  {
    7846  auto result = basic_json(value_t::discarded);
    7847 
    7848  switch (last_token)
    7849  {
    7850  case lexer::token_type::begin_object:
    7851  {
    7852  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    7853  {
    7854  // explicitly set result to object to cope with {}
    7855  result.m_type = value_t::object;
    7856  result.m_value = json_value(value_t::object);
    7857  }
    7858 
    7859  // read next token
    7860  get_token();
    7861 
    7862  // closing } -> we are done
    7863  if (last_token == lexer::token_type::end_object)
    7864  {
    7865  get_token();
    7866  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    7867  {
    7868  result = basic_json(value_t::discarded);
    7869  }
    7870  return result;
    7871  }
    7872 
    7873  // no comma is expected here
    7874  unexpect(lexer::token_type::value_separator);
    7875 
    7876  // otherwise: parse key-value pairs
    7877  do
    7878  {
    7879  // ugly, but could be fixed with loop reorganization
    7880  if (last_token == lexer::token_type::value_separator)
    7881  {
    7882  get_token();
    7883  }
    7884 
    7885  // store key
    7886  expect(lexer::token_type::value_string);
    7887  const auto key = m_lexer.get_string();
    7888 
    7889  bool keep_tag = false;
    7890  if (keep)
    7891  {
    7892  if (callback)
    7893  {
    7894  basic_json k(key);
    7895  keep_tag = callback(depth, parse_event_t::key, k);
    7896  }
    7897  else
    7898  {
    7899  keep_tag = true;
    7900  }
    7901  }
    7902 
    7903  // parse separator (:)
    7904  get_token();
    7905  expect(lexer::token_type::name_separator);
    7906 
    7907  // parse and add value
    7908  get_token();
    7909  auto value = parse_internal(keep);
    7910  if (keep and keep_tag and not value.is_discarded())
    7911  {
    7912  result[key] = std::move(value);
    7913  }
    7914  }
    7915  while (last_token == lexer::token_type::value_separator);
    7916 
    7917  // closing }
    7918  expect(lexer::token_type::end_object);
    7919  get_token();
    7920  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    7921  {
    7922  result = basic_json(value_t::discarded);
    7923  }
    7924 
    7925  return result;
    7926  }
    7927 
    7928  case lexer::token_type::begin_array:
    7929  {
    7930  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    7931  {
    7932  // explicitly set result to object to cope with []
    7933  result.m_type = value_t::array;
    7934  result.m_value = json_value(value_t::array);
    7935  }
    7936 
    7937  // read next token
    7938  get_token();
    7939 
    7940  // closing ] -> we are done
    7941  if (last_token == lexer::token_type::end_array)
    7942  {
    7943  get_token();
    7944  if (callback and not callback(--depth, parse_event_t::array_end, result))
    7945  {
    7946  result = basic_json(value_t::discarded);
    7947  }
    7948  return result;
    7949  }
    7950 
    7951  // no comma is expected here
    7952  unexpect(lexer::token_type::value_separator);
    7953 
    7954  // otherwise: parse values
    7955  do
    7956  {
    7957  // ugly, but could be fixed with loop reorganization
    7958  if (last_token == lexer::token_type::value_separator)
    7959  {
    7960  get_token();
    7961  }
    7962 
    7963  // parse value
    7964  auto value = parse_internal(keep);
    7965  if (keep and not value.is_discarded())
    7966  {
    7967  result.push_back(std::move(value));
    7968  }
    7969  }
    7970  while (last_token == lexer::token_type::value_separator);
    7971 
    7972  // closing ]
    7973  expect(lexer::token_type::end_array);
    7974  get_token();
    7975  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    7976  {
    7977  result = basic_json(value_t::discarded);
    7978  }
    7979 
    7980  return result;
    7981  }
    7982 
    7983  case lexer::token_type::literal_null:
    7984  {
    7985  get_token();
    7986  result.m_type = value_t::null;
    7987  break;
    7988  }
    7989 
    7990  case lexer::token_type::value_string:
    7991  {
    7992  const auto s = m_lexer.get_string();
    7993  get_token();
    7994  result = basic_json(s);
    7995  break;
    7996  }
    7997 
    7998  case lexer::token_type::literal_true:
    7999  {
    8000  get_token();
    8001  result.m_type = value_t::boolean;
    8002  result.m_value = true;
    8003  break;
    8004  }
    8005 
    8006  case lexer::token_type::literal_false:
    8007  {
    8008  get_token();
    8009  result.m_type = value_t::boolean;
    8010  result.m_value = false;
    8011  break;
    8012  }
    8013 
    8014  case lexer::token_type::value_number:
    8015  {
    8016  auto float_val = m_lexer.get_number();
    8017 
    8018  // NAN is returned if token could not be translated
    8019  // completely
    8020  if (std::isnan(float_val))
    8021  {
    8022  throw std::invalid_argument(std::string("parse error - ") +
    8023  m_lexer.get_token() + " is not a number");
    8024  }
    8025 
    8026  get_token();
    8027 
    8028  // check if conversion loses precision
    8029  const auto int_val = static_cast<number_integer_t>(float_val);
    8030  if (approx(float_val, static_cast<long double>(int_val)))
    8031  {
    8032  // we would not lose precision -> return int
    8033  result.m_type = value_t::number_integer;
    8034  result.m_value = int_val;
    8035  }
    8036  else
    8037  {
    8038  // we would lose precision -> return float
    8039  result.m_type = value_t::number_float;
    8040  result.m_value = static_cast<number_float_t>(float_val);
    8041  }
    8042  break;
    8043  }
    8044 
    8045  default:
    8046  {
    8047  // the last token was unexpected
    8048  unexpect(last_token);
    8049  }
    8050  }
    8051 
    8052  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8053  {
    8054  result = basic_json(value_t::discarded);
    8055  }
    8056  return result;
    8057  }
    8058 
    8060  typename lexer::token_type get_token()
    8061  {
    8062  last_token = m_lexer.scan();
    8063  return last_token;
    8064  }
    8065 
    8066  void expect(typename lexer::token_type t) const
    8067  {
    8068  if (t != last_token)
    8069  {
    8070  std::string error_msg = "parse error - unexpected ";
    8071  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8072  lexer::token_type_name(last_token));
    8073  error_msg += "; expected " + lexer::token_type_name(t);
    8074  throw std::invalid_argument(error_msg);
    8075  }
    8076  }
    8077 
    8078  void unexpect(typename lexer::token_type t) const
    8079  {
    8080  if (t == last_token)
    8081  {
    8082  std::string error_msg = "parse error - unexpected ";
    8083  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8084  lexer::token_type_name(last_token));
    8085  throw std::invalid_argument(error_msg);
    8086  }
    8087  }
    8088 
    8089  private:
    8091  int depth = 0;
    8093  parser_callback_t callback;
    8095  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8097  lexer m_lexer;
    8098  };
    8099 };
    8100 
    8101 
    8103 // presets //
    8105 
    8115 }
    8116 
    8117 
    8119 // nonmember functions //
    8121 
    8122 // specialization of std::swap, and std::hash
    8123 namespace std
    8124 {
    8130 template <>
    8131 inline void swap(nlohmann::json& j1,
    8132  nlohmann::json& j2) noexcept(
    8133  is_nothrow_move_constructible<nlohmann::json>::value and
    8134  is_nothrow_move_assignable<nlohmann::json>::value
    8135  )
    8136 {
    8137  j1.swap(j2);
    8138 }
    8139 
    8141 template <>
    8142 struct hash<nlohmann::json>
    8143 {
    8149  std::size_t operator()(const nlohmann::json& j) const
    8150  {
    8151  // a naive hashing via the string representation
    8152  const auto& h = hash<nlohmann::json::string_t>();
    8153  return h(j.dump());
    8154  }
    8155 };
    8156 }
    8157 
    8170 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8171 {
    8172  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8173 }
    8174 
    8175 #endif
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6171
    -
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4454
    -
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6419
    -
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5065
    -
    typename std::allocator_traits< allocator_type >::pointer pointer
    the type of an element pointer
    Definition: json.hpp:228
    -
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:6574
    -
    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:1510
    -
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:2952
    -
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:5843
    -
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:3988
    -
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6112
    -
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5278
    -
    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:5912
    -
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:5839
    -
    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:1782
    -
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3201
    -
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4536
    -
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4483
    -
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6546
    -
    StringType string_t
    a type for a string
    Definition: json.hpp:434
    -
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4375
    -
    basic_json(boolean_t val)
    create a boolean (explicit)
    Definition: json.hpp:1132
    -
    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:1470
    -
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6427
    -
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:4921
    -
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:387
    -
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6075
    -
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6582
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:8114
    -
    reference front()
    access the first element
    Definition: json.hpp:3319
    -
    bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2095
    -
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:3699
    -
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6518
    -
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6523
    -
    a class to store JSON values
    Definition: json.hpp:188
    -
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6552
    -
    basic_json(const object_t &val)
    create an object (explicit)
    Definition: json.hpp:934
    -
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:4900
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4289
    -
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3799
    -
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3152
    -
    bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2114
    -
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6449
    -
    const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2589
    -
    basic_json(const CompatibleStringType &val)
    create a string (implicit)
    Definition: json.hpp:1114
    -
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4315
    -
    basic_json(size_type cnt, const basic_json &val)
    construct an array with count copies of given value
    Definition: json.hpp:1534
    -
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6374
    -
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6456
    -
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5240
    -
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:2993
    +
    1 
    38 #ifndef NLOHMANN_JSON_HPP
    39 #define NLOHMANN_JSON_HPP
    40 
    41 #include <algorithm>
    42 #include <array>
    43 #include <cassert>
    44 #include <ciso646>
    45 #include <cmath>
    46 #include <cstddef>
    47 #include <cstdio>
    48 #include <cstdlib>
    49 #include <functional>
    50 #include <initializer_list>
    51 #include <iomanip>
    52 #include <iostream>
    53 #include <iterator>
    54 #include <limits>
    55 #include <map>
    56 #include <memory>
    57 #include <sstream>
    58 #include <stdexcept>
    59 #include <string>
    60 #include <type_traits>
    61 #include <utility>
    62 #include <vector>
    63 
    64 // enable ssize_t on MinGW
    65 #ifdef __GNUC__
    66  #ifdef __MINGW32__
    67  #include <sys/types.h>
    68  #endif
    69 #endif
    70 
    71 // disable float-equal warnings on GCC/clang
    72 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    73  #pragma GCC diagnostic push
    74  #pragma GCC diagnostic ignored "-Wfloat-equal"
    75 #endif
    76 
    77 // enable ssize_t for MSVC
    78 #ifdef _MSC_VER
    79  #include <basetsd.h>
    80  using ssize_t = SSIZE_T;
    81 #endif
    82 
    88 namespace nlohmann
    89 {
    90 
    91 
    96 namespace
    97 {
    102 template<typename T>
    103 struct has_mapped_type
    104 {
    105  private:
    106  template<typename C> static char test(typename C::mapped_type*);
    107  template<typename C> static char (&test(...))[2];
    108  public:
    109  static constexpr bool value = sizeof(test<T>(0)) == 1;
    110 };
    111 
    112 }
    113 
    182 template <
    183  template<typename U, typename V, typename... Args> class ObjectType = std::map,
    184  template<typename U, typename... Args> class ArrayType = std::vector,
    185  class StringType = std::string,
    186  class BooleanType = bool,
    187  class NumberIntegerType = int64_t,
    188  class NumberFloatType = double,
    189  template<typename U> class AllocatorType = std::allocator
    190  >
    192 {
    193  private:
    195  using basic_json_t = basic_json<ObjectType,
    196  ArrayType,
    197  StringType,
    198  BooleanType,
    199  NumberIntegerType,
    200  NumberFloatType,
    201  AllocatorType>;
    202 
    203  public:
    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 
    233  // forward declaration
    234  template<typename Base> class json_reverse_iterator;
    235 
    237  class iterator;
    239  class const_iterator;
    244 
    246 
    247 
    252  {
    253  return allocator_type();
    254  }
    255 
    256 
    258  // JSON value data types //
    260 
    263 
    346  using object_t = ObjectType<StringType,
    347  basic_json,
    348  std::less<StringType>,
    349  AllocatorType<std::pair<const StringType,
    350  basic_json>>>;
    351 
    396  using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
    397 
    443  using string_t = StringType;
    444 
    469  using boolean_t = BooleanType;
    470 
    537  using number_integer_t = NumberIntegerType;
    538 
    602  using number_float_t = NumberFloatType;
    603 
    605 
    606 
    608  // JSON type enumeration //
    610 
    621  enum class value_t : uint8_t
    622  {
    623  null,
    624  object,
    625  array,
    626  string,
    627  boolean,
    628  number_integer,
    629  number_float,
    630  discarded
    631  };
    632 
    633 
    634  private:
    636  template<typename T, typename... Args>
    637  static T* create(Args&& ... args)
    638  {
    639  AllocatorType<T> alloc;
    640  auto deleter = [&](T * object)
    641  {
    642  alloc.deallocate(object, 1);
    643  };
    644  std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
    645  alloc.construct(object.get(), std::forward<Args>(args)...);
    646  return object.release();
    647  }
    648 
    650  // JSON value storage //
    652 
    660  union json_value
    661  {
    663  object_t* object;
    665  array_t* array;
    667  string_t* string;
    669  boolean_t boolean;
    671  number_integer_t number_integer;
    673  number_float_t number_float;
    674 
    676  json_value() noexcept = default;
    678  json_value(boolean_t v) noexcept : boolean(v) {}
    680  json_value(number_integer_t v) noexcept : number_integer(v) {}
    682  json_value(number_float_t v) noexcept : number_float(v) {}
    684  json_value(value_t t)
    685  {
    686  switch (t)
    687  {
    688  case value_t::object:
    689  {
    690  object = create<object_t>();
    691  break;
    692  }
    693 
    694  case value_t::array:
    695  {
    696  array = create<array_t>();
    697  break;
    698  }
    699 
    700  case value_t::string:
    701  {
    702  string = create<string_t>("");
    703  break;
    704  }
    705 
    706  case value_t::boolean:
    707  {
    708  boolean = boolean_t(false);
    709  break;
    710  }
    711 
    712  case value_t::number_integer:
    713  {
    714  number_integer = number_integer_t(0);
    715  break;
    716  }
    717 
    718  case value_t::number_float:
    719  {
    720  number_float = number_float_t(0.0);
    721  break;
    722  }
    723 
    724  default:
    725  {
    726  break;
    727  }
    728  }
    729  }
    730 
    732  json_value(const string_t& value)
    733  {
    734  string = create<string_t>(value);
    735  }
    736 
    738  json_value(const object_t& value)
    739  {
    740  object = create<object_t>(value);
    741  }
    742 
    744  json_value(const array_t& value)
    745  {
    746  array = create<array_t>(value);
    747  }
    748  };
    749 
    750 
    751  public:
    753  // JSON parser callback //
    755 
    764  enum class parse_event_t : uint8_t
    765  {
    767  object_start,
    769  object_end,
    771  array_start,
    773  array_end,
    775  key,
    777  value
    778  };
    779 
    829  using parser_callback_t = std::function<bool(int depth, parse_event_t event, basic_json& parsed)>;
    830 
    831 
    833  // constructors //
    835 
    838 
    877  : m_type(value_type), m_value(value_type)
    878  {}
    879 
    899  basic_json() noexcept = default;
    900 
    920  basic_json(std::nullptr_t) noexcept
    921  : basic_json(value_t::null)
    922  {}
    923 
    943  basic_json(const object_t& val)
    944  : m_type(value_t::object), m_value(val)
    945  {}
    946 
    970  template <class CompatibleObjectType, typename
    971  std::enable_if<
    972  std::is_constructible<typename object_t::key_type, typename CompatibleObjectType::key_type>::value and
    973  std::is_constructible<basic_json, typename CompatibleObjectType::mapped_type>::value, int>::type
    974  = 0>
    975  basic_json(const CompatibleObjectType& val)
    976  : m_type(value_t::object)
    977  {
    978  using std::begin;
    979  using std::end;
    980  m_value.object = create<object_t>(begin(val), end(val));
    981  }
    982 
    1002  basic_json(const array_t& val)
    1003  : m_type(value_t::array), m_value(val)
    1004  {}
    1005 
    1029  template <class CompatibleArrayType, typename
    1030  std::enable_if<
    1031  not std::is_same<CompatibleArrayType, typename basic_json_t::iterator>::value and
    1032  not std::is_same<CompatibleArrayType, typename basic_json_t::const_iterator>::value and
    1033  not std::is_same<CompatibleArrayType, typename basic_json_t::reverse_iterator>::value and
    1034  not std::is_same<CompatibleArrayType, typename basic_json_t::const_reverse_iterator>::value and
    1035  not std::is_same<CompatibleArrayType, typename array_t::iterator>::value and
    1036  not std::is_same<CompatibleArrayType, typename array_t::const_iterator>::value and
    1037  std::is_constructible<basic_json, typename CompatibleArrayType::value_type>::value, int>::type
    1038  = 0>
    1039  basic_json(const CompatibleArrayType& val)
    1040  : m_type(value_t::array)
    1041  {
    1042  using std::begin;
    1043  using std::end;
    1044  m_value.array = create<array_t>(begin(val), end(val));
    1045  }
    1046 
    1068  basic_json(const string_t& val)
    1069  : m_type(value_t::string), m_value(val)
    1070  {}
    1071 
    1092  basic_json(const typename string_t::value_type* val)
    1093  : basic_json(string_t(val))
    1094  {}
    1095 
    1119  template <class CompatibleStringType, typename
    1120  std::enable_if<
    1121  std::is_constructible<string_t, CompatibleStringType>::value, int>::type
    1122  = 0>
    1123  basic_json(const CompatibleStringType& val)
    1124  : basic_json(string_t(val))
    1125  {}
    1126 
    1142  : m_type(value_t::boolean), m_value(val)
    1143  {}
    1144 
    1170  template<typename T,
    1171  typename std::enable_if<
    1172  not (std::is_same<T, int>::value)
    1173  and std::is_same<T, number_integer_t>::value
    1174  , int>::type = 0>
    1176  : m_type(value_t::number_integer), m_value(val)
    1177  {}
    1178 
    1204  basic_json(const int val)
    1205  : m_type(value_t::number_integer),
    1206  m_value(static_cast<number_integer_t>(val))
    1207  {}
    1208 
    1234  template<typename CompatibleNumberIntegerType, typename
    1235  std::enable_if<
    1236  std::is_constructible<number_integer_t, CompatibleNumberIntegerType>::value and
    1237  std::numeric_limits<CompatibleNumberIntegerType>::is_integer, CompatibleNumberIntegerType>::type
    1238  = 0>
    1239  basic_json(const CompatibleNumberIntegerType val) noexcept
    1240  : m_type(value_t::number_integer),
    1241  m_value(static_cast<number_integer_t>(val))
    1242  {}
    1243 
    1269  : m_type(value_t::number_float), m_value(val)
    1270  {
    1271  // replace infinity and NAN by null
    1272  if (not std::isfinite(val))
    1273  {
    1274  m_type = value_t::null;
    1275  m_value = json_value();
    1276  }
    1277  }
    1278 
    1309  template<typename CompatibleNumberFloatType, typename = typename
    1310  std::enable_if<
    1311  std::is_constructible<number_float_t, CompatibleNumberFloatType>::value and
    1312  std::is_floating_point<CompatibleNumberFloatType>::value>::type
    1313  >
    1314  basic_json(const CompatibleNumberFloatType val) noexcept
    1315  : basic_json(number_float_t(val))
    1316  {}
    1317 
    1387  basic_json(std::initializer_list<basic_json> init,
    1388  bool type_deduction = true,
    1389  value_t manual_type = value_t::array)
    1390  {
    1391  // the initializer list could describe an object
    1392  bool is_an_object = true;
    1393 
    1394  // check if each element is an array with two elements whose first
    1395  // element is a string
    1396  for (const auto& element : init)
    1397  {
    1398  if (not element.is_array() or element.size() != 2
    1399  or not element[0].is_string())
    1400  {
    1401  // we found an element that makes it impossible to use the
    1402  // initializer list as object
    1403  is_an_object = false;
    1404  break;
    1405  }
    1406  }
    1407 
    1408  // adjust type if type deduction is not wanted
    1409  if (not type_deduction)
    1410  {
    1411  // if array is wanted, do not create an object though possible
    1412  if (manual_type == value_t::array)
    1413  {
    1414  is_an_object = false;
    1415  }
    1416 
    1417  // if object is wanted but impossible, throw an exception
    1418  if (manual_type == value_t::object and not is_an_object)
    1419  {
    1420  throw std::domain_error("cannot create object from initializer list");
    1421  }
    1422  }
    1423 
    1424  if (is_an_object)
    1425  {
    1426  // the initializer list is a list of pairs -> create object
    1427  m_type = value_t::object;
    1428  m_value = value_t::object;
    1429 
    1430  assert(m_value.object != nullptr);
    1431 
    1432  for (auto& element : init)
    1433  {
    1434  m_value.object->emplace(std::move(*(element[0].m_value.string)), std::move(element[1]));
    1435  }
    1436  }
    1437  else
    1438  {
    1439  // the initializer list describes an array -> create array
    1440  m_type = value_t::array;
    1441  m_value.array = create<array_t>(std::move(init));
    1442  }
    1443  }
    1444 
    1479  static basic_json array(std::initializer_list<basic_json> init =
    1480  std::initializer_list<basic_json>())
    1481  {
    1482  return basic_json(init, false, value_t::array);
    1483  }
    1484 
    1519  static basic_json object(std::initializer_list<basic_json> init =
    1520  std::initializer_list<basic_json>())
    1521  {
    1522  return basic_json(init, false, value_t::object);
    1523  }
    1524 
    1543  basic_json(size_type cnt, const basic_json& val)
    1544  : m_type(value_t::array)
    1545  {
    1546  m_value.array = create<array_t>(cnt, val);
    1547  }
    1548 
    1583  template <class InputIT, typename
    1584  std::enable_if<
    1585  std::is_same<InputIT, typename basic_json_t::iterator>::value or
    1586  std::is_same<InputIT, typename basic_json_t::const_iterator>::value
    1587  , int>::type
    1588  = 0>
    1589  basic_json(InputIT first, InputIT last) : m_type(first.m_object->m_type)
    1590  {
    1591  // make sure iterator fits the current value
    1592  if (first.m_object != last.m_object)
    1593  {
    1594  throw std::domain_error("iterators are not compatible");
    1595  }
    1596 
    1597  // check if iterator range is complete for primitive values
    1598  switch (m_type)
    1599  {
    1600  case value_t::boolean:
    1601  case value_t::number_float:
    1602  case value_t::number_integer:
    1603  case value_t::string:
    1604  {
    1605  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    1606  {
    1607  throw std::out_of_range("iterators out of range");
    1608  }
    1609  break;
    1610  }
    1611 
    1612  default:
    1613  {
    1614  break;
    1615  }
    1616  }
    1617 
    1618  switch (m_type)
    1619  {
    1620  case value_t::number_integer:
    1621  {
    1622  assert(first.m_object != nullptr);
    1623  m_value.number_integer = first.m_object->m_value.number_integer;
    1624  break;
    1625  }
    1626 
    1627  case value_t::number_float:
    1628  {
    1629  assert(first.m_object != nullptr);
    1630  m_value.number_float = first.m_object->m_value.number_float;
    1631  break;
    1632  }
    1633 
    1634  case value_t::boolean:
    1635  {
    1636  assert(first.m_object != nullptr);
    1637  m_value.boolean = first.m_object->m_value.boolean;
    1638  break;
    1639  }
    1640 
    1641  case value_t::string:
    1642  {
    1643  assert(first.m_object != nullptr);
    1644  m_value = *first.m_object->m_value.string;
    1645  break;
    1646  }
    1647 
    1648  case value_t::object:
    1649  {
    1650  m_value.object = create<object_t>(first.m_it.object_iterator, last.m_it.object_iterator);
    1651  break;
    1652  }
    1653 
    1654  case value_t::array:
    1655  {
    1656  m_value.array = create<array_t>(first.m_it.array_iterator, last.m_it.array_iterator);
    1657  break;
    1658  }
    1659 
    1660  default:
    1661  {
    1662  assert(first.m_object != nullptr);
    1663  throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
    1664  }
    1665  }
    1666  }
    1667 
    1669  // other constructors and destructor //
    1671 
    1692  basic_json(const basic_json& other)
    1693  : m_type(other.m_type)
    1694  {
    1695  switch (m_type)
    1696  {
    1697  case value_t::object:
    1698  {
    1699  assert(other.m_value.object != nullptr);
    1700  m_value = *other.m_value.object;
    1701  break;
    1702  }
    1703 
    1704  case value_t::array:
    1705  {
    1706  assert(other.m_value.array != nullptr);
    1707  m_value = *other.m_value.array;
    1708  break;
    1709  }
    1710 
    1711  case value_t::string:
    1712  {
    1713  assert(other.m_value.string != nullptr);
    1714  m_value = *other.m_value.string;
    1715  break;
    1716  }
    1717 
    1718  case value_t::boolean:
    1719  {
    1720  m_value = other.m_value.boolean;
    1721  break;
    1722  }
    1723 
    1724  case value_t::number_integer:
    1725  {
    1726  m_value = other.m_value.number_integer;
    1727  break;
    1728  }
    1729 
    1730  case value_t::number_float:
    1731  {
    1732  m_value = other.m_value.number_float;
    1733  break;
    1734  }
    1735 
    1736  default:
    1737  {
    1738  break;
    1739  }
    1740  }
    1741  }
    1742 
    1761  basic_json(basic_json&& other) noexcept
    1762  : m_type(std::move(other.m_type)),
    1763  m_value(std::move(other.m_value))
    1764  {
    1765  // invalidate payload
    1766  other.m_type = value_t::null;
    1767  other.m_value = {};
    1768  }
    1769 
    1791  reference& operator=(basic_json other) noexcept (
    1792  std::is_nothrow_move_constructible<value_t>::value and
    1793  std::is_nothrow_move_assignable<value_t>::value and
    1794  std::is_nothrow_move_constructible<json_value>::value and
    1795  std::is_nothrow_move_assignable<json_value>::value
    1796  )
    1797  {
    1798  using std::swap;
    1799  swap(m_type, other.m_type);
    1800  swap(m_value, other.m_value);
    1801  return *this;
    1802  }
    1803 
    1818  {
    1819  switch (m_type)
    1820  {
    1821  case value_t::object:
    1822  {
    1823  AllocatorType<object_t> alloc;
    1824  alloc.destroy(m_value.object);
    1825  alloc.deallocate(m_value.object, 1);
    1826  break;
    1827  }
    1828 
    1829  case value_t::array:
    1830  {
    1831  AllocatorType<array_t> alloc;
    1832  alloc.destroy(m_value.array);
    1833  alloc.deallocate(m_value.array, 1);
    1834  break;
    1835  }
    1836 
    1837  case value_t::string:
    1838  {
    1839  AllocatorType<string_t> alloc;
    1840  alloc.destroy(m_value.string);
    1841  alloc.deallocate(m_value.string, 1);
    1842  break;
    1843  }
    1844 
    1845  default:
    1846  {
    1847  // all other types need no specific destructor
    1848  break;
    1849  }
    1850  }
    1851  }
    1852 
    1854 
    1855  public:
    1857  // object inspection //
    1859 
    1862 
    1886  string_t dump(const int indent = -1) const
    1887  {
    1888  std::stringstream ss;
    1889 
    1890  if (indent >= 0)
    1891  {
    1892  dump(ss, true, static_cast<unsigned int>(indent));
    1893  }
    1894  else
    1895  {
    1896  dump(ss, false, 0);
    1897  }
    1898 
    1899  return ss.str();
    1900  }
    1901 
    1917  value_t type() const noexcept
    1918  {
    1919  return m_type;
    1920  }
    1921 
    1938  bool is_primitive() const noexcept
    1939  {
    1940  return is_null() or is_string() or is_boolean() or is_number();
    1941  }
    1942 
    1958  bool is_structured() const noexcept
    1959  {
    1960  return is_array() or is_object();
    1961  }
    1962 
    1977  bool is_null() const noexcept
    1978  {
    1979  return m_type == value_t::null;
    1980  }
    1981 
    1996  bool is_boolean() const noexcept
    1997  {
    1998  return m_type == value_t::boolean;
    1999  }
    2000 
    2020  bool is_number() const noexcept
    2021  {
    2022  return is_number_integer() or is_number_float();
    2023  }
    2024 
    2043  bool is_number_integer() const noexcept
    2044  {
    2045  return m_type == value_t::number_integer;
    2046  }
    2047 
    2066  bool is_number_float() const noexcept
    2067  {
    2068  return m_type == value_t::number_float;
    2069  }
    2070 
    2085  bool is_object() const noexcept
    2086  {
    2087  return m_type == value_t::object;
    2088  }
    2089 
    2104  bool is_array() const noexcept
    2105  {
    2106  return m_type == value_t::array;
    2107  }
    2108 
    2123  bool is_string() const noexcept
    2124  {
    2125  return m_type == value_t::string;
    2126  }
    2127 
    2147  bool is_discarded() const noexcept
    2148  {
    2149  return m_type == value_t::discarded;
    2150  }
    2151 
    2167  operator value_t() const noexcept
    2168  {
    2169  return m_type;
    2170  }
    2171 
    2173 
    2174  private:
    2176  // value access //
    2178 
    2180  template <class T, typename
    2181  std::enable_if<
    2182  std::is_convertible<typename object_t::key_type, typename T::key_type>::value and
    2183  std::is_convertible<basic_json_t, typename T::mapped_type>::value
    2184  , int>::type = 0>
    2185  T get_impl(T*) const
    2186  {
    2187  if (is_object())
    2188  {
    2189  assert(m_value.object != nullptr);
    2190  return T(m_value.object->begin(), m_value.object->end());
    2191  }
    2192  else
    2193  {
    2194  throw std::domain_error("type must be object, but is " + type_name());
    2195  }
    2196  }
    2197 
    2199  object_t get_impl(object_t*) const
    2200  {
    2201  if (is_object())
    2202  {
    2203  assert(m_value.object != nullptr);
    2204  return *(m_value.object);
    2205  }
    2206  else
    2207  {
    2208  throw std::domain_error("type must be object, but is " + type_name());
    2209  }
    2210  }
    2211 
    2213  template <class T, typename
    2214  std::enable_if<
    2215  std::is_convertible<basic_json_t, typename T::value_type>::value and
    2216  not std::is_same<basic_json_t, typename T::value_type>::value and
    2217  not std::is_arithmetic<T>::value and
    2218  not std::is_convertible<std::string, T>::value and
    2219  not has_mapped_type<T>::value
    2220  , int>::type = 0>
    2221  T get_impl(T*) const
    2222  {
    2223  if (is_array())
    2224  {
    2225  T to_vector;
    2226  assert(m_value.array != nullptr);
    2227  std::transform(m_value.array->begin(), m_value.array->end(),
    2228  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2229  {
    2230  return i.get<typename T::value_type>();
    2231  });
    2232  return to_vector;
    2233  }
    2234  else
    2235  {
    2236  throw std::domain_error("type must be array, but is " + type_name());
    2237  }
    2238  }
    2239 
    2241  template <class T, typename
    2242  std::enable_if<
    2243  std::is_convertible<basic_json_t, T>::value and
    2244  not std::is_same<basic_json_t, T>::value
    2245  , int>::type = 0>
    2246  std::vector<T> get_impl(std::vector<T>*) const
    2247  {
    2248  if (is_array())
    2249  {
    2250  std::vector<T> to_vector;
    2251  assert(m_value.array != nullptr);
    2252  to_vector.reserve(m_value.array->size());
    2253  std::transform(m_value.array->begin(), m_value.array->end(),
    2254  std::inserter(to_vector, to_vector.end()), [](basic_json i)
    2255  {
    2256  return i.get<T>();
    2257  });
    2258  return to_vector;
    2259  }
    2260  else
    2261  {
    2262  throw std::domain_error("type must be array, but is " + type_name());
    2263  }
    2264  }
    2265 
    2267  template <class T, typename
    2268  std::enable_if<
    2269  std::is_same<basic_json, typename T::value_type>::value and
    2270  not has_mapped_type<T>::value
    2271  , int>::type = 0>
    2272  T get_impl(T*) const
    2273  {
    2274  if (is_array())
    2275  {
    2276  assert(m_value.array != nullptr);
    2277  return T(m_value.array->begin(), m_value.array->end());
    2278  }
    2279  else
    2280  {
    2281  throw std::domain_error("type must be array, but is " + type_name());
    2282  }
    2283  }
    2284 
    2286  array_t get_impl(array_t*) const
    2287  {
    2288  if (is_array())
    2289  {
    2290  assert(m_value.array != nullptr);
    2291  return *(m_value.array);
    2292  }
    2293  else
    2294  {
    2295  throw std::domain_error("type must be array, but is " + type_name());
    2296  }
    2297  }
    2298 
    2300  template <typename T, typename
    2301  std::enable_if<
    2302  std::is_convertible<string_t, T>::value
    2303  , int>::type = 0>
    2304  T get_impl(T*) const
    2305  {
    2306  if (is_string())
    2307  {
    2308  assert(m_value.string != nullptr);
    2309  return *m_value.string;
    2310  }
    2311  else
    2312  {
    2313  throw std::domain_error("type must be string, but is " + type_name());
    2314  }
    2315  }
    2316 
    2318  template<typename T, typename
    2319  std::enable_if<
    2320  std::is_arithmetic<T>::value
    2321  , int>::type = 0>
    2322  T get_impl(T*) const
    2323  {
    2324  switch (m_type)
    2325  {
    2326  case value_t::number_integer:
    2327  {
    2328  return static_cast<T>(m_value.number_integer);
    2329  }
    2330 
    2331  case value_t::number_float:
    2332  {
    2333  return static_cast<T>(m_value.number_float);
    2334  }
    2335 
    2336  default:
    2337  {
    2338  throw std::domain_error("type must be number, but is " + type_name());
    2339  }
    2340  }
    2341  }
    2342 
    2344  boolean_t get_impl(boolean_t*) const
    2345  {
    2346  if (is_boolean())
    2347  {
    2348  return m_value.boolean;
    2349  }
    2350  else
    2351  {
    2352  throw std::domain_error("type must be boolean, but is " + type_name());
    2353  }
    2354  }
    2355 
    2357  object_t* get_impl_ptr(object_t*) noexcept
    2358  {
    2359  return is_object() ? m_value.object : nullptr;
    2360  }
    2361 
    2363  const object_t* get_impl_ptr(const object_t*) const noexcept
    2364  {
    2365  return is_object() ? m_value.object : nullptr;
    2366  }
    2367 
    2369  array_t* get_impl_ptr(array_t*) noexcept
    2370  {
    2371  return is_array() ? m_value.array : nullptr;
    2372  }
    2373 
    2375  const array_t* get_impl_ptr(const array_t*) const noexcept
    2376  {
    2377  return is_array() ? m_value.array : nullptr;
    2378  }
    2379 
    2381  string_t* get_impl_ptr(string_t*) noexcept
    2382  {
    2383  return is_string() ? m_value.string : nullptr;
    2384  }
    2385 
    2387  const string_t* get_impl_ptr(const string_t*) const noexcept
    2388  {
    2389  return is_string() ? m_value.string : nullptr;
    2390  }
    2391 
    2393  boolean_t* get_impl_ptr(boolean_t*) noexcept
    2394  {
    2395  return is_boolean() ? &m_value.boolean : nullptr;
    2396  }
    2397 
    2399  const boolean_t* get_impl_ptr(const boolean_t*) const noexcept
    2400  {
    2401  return is_boolean() ? &m_value.boolean : nullptr;
    2402  }
    2403 
    2405  number_integer_t* get_impl_ptr(number_integer_t*) noexcept
    2406  {
    2407  return is_number_integer() ? &m_value.number_integer : nullptr;
    2408  }
    2409 
    2411  const number_integer_t* get_impl_ptr(const number_integer_t*) const noexcept
    2412  {
    2413  return is_number_integer() ? &m_value.number_integer : nullptr;
    2414  }
    2415 
    2417  number_float_t* get_impl_ptr(number_float_t*) noexcept
    2418  {
    2419  return is_number_float() ? &m_value.number_float : nullptr;
    2420  }
    2421 
    2423  const number_float_t* get_impl_ptr(const number_float_t*) const noexcept
    2424  {
    2425  return is_number_float() ? &m_value.number_float : nullptr;
    2426  }
    2427 
    2439  template<typename ReferenceType, typename ThisType>
    2440  static ReferenceType get_ref_impl(ThisType& obj)
    2441  {
    2442  // delegate the call to get_ptr<>()
    2443  using PointerType = typename std::add_pointer<ReferenceType>::type;
    2444  auto ptr = obj.template get_ptr<PointerType>();
    2445 
    2446  if (ptr != nullptr)
    2447  {
    2448  return *ptr;
    2449  }
    2450  else
    2451  {
    2452  throw std::domain_error("incompatible ReferenceType for get_ref, actual type is " +
    2453  obj.type_name());
    2454  }
    2455  }
    2456 
    2457  public:
    2458 
    2461 
    2495  template<typename ValueType, typename
    2496  std::enable_if<
    2497  not std::is_pointer<ValueType>::value
    2498  , int>::type = 0>
    2499  ValueType get() const
    2500  {
    2501  return get_impl(static_cast<ValueType*>(nullptr));
    2502  }
    2503 
    2530  template<typename PointerType, typename
    2531  std::enable_if<
    2532  std::is_pointer<PointerType>::value
    2533  , int>::type = 0>
    2534  PointerType get() noexcept
    2535  {
    2536  // delegate the call to get_ptr
    2537  return get_ptr<PointerType>();
    2538  }
    2539 
    2544  template<typename PointerType, typename
    2545  std::enable_if<
    2546  std::is_pointer<PointerType>::value
    2547  , int>::type = 0>
    2548  const PointerType get() const noexcept
    2549  {
    2550  // delegate the call to get_ptr
    2551  return get_ptr<PointerType>();
    2552  }
    2553 
    2579  template<typename PointerType, typename
    2580  std::enable_if<
    2581  std::is_pointer<PointerType>::value
    2582  , int>::type = 0>
    2583  PointerType get_ptr() noexcept
    2584  {
    2585  // delegate the call to get_impl_ptr<>()
    2586  return get_impl_ptr(static_cast<PointerType>(nullptr));
    2587  }
    2588 
    2593  template<typename PointerType, typename
    2594  std::enable_if<
    2595  std::is_pointer<PointerType>::value
    2596  and std::is_const<typename std::remove_pointer<PointerType>::type>::value
    2597  , int>::type = 0>
    2598  const PointerType get_ptr() const noexcept
    2599  {
    2600  // delegate the call to get_impl_ptr<>() const
    2601  return get_impl_ptr(static_cast<const PointerType>(nullptr));
    2602  }
    2603 
    2630  template<typename ReferenceType, typename
    2631  std::enable_if<
    2632  std::is_reference<ReferenceType>::value
    2633  , int>::type = 0>
    2634  ReferenceType get_ref()
    2635  {
    2636  // delegate call to get_ref_impl
    2637  return get_ref_impl<ReferenceType>(*this);
    2638  }
    2639 
    2644  template<typename ReferenceType, typename
    2645  std::enable_if<
    2646  std::is_reference<ReferenceType>::value
    2647  and std::is_const<typename std::remove_reference<ReferenceType>::type>::value
    2648  , int>::type = 0>
    2649  ReferenceType get_ref() const
    2650  {
    2651  // delegate call to get_ref_impl
    2652  return get_ref_impl<ReferenceType>(*this);
    2653  }
    2654 
    2683  template < typename ValueType, typename
    2684  std::enable_if <
    2685  not std::is_pointer<ValueType>::value
    2686  and not std::is_same<ValueType, typename string_t::value_type>::value
    2687 #ifndef _MSC_VER // Fix for issue #167 operator<< abiguity under VS2015
    2688  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2689 #endif
    2690  , int >::type = 0 >
    2691  operator ValueType() const
    2692  {
    2693  // delegate the call to get<>() const
    2694  return get<ValueType>();
    2695  }
    2696 
    2698 
    2699 
    2701  // element access //
    2703 
    2706 
    2730  {
    2731  // at only works for arrays
    2732  if (is_array())
    2733  {
    2734  try
    2735  {
    2736  assert(m_value.array != nullptr);
    2737  return m_value.array->at(idx);
    2738  }
    2739  catch (std::out_of_range&)
    2740  {
    2741  // create better exception explanation
    2742  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2743  }
    2744  }
    2745  else
    2746  {
    2747  throw std::domain_error("cannot use at() with " + type_name());
    2748  }
    2749  }
    2750 
    2774  {
    2775  // at only works for arrays
    2776  if (is_array())
    2777  {
    2778  try
    2779  {
    2780  assert(m_value.array != nullptr);
    2781  return m_value.array->at(idx);
    2782  }
    2783  catch (std::out_of_range&)
    2784  {
    2785  // create better exception explanation
    2786  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2787  }
    2788  }
    2789  else
    2790  {
    2791  throw std::domain_error("cannot use at() with " + type_name());
    2792  }
    2793  }
    2794 
    2821  reference at(const typename object_t::key_type& key)
    2822  {
    2823  // at only works for objects
    2824  if (is_object())
    2825  {
    2826  try
    2827  {
    2828  assert(m_value.object != nullptr);
    2829  return m_value.object->at(key);
    2830  }
    2831  catch (std::out_of_range&)
    2832  {
    2833  // create better exception explanation
    2834  throw std::out_of_range("key '" + key + "' not found");
    2835  }
    2836  }
    2837  else
    2838  {
    2839  throw std::domain_error("cannot use at() with " + type_name());
    2840  }
    2841  }
    2842 
    2869  const_reference at(const typename object_t::key_type& key) const
    2870  {
    2871  // at only works for objects
    2872  if (is_object())
    2873  {
    2874  try
    2875  {
    2876  assert(m_value.object != nullptr);
    2877  return m_value.object->at(key);
    2878  }
    2879  catch (std::out_of_range&)
    2880  {
    2881  // create better exception explanation
    2882  throw std::out_of_range("key '" + key + "' not found");
    2883  }
    2884  }
    2885  else
    2886  {
    2887  throw std::domain_error("cannot use at() with " + type_name());
    2888  }
    2889  }
    2890 
    2917  {
    2918  // implicitly convert null to object
    2919  if (is_null())
    2920  {
    2921  m_type = value_t::array;
    2922  m_value.array = create<array_t>();
    2923  }
    2924 
    2925  // [] only works for arrays
    2926  if (is_array())
    2927  {
    2928  assert(m_value.array != nullptr);
    2929  for (size_t i = m_value.array->size(); i <= idx; ++i)
    2930  {
    2931  m_value.array->push_back(basic_json());
    2932  }
    2933 
    2934  return m_value.array->operator[](idx);
    2935  }
    2936  else
    2937  {
    2938  throw std::domain_error("cannot use operator[] with " + type_name());
    2939  }
    2940  }
    2941 
    2962  {
    2963  // at only works for arrays
    2964  if (is_array())
    2965  {
    2966  assert(m_value.array != nullptr);
    2967  return m_value.array->operator[](idx);
    2968  }
    2969  else
    2970  {
    2971  throw std::domain_error("cannot use operator[] with " + type_name());
    2972  }
    2973  }
    2974 
    3002  reference operator[](const typename object_t::key_type& key)
    3003  {
    3004  // implicitly convert null to object
    3005  if (is_null())
    3006  {
    3007  m_type = value_t::object;
    3008  m_value.object = create<object_t>();
    3009  }
    3010 
    3011  // [] only works for objects
    3012  if (is_object())
    3013  {
    3014  assert(m_value.object != nullptr);
    3015  return m_value.object->operator[](key);
    3016  }
    3017  else
    3018  {
    3019  throw std::domain_error("cannot use operator[] with " + type_name());
    3020  }
    3021  }
    3022 
    3050  const_reference operator[](const typename object_t::key_type& key) const
    3051  {
    3052  // [] only works for objects
    3053  if (is_object())
    3054  {
    3055  assert(m_value.object != nullptr);
    3056  assert(m_value.object->find(key) != m_value.object->end());
    3057  return m_value.object->find(key)->second;
    3058  }
    3059  else
    3060  {
    3061  throw std::domain_error("cannot use operator[] with " + type_name());
    3062  }
    3063  }
    3064 
    3092  template<typename T, std::size_t n>
    3093  reference operator[](T * (&key)[n])
    3094  {
    3095  return operator[](static_cast<const T>(key));
    3096  }
    3097 
    3127  template<typename T, std::size_t n>
    3128  const_reference operator[](T * (&key)[n]) const
    3129  {
    3130  return operator[](static_cast<const T>(key));
    3131  }
    3132 
    3160  template<typename T>
    3162  {
    3163  // implicitly convert null to object
    3164  if (is_null())
    3165  {
    3166  m_type = value_t::object;
    3167  m_value = value_t::object;
    3168  }
    3169 
    3170  // at only works for objects
    3171  if (is_object())
    3172  {
    3173  assert(m_value.object != nullptr);
    3174  return m_value.object->operator[](key);
    3175  }
    3176  else
    3177  {
    3178  throw std::domain_error("cannot use operator[] with " + type_name());
    3179  }
    3180  }
    3181 
    3209  template<typename T>
    3211  {
    3212  // at only works for objects
    3213  if (is_object())
    3214  {
    3215  assert(m_value.object != nullptr);
    3216  assert(m_value.object->find(key) != m_value.object->end());
    3217  return m_value.object->find(key)->second;
    3218  }
    3219  else
    3220  {
    3221  throw std::domain_error("cannot use operator[] with " + type_name());
    3222  }
    3223  }
    3224 
    3273  template <class ValueType, typename
    3274  std::enable_if<
    3275  std::is_convertible<basic_json_t, ValueType>::value
    3276  , int>::type = 0>
    3277  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3278  {
    3279  // at only works for objects
    3280  if (is_object())
    3281  {
    3282  // if key is found, return value and given default value otherwise
    3283  const auto it = find(key);
    3284  if (it != end())
    3285  {
    3286  return *it;
    3287  }
    3288  else
    3289  {
    3290  return default_value;
    3291  }
    3292  }
    3293  else
    3294  {
    3295  throw std::domain_error("cannot use value() with " + type_name());
    3296  }
    3297  }
    3298 
    3303  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3304  {
    3305  return value(key, string_t(default_value));
    3306  }
    3307 
    3329  {
    3330  return *begin();
    3331  }
    3332 
    3337  {
    3338  return *cbegin();
    3339  }
    3340 
    3363  {
    3364  auto tmp = end();
    3365  --tmp;
    3366  return *tmp;
    3367  }
    3368 
    3373  {
    3374  auto tmp = cend();
    3375  --tmp;
    3376  return *tmp;
    3377  }
    3378 
    3423  template <class InteratorType, typename
    3424  std::enable_if<
    3425  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3426  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3427  , int>::type
    3428  = 0>
    3429  InteratorType erase(InteratorType pos)
    3430  {
    3431  // make sure iterator fits the current value
    3432  if (this != pos.m_object)
    3433  {
    3434  throw std::domain_error("iterator does not fit current value");
    3435  }
    3436 
    3437  InteratorType result = end();
    3438 
    3439  switch (m_type)
    3440  {
    3441  case value_t::boolean:
    3442  case value_t::number_float:
    3443  case value_t::number_integer:
    3444  case value_t::string:
    3445  {
    3446  if (not pos.m_it.primitive_iterator.is_begin())
    3447  {
    3448  throw std::out_of_range("iterator out of range");
    3449  }
    3450 
    3451  if (is_string())
    3452  {
    3453  delete m_value.string;
    3454  m_value.string = nullptr;
    3455  }
    3456 
    3457  m_type = value_t::null;
    3458  break;
    3459  }
    3460 
    3461  case value_t::object:
    3462  {
    3463  assert(m_value.object != nullptr);
    3464  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3465  break;
    3466  }
    3467 
    3468  case value_t::array:
    3469  {
    3470  assert(m_value.array != nullptr);
    3471  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3472  break;
    3473  }
    3474 
    3475  default:
    3476  {
    3477  throw std::domain_error("cannot use erase() with " + type_name());
    3478  }
    3479  }
    3480 
    3481  return result;
    3482  }
    3483 
    3528  template <class InteratorType, typename
    3529  std::enable_if<
    3530  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3531  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3532  , int>::type
    3533  = 0>
    3534  InteratorType erase(InteratorType first, InteratorType last)
    3535  {
    3536  // make sure iterator fits the current value
    3537  if (this != first.m_object or this != last.m_object)
    3538  {
    3539  throw std::domain_error("iterators do not fit current value");
    3540  }
    3541 
    3542  InteratorType result = end();
    3543 
    3544  switch (m_type)
    3545  {
    3546  case value_t::boolean:
    3547  case value_t::number_float:
    3548  case value_t::number_integer:
    3549  case value_t::string:
    3550  {
    3551  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3552  {
    3553  throw std::out_of_range("iterators out of range");
    3554  }
    3555 
    3556  if (is_string())
    3557  {
    3558  delete m_value.string;
    3559  m_value.string = nullptr;
    3560  }
    3561 
    3562  m_type = value_t::null;
    3563  break;
    3564  }
    3565 
    3566  case value_t::object:
    3567  {
    3568  assert(m_value.object != nullptr);
    3569  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3570  last.m_it.object_iterator);
    3571  break;
    3572  }
    3573 
    3574  case value_t::array:
    3575  {
    3576  assert(m_value.array != nullptr);
    3577  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3578  last.m_it.array_iterator);
    3579  break;
    3580  }
    3581 
    3582  default:
    3583  {
    3584  throw std::domain_error("cannot use erase() with " + type_name());
    3585  }
    3586  }
    3587 
    3588  return result;
    3589  }
    3590 
    3617  size_type erase(const typename object_t::key_type& key)
    3618  {
    3619  // this erase only works for objects
    3620  if (is_object())
    3621  {
    3622  assert(m_value.object != nullptr);
    3623  return m_value.object->erase(key);
    3624  }
    3625  else
    3626  {
    3627  throw std::domain_error("cannot use erase() with " + type_name());
    3628  }
    3629  }
    3630 
    3655  void erase(const size_type idx)
    3656  {
    3657  // this erase only works for arrays
    3658  if (is_array())
    3659  {
    3660  if (idx >= size())
    3661  {
    3662  throw std::out_of_range("index out of range");
    3663  }
    3664 
    3665  assert(m_value.array != nullptr);
    3666  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3667  }
    3668  else
    3669  {
    3670  throw std::domain_error("cannot use erase() with " + type_name());
    3671  }
    3672  }
    3673 
    3691  iterator find(typename object_t::key_type key)
    3692  {
    3693  auto result = end();
    3694 
    3695  if (is_object())
    3696  {
    3697  assert(m_value.object != nullptr);
    3698  result.m_it.object_iterator = m_value.object->find(key);
    3699  }
    3700 
    3701  return result;
    3702  }
    3703 
    3708  const_iterator find(typename object_t::key_type key) const
    3709  {
    3710  auto result = cend();
    3711 
    3712  if (is_object())
    3713  {
    3714  assert(m_value.object != nullptr);
    3715  result.m_it.object_iterator = m_value.object->find(key);
    3716  }
    3717 
    3718  return result;
    3719  }
    3720 
    3739  size_type count(typename object_t::key_type key) const
    3740  {
    3741  // return 0 for all nonobject types
    3742  assert(not is_object() or m_value.object != nullptr);
    3743  return is_object() ? m_value.object->count(key) : 0;
    3744  }
    3745 
    3747 
    3748 
    3750  // iterators //
    3752 
    3755 
    3775  {
    3776  iterator result(this);
    3777  result.set_begin();
    3778  return result;
    3779  }
    3780 
    3785  {
    3786  return cbegin();
    3787  }
    3788 
    3809  {
    3810  const_iterator result(this);
    3811  result.set_begin();
    3812  return result;
    3813  }
    3814 
    3834  {
    3835  iterator result(this);
    3836  result.set_end();
    3837  return result;
    3838  }
    3839 
    3844  {
    3845  return cend();
    3846  }
    3847 
    3868  {
    3869  const_iterator result(this);
    3870  result.set_end();
    3871  return result;
    3872  }
    3873 
    3892  {
    3893  return reverse_iterator(end());
    3894  }
    3895 
    3900  {
    3901  return crbegin();
    3902  }
    3903 
    3923  {
    3924  return reverse_iterator(begin());
    3925  }
    3926 
    3931  {
    3932  return crend();
    3933  }
    3934 
    3954  {
    3955  return const_reverse_iterator(cend());
    3956  }
    3957 
    3977  {
    3978  return const_reverse_iterator(cbegin());
    3979  }
    3980 
    3981  private:
    3982  // forward declaration
    3983  template<typename IteratorType> class iteration_proxy;
    3984 
    3985  public:
    3997  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    3998  {
    3999  return iteration_proxy<iterator>(cont);
    4000  }
    4001 
    4005  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    4006  {
    4007  return iteration_proxy<const_iterator>(cont);
    4008  }
    4009 
    4011 
    4012 
    4014  // capacity //
    4016 
    4019 
    4049  bool empty() const noexcept
    4050  {
    4051  switch (m_type)
    4052  {
    4053  case value_t::null:
    4054  {
    4055  // null values are empty
    4056  return true;
    4057  }
    4058 
    4059  case value_t::array:
    4060  {
    4061  assert(m_value.array != nullptr);
    4062  return m_value.array->empty();
    4063  }
    4064 
    4065  case value_t::object:
    4066  {
    4067  assert(m_value.object != nullptr);
    4068  return m_value.object->empty();
    4069  }
    4070 
    4071  default:
    4072  {
    4073  // all other types are nonempty
    4074  return false;
    4075  }
    4076  }
    4077  }
    4078 
    4107  size_type size() const noexcept
    4108  {
    4109  switch (m_type)
    4110  {
    4111  case value_t::null:
    4112  {
    4113  // null values are empty
    4114  return 0;
    4115  }
    4116 
    4117  case value_t::array:
    4118  {
    4119  assert(m_value.array != nullptr);
    4120  return m_value.array->size();
    4121  }
    4122 
    4123  case value_t::object:
    4124  {
    4125  assert(m_value.object != nullptr);
    4126  return m_value.object->size();
    4127  }
    4128 
    4129  default:
    4130  {
    4131  // all other types have size 1
    4132  return 1;
    4133  }
    4134  }
    4135  }
    4136 
    4169  size_type max_size() const noexcept
    4170  {
    4171  switch (m_type)
    4172  {
    4173  case value_t::array:
    4174  {
    4175  assert(m_value.array != nullptr);
    4176  return m_value.array->max_size();
    4177  }
    4178 
    4179  case value_t::object:
    4180  {
    4181  assert(m_value.object != nullptr);
    4182  return m_value.object->max_size();
    4183  }
    4184 
    4185  default:
    4186  {
    4187  // all other types have max_size() == size()
    4188  return size();
    4189  }
    4190  }
    4191  }
    4192 
    4194 
    4195 
    4197  // modifiers //
    4199 
    4202 
    4228  void clear() noexcept
    4229  {
    4230  switch (m_type)
    4231  {
    4232  case value_t::number_integer:
    4233  {
    4234  m_value.number_integer = 0;
    4235  break;
    4236  }
    4237 
    4238  case value_t::number_float:
    4239  {
    4240  m_value.number_float = 0.0;
    4241  break;
    4242  }
    4243 
    4244  case value_t::boolean:
    4245  {
    4246  m_value.boolean = false;
    4247  break;
    4248  }
    4249 
    4250  case value_t::string:
    4251  {
    4252  assert(m_value.string != nullptr);
    4253  m_value.string->clear();
    4254  break;
    4255  }
    4256 
    4257  case value_t::array:
    4258  {
    4259  assert(m_value.array != nullptr);
    4260  m_value.array->clear();
    4261  break;
    4262  }
    4263 
    4264  case value_t::object:
    4265  {
    4266  assert(m_value.object != nullptr);
    4267  m_value.object->clear();
    4268  break;
    4269  }
    4270 
    4271  default:
    4272  {
    4273  break;
    4274  }
    4275  }
    4276  }
    4277 
    4298  void push_back(basic_json&& val)
    4299  {
    4300  // push_back only works for null objects or arrays
    4301  if (not(is_null() or is_array()))
    4302  {
    4303  throw std::domain_error("cannot use push_back() with " + type_name());
    4304  }
    4305 
    4306  // transform null object into an array
    4307  if (is_null())
    4308  {
    4309  m_type = value_t::array;
    4310  m_value = value_t::array;
    4311  }
    4312 
    4313  // add element to array (move semantics)
    4314  assert(m_value.array != nullptr);
    4315  m_value.array->push_back(std::move(val));
    4316  // invalidate object
    4317  val.m_type = value_t::null;
    4318  }
    4319 
    4324  reference operator+=(basic_json&& val)
    4325  {
    4326  push_back(std::move(val));
    4327  return *this;
    4328  }
    4329 
    4334  void push_back(const basic_json& val)
    4335  {
    4336  // push_back only works for null objects or arrays
    4337  if (not(is_null() or is_array()))
    4338  {
    4339  throw std::domain_error("cannot use push_back() with " + type_name());
    4340  }
    4341 
    4342  // transform null object into an array
    4343  if (is_null())
    4344  {
    4345  m_type = value_t::array;
    4346  m_value = value_t::array;
    4347  }
    4348 
    4349  // add element to array
    4350  assert(m_value.array != nullptr);
    4351  m_value.array->push_back(val);
    4352  }
    4353 
    4358  reference operator+=(const basic_json& val)
    4359  {
    4360  push_back(val);
    4361  return *this;
    4362  }
    4363 
    4384  void push_back(const typename object_t::value_type& val)
    4385  {
    4386  // push_back only works for null objects or objects
    4387  if (not(is_null() or is_object()))
    4388  {
    4389  throw std::domain_error("cannot use push_back() with " + type_name());
    4390  }
    4391 
    4392  // transform null object into an object
    4393  if (is_null())
    4394  {
    4395  m_type = value_t::object;
    4396  m_value = value_t::object;
    4397  }
    4398 
    4399  // add element to array
    4400  assert(m_value.object != nullptr);
    4401  m_value.object->insert(val);
    4402  }
    4403 
    4408  reference operator+=(const typename object_t::value_type& val)
    4409  {
    4410  push_back(val);
    4411  return operator[](val.first);
    4412  }
    4413 
    4436  iterator insert(const_iterator pos, const basic_json& val)
    4437  {
    4438  // insert only works for arrays
    4439  if (is_array())
    4440  {
    4441  // check if iterator pos fits to this JSON value
    4442  if (pos.m_object != this)
    4443  {
    4444  throw std::domain_error("iterator does not fit current value");
    4445  }
    4446 
    4447  // insert to array and return iterator
    4448  iterator result(this);
    4449  assert(m_value.array != nullptr);
    4450  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4451  return result;
    4452  }
    4453  else
    4454  {
    4455  throw std::domain_error("cannot use insert() with " + type_name());
    4456  }
    4457  }
    4458 
    4463  iterator insert(const_iterator pos, basic_json&& val)
    4464  {
    4465  return insert(pos, val);
    4466  }
    4467 
    4492  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4493  {
    4494  // insert only works for arrays
    4495  if (is_array())
    4496  {
    4497  // check if iterator pos fits to this JSON value
    4498  if (pos.m_object != this)
    4499  {
    4500  throw std::domain_error("iterator does not fit current value");
    4501  }
    4502 
    4503  // insert to array and return iterator
    4504  iterator result(this);
    4505  assert(m_value.array != nullptr);
    4506  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4507  return result;
    4508  }
    4509  else
    4510  {
    4511  throw std::domain_error("cannot use insert() with " + type_name());
    4512  }
    4513  }
    4514 
    4546  {
    4547  // insert only works for arrays
    4548  if (not is_array())
    4549  {
    4550  throw std::domain_error("cannot use insert() with " + type_name());
    4551  }
    4552 
    4553  // check if iterator pos fits to this JSON value
    4554  if (pos.m_object != this)
    4555  {
    4556  throw std::domain_error("iterator does not fit current value");
    4557  }
    4558 
    4559  if (first.m_object != last.m_object)
    4560  {
    4561  throw std::domain_error("iterators do not fit");
    4562  }
    4563 
    4564  if (first.m_object == this or last.m_object == this)
    4565  {
    4566  throw std::domain_error("passed iterators may not belong to container");
    4567  }
    4568 
    4569  // insert to array and return iterator
    4570  iterator result(this);
    4571  assert(m_value.array != nullptr);
    4572  result.m_it.array_iterator = m_value.array->insert(
    4573  pos.m_it.array_iterator,
    4574  first.m_it.array_iterator,
    4575  last.m_it.array_iterator);
    4576  return result;
    4577  }
    4578 
    4603  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4604  {
    4605  // insert only works for arrays
    4606  if (not is_array())
    4607  {
    4608  throw std::domain_error("cannot use insert() with " + type_name());
    4609  }
    4610 
    4611  // check if iterator pos fits to this JSON value
    4612  if (pos.m_object != this)
    4613  {
    4614  throw std::domain_error("iterator does not fit current value");
    4615  }
    4616 
    4617  // insert to array and return iterator
    4618  iterator result(this);
    4619  assert(m_value.array != nullptr);
    4620  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4621  return result;
    4622  }
    4623 
    4641  void swap(reference other) noexcept (
    4642  std::is_nothrow_move_constructible<value_t>::value and
    4643  std::is_nothrow_move_assignable<value_t>::value and
    4644  std::is_nothrow_move_constructible<json_value>::value and
    4645  std::is_nothrow_move_assignable<json_value>::value
    4646  )
    4647  {
    4648  std::swap(m_type, other.m_type);
    4649  std::swap(m_value, other.m_value);
    4650  }
    4651 
    4672  void swap(array_t& other)
    4673  {
    4674  // swap only works for arrays
    4675  if (is_array())
    4676  {
    4677  assert(m_value.array != nullptr);
    4678  std::swap(*(m_value.array), other);
    4679  }
    4680  else
    4681  {
    4682  throw std::domain_error("cannot use swap() with " + type_name());
    4683  }
    4684  }
    4685 
    4706  void swap(object_t& other)
    4707  {
    4708  // swap only works for objects
    4709  if (is_object())
    4710  {
    4711  assert(m_value.object != nullptr);
    4712  std::swap(*(m_value.object), other);
    4713  }
    4714  else
    4715  {
    4716  throw std::domain_error("cannot use swap() with " + type_name());
    4717  }
    4718  }
    4719 
    4740  void swap(string_t& other)
    4741  {
    4742  // swap only works for strings
    4743  if (is_string())
    4744  {
    4745  assert(m_value.string != nullptr);
    4746  std::swap(*(m_value.string), other);
    4747  }
    4748  else
    4749  {
    4750  throw std::domain_error("cannot use swap() with " + type_name());
    4751  }
    4752  }
    4753 
    4755 
    4756 
    4758  // lexicographical comparison operators //
    4760 
    4763 
    4764  private:
    4774  friend bool operator<(const value_t lhs, const value_t rhs)
    4775  {
    4776  static constexpr std::array<uint8_t, 7> order = {{
    4777  0, // null
    4778  3, // object
    4779  4, // array
    4780  5, // string
    4781  1, // boolean
    4782  2, // integer
    4783  2 // float
    4784  }
    4785  };
    4786 
    4787  // discarded values are not comparable
    4788  if (lhs == value_t::discarded or rhs == value_t::discarded)
    4789  {
    4790  return false;
    4791  }
    4792 
    4793  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    4794  }
    4795 
    4796  public:
    4820  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    4821  {
    4822  const auto lhs_type = lhs.type();
    4823  const auto rhs_type = rhs.type();
    4824 
    4825  if (lhs_type == rhs_type)
    4826  {
    4827  switch (lhs_type)
    4828  {
    4829  case value_t::array:
    4830  {
    4831  assert(lhs.m_value.array != nullptr);
    4832  assert(rhs.m_value.array != nullptr);
    4833  return *lhs.m_value.array == *rhs.m_value.array;
    4834  }
    4835  case value_t::object:
    4836  {
    4837  assert(lhs.m_value.object != nullptr);
    4838  assert(rhs.m_value.object != nullptr);
    4839  return *lhs.m_value.object == *rhs.m_value.object;
    4840  }
    4841  case value_t::null:
    4842  {
    4843  return true;
    4844  }
    4845  case value_t::string:
    4846  {
    4847  assert(lhs.m_value.string != nullptr);
    4848  assert(rhs.m_value.string != nullptr);
    4849  return *lhs.m_value.string == *rhs.m_value.string;
    4850  }
    4851  case value_t::boolean:
    4852  {
    4853  return lhs.m_value.boolean == rhs.m_value.boolean;
    4854  }
    4855  case value_t::number_integer:
    4856  {
    4857  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    4858  }
    4859  case value_t::number_float:
    4860  {
    4861  return lhs.m_value.number_float == rhs.m_value.number_float;
    4862  }
    4863  default:
    4864  {
    4865  return false;
    4866  }
    4867  }
    4868  }
    4869  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    4870  {
    4871  return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
    4872  }
    4873  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    4874  {
    4875  return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
    4876  }
    4877  return false;
    4878  }
    4879 
    4898  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    4899  {
    4900  return v.is_null();
    4901  }
    4902 
    4907  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    4908  {
    4909  return v.is_null();
    4910  }
    4911 
    4928  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    4929  {
    4930  return not (lhs == rhs);
    4931  }
    4932 
    4951  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    4952  {
    4953  return not v.is_null();
    4954  }
    4955 
    4960  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    4961  {
    4962  return not v.is_null();
    4963  }
    4964 
    4989  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    4990  {
    4991  const auto lhs_type = lhs.type();
    4992  const auto rhs_type = rhs.type();
    4993 
    4994  if (lhs_type == rhs_type)
    4995  {
    4996  switch (lhs_type)
    4997  {
    4998  case value_t::array:
    4999  {
    5000  assert(lhs.m_value.array != nullptr);
    5001  assert(rhs.m_value.array != nullptr);
    5002  return *lhs.m_value.array < *rhs.m_value.array;
    5003  }
    5004  case value_t::object:
    5005  {
    5006  assert(lhs.m_value.object != nullptr);
    5007  assert(rhs.m_value.object != nullptr);
    5008  return *lhs.m_value.object < *rhs.m_value.object;
    5009  }
    5010  case value_t::null:
    5011  {
    5012  return false;
    5013  }
    5014  case value_t::string:
    5015  {
    5016  assert(lhs.m_value.string != nullptr);
    5017  assert(rhs.m_value.string != nullptr);
    5018  return *lhs.m_value.string < *rhs.m_value.string;
    5019  }
    5020  case value_t::boolean:
    5021  {
    5022  return lhs.m_value.boolean < rhs.m_value.boolean;
    5023  }
    5024  case value_t::number_integer:
    5025  {
    5026  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    5027  }
    5028  case value_t::number_float:
    5029  {
    5030  return lhs.m_value.number_float < rhs.m_value.number_float;
    5031  }
    5032  default:
    5033  {
    5034  return false;
    5035  }
    5036  }
    5037  }
    5038  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    5039  {
    5040  return static_cast<number_float_t>(lhs.m_value.number_integer) <
    5041  rhs.m_value.number_float;
    5042  }
    5043  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    5044  {
    5045  return lhs.m_value.number_float <
    5046  static_cast<number_float_t>(rhs.m_value.number_integer);
    5047  }
    5048 
    5049  // We only reach this line if we cannot compare values. In that case,
    5050  // we compare types. Note we have to call the operator explicitly,
    5051  // because MSVC has problems otherwise.
    5052  return operator<(lhs_type, rhs_type);
    5053  }
    5054 
    5072  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5073  {
    5074  return not (rhs < lhs);
    5075  }
    5076 
    5094  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5095  {
    5096  return not (lhs <= rhs);
    5097  }
    5098 
    5116  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5117  {
    5118  return not (lhs < rhs);
    5119  }
    5120 
    5122 
    5123 
    5125  // serialization //
    5127 
    5130 
    5153  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5154  {
    5155  // read width member and use it as indentation parameter if nonzero
    5156  const bool pretty_print = (o.width() > 0);
    5157  const auto indentation = (pretty_print ? o.width() : 0);
    5158 
    5159  // reset width to 0 for subsequent calls to this stream
    5160  o.width(0);
    5161 
    5162  // do the actual serialization
    5163  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5164  return o;
    5165  }
    5166 
    5171  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5172  {
    5173  return o << j;
    5174  }
    5175 
    5177 
    5178 
    5180  // deserialization //
    5182 
    5185 
    5210  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5211  {
    5212  return parser(s, cb).parse();
    5213  }
    5214 
    5239  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5240  {
    5241  return parser(i, cb).parse();
    5242  }
    5243 
    5247  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5248  {
    5249  return parser(i, cb).parse();
    5250  }
    5251 
    5275  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5276  {
    5277  j = parser(i).parse();
    5278  return i;
    5279  }
    5280 
    5285  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5286  {
    5287  j = parser(i).parse();
    5288  return i;
    5289  }
    5290 
    5292 
    5293 
    5294  private:
    5296  // convenience functions //
    5298 
    5300  string_t type_name() const
    5301  {
    5302  switch (m_type)
    5303  {
    5304  case value_t::null:
    5305  return "null";
    5306  case value_t::object:
    5307  return "object";
    5308  case value_t::array:
    5309  return "array";
    5310  case value_t::string:
    5311  return "string";
    5312  case value_t::boolean:
    5313  return "boolean";
    5314  case value_t::discarded:
    5315  return "discarded";
    5316  default:
    5317  return "number";
    5318  }
    5319  }
    5320 
    5329  static std::size_t extra_space(const string_t& s) noexcept
    5330  {
    5331  std::size_t result = 0;
    5332 
    5333  for (const auto& c : s)
    5334  {
    5335  switch (c)
    5336  {
    5337  case '"':
    5338  case '\\':
    5339  case '\b':
    5340  case '\f':
    5341  case '\n':
    5342  case '\r':
    5343  case '\t':
    5344  {
    5345  // from c (1 byte) to \x (2 bytes)
    5346  result += 1;
    5347  break;
    5348  }
    5349 
    5350  default:
    5351  {
    5352  if (c >= 0x00 and c <= 0x1f)
    5353  {
    5354  // from c (1 byte) to \uxxxx (6 bytes)
    5355  result += 5;
    5356  }
    5357  break;
    5358  }
    5359  }
    5360  }
    5361 
    5362  return result;
    5363  }
    5364 
    5378  static string_t escape_string(const string_t& s) noexcept
    5379  {
    5380  const auto space = extra_space(s);
    5381  if (space == 0)
    5382  {
    5383  return s;
    5384  }
    5385 
    5386  // create a result string of necessary size
    5387  string_t result(s.size() + space, '\\');
    5388  std::size_t pos = 0;
    5389 
    5390  for (const auto& c : s)
    5391  {
    5392  switch (c)
    5393  {
    5394  // quotation mark (0x22)
    5395  case '"':
    5396  {
    5397  result[pos + 1] = '"';
    5398  pos += 2;
    5399  break;
    5400  }
    5401 
    5402  // reverse solidus (0x5c)
    5403  case '\\':
    5404  {
    5405  // nothing to change
    5406  pos += 2;
    5407  break;
    5408  }
    5409 
    5410  // backspace (0x08)
    5411  case '\b':
    5412  {
    5413  result[pos + 1] = 'b';
    5414  pos += 2;
    5415  break;
    5416  }
    5417 
    5418  // formfeed (0x0c)
    5419  case '\f':
    5420  {
    5421  result[pos + 1] = 'f';
    5422  pos += 2;
    5423  break;
    5424  }
    5425 
    5426  // newline (0x0a)
    5427  case '\n':
    5428  {
    5429  result[pos + 1] = 'n';
    5430  pos += 2;
    5431  break;
    5432  }
    5433 
    5434  // carriage return (0x0d)
    5435  case '\r':
    5436  {
    5437  result[pos + 1] = 'r';
    5438  pos += 2;
    5439  break;
    5440  }
    5441 
    5442  // horizontal tab (0x09)
    5443  case '\t':
    5444  {
    5445  result[pos + 1] = 't';
    5446  pos += 2;
    5447  break;
    5448  }
    5449 
    5450  default:
    5451  {
    5452  if (c >= 0x00 and c <= 0x1f)
    5453  {
    5454  // convert a number 0..15 to its hex representation (0..f)
    5455  auto hexify = [](const char v) -> char
    5456  {
    5457  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5458  };
    5459 
    5460  // print character c as \uxxxx
    5461  for (const char m :
    5462  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5463  })
    5464  {
    5465  result[++pos] = m;
    5466  }
    5467 
    5468  ++pos;
    5469  }
    5470  else
    5471  {
    5472  // all other characters are added as-is
    5473  result[pos++] = c;
    5474  }
    5475  break;
    5476  }
    5477  }
    5478  }
    5479 
    5480  return result;
    5481  }
    5482 
    5500  void dump(std::ostream& o,
    5501  const bool pretty_print,
    5502  const unsigned int indent_step,
    5503  const unsigned int current_indent = 0) const
    5504  {
    5505  // variable to hold indentation for recursive calls
    5506  unsigned int new_indent = current_indent;
    5507 
    5508  switch (m_type)
    5509  {
    5510  case value_t::object:
    5511  {
    5512  assert(m_value.object != nullptr);
    5513 
    5514  if (m_value.object->empty())
    5515  {
    5516  o << "{}";
    5517  return;
    5518  }
    5519 
    5520  o << "{";
    5521 
    5522  // increase indentation
    5523  if (pretty_print)
    5524  {
    5525  new_indent += indent_step;
    5526  o << "\n";
    5527  }
    5528 
    5529  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5530  {
    5531  if (i != m_value.object->cbegin())
    5532  {
    5533  o << (pretty_print ? ",\n" : ",");
    5534  }
    5535  o << string_t(new_indent, ' ') << "\""
    5536  << escape_string(i->first) << "\":"
    5537  << (pretty_print ? " " : "");
    5538  i->second.dump(o, pretty_print, indent_step, new_indent);
    5539  }
    5540 
    5541  // decrease indentation
    5542  if (pretty_print)
    5543  {
    5544  new_indent -= indent_step;
    5545  o << "\n";
    5546  }
    5547 
    5548  o << string_t(new_indent, ' ') + "}";
    5549  return;
    5550  }
    5551 
    5552  case value_t::array:
    5553  {
    5554  assert(m_value.array != nullptr);
    5555 
    5556  if (m_value.array->empty())
    5557  {
    5558  o << "[]";
    5559  return;
    5560  }
    5561 
    5562  o << "[";
    5563 
    5564  // increase indentation
    5565  if (pretty_print)
    5566  {
    5567  new_indent += indent_step;
    5568  o << "\n";
    5569  }
    5570 
    5571  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5572  {
    5573  if (i != m_value.array->cbegin())
    5574  {
    5575  o << (pretty_print ? ",\n" : ",");
    5576  }
    5577  o << string_t(new_indent, ' ');
    5578  i->dump(o, pretty_print, indent_step, new_indent);
    5579  }
    5580 
    5581  // decrease indentation
    5582  if (pretty_print)
    5583  {
    5584  new_indent -= indent_step;
    5585  o << "\n";
    5586  }
    5587 
    5588  o << string_t(new_indent, ' ') << "]";
    5589  return;
    5590  }
    5591 
    5592  case value_t::string:
    5593  {
    5594  assert(m_value.string != nullptr);
    5595  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5596  return;
    5597  }
    5598 
    5599  case value_t::boolean:
    5600  {
    5601  o << (m_value.boolean ? "true" : "false");
    5602  return;
    5603  }
    5604 
    5605  case value_t::number_integer:
    5606  {
    5607  o << m_value.number_integer;
    5608  return;
    5609  }
    5610 
    5611  case value_t::number_float:
    5612  {
    5613  // If the number is an integer then output as a fixed with with
    5614  // precision 1 to output "0.0", "1.0" etc as expected for some
    5615  // round trip tests otherwise 15 digits of precision allows
    5616  // round-trip IEEE 754 string->double->string; to be safe, we
    5617  // read this value from
    5618  // std::numeric_limits<number_float_t>::digits10
    5619  if (std::fmod(m_value.number_float, 1) == 0)
    5620  {
    5621  o << std::fixed << std::setprecision(1);
    5622  }
    5623  else
    5624  {
    5625  // std::defaultfloat not supported in gcc version < 5
    5626  o.unsetf(std::ios_base::floatfield);
    5627  o << std::setprecision(std::numeric_limits<double>::digits10);
    5628  }
    5629  o << m_value.number_float;
    5630  return;
    5631  }
    5632 
    5633  case value_t::discarded:
    5634  {
    5635  o << "<discarded>";
    5636  return;
    5637  }
    5638 
    5639  case value_t::null:
    5640  {
    5641  o << "null";
    5642  return;
    5643  }
    5644  }
    5645  }
    5646 
    5647  private:
    5649  // member variables //
    5651 
    5653  value_t m_type = value_t::null;
    5654 
    5656  json_value m_value = {};
    5657 
    5658 
    5659  private:
    5661  // iterators //
    5663 
    5673  class primitive_iterator_t
    5674  {
    5675  public:
    5677  void set_begin()
    5678  {
    5679  m_it = begin_value;
    5680  }
    5681 
    5683  void set_end()
    5684  {
    5685  m_it = end_value;
    5686  }
    5687 
    5689  bool is_begin() const
    5690  {
    5691  return (m_it == begin_value);
    5692  }
    5693 
    5695  bool is_end() const
    5696  {
    5697  return (m_it == end_value);
    5698  }
    5699 
    5701  operator difference_type& ()
    5702  {
    5703  return m_it;
    5704  }
    5705 
    5707  operator difference_type () const
    5708  {
    5709  return m_it;
    5710  }
    5711 
    5712  private:
    5713  static constexpr difference_type begin_value = 0;
    5714  static constexpr difference_type end_value = begin_value + 1;
    5715 
    5717  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    5718  };
    5719 
    5727  struct internal_iterator
    5728  {
    5730  typename object_t::iterator object_iterator;
    5732  typename array_t::iterator array_iterator;
    5734  primitive_iterator_t primitive_iterator;
    5735 
    5737  internal_iterator()
    5738  : object_iterator(), array_iterator(), primitive_iterator()
    5739  {}
    5740  };
    5741 
    5743  template<typename IteratorType>
    5744  class iteration_proxy
    5745  {
    5746  private:
    5748  class iteration_proxy_internal
    5749  {
    5750  private:
    5752  IteratorType anchor;
    5754  size_t array_index = 0;
    5755 
    5756  public:
    5757  iteration_proxy_internal(IteratorType it)
    5758  : anchor(it)
    5759  {}
    5760 
    5762  iteration_proxy_internal& operator*()
    5763  {
    5764  return *this;
    5765  }
    5766 
    5768  iteration_proxy_internal& operator++()
    5769  {
    5770  ++anchor;
    5771  ++array_index;
    5772 
    5773  return *this;
    5774  }
    5775 
    5777  bool operator!= (const iteration_proxy_internal& o) const
    5778  {
    5779  return anchor != o.anchor;
    5780  }
    5781 
    5783  typename basic_json::string_t key() const
    5784  {
    5785  assert(anchor.m_object != nullptr);
    5786 
    5787  switch (anchor.m_object->type())
    5788  {
    5789  // use integer array index as key
    5790  case value_t::array:
    5791  {
    5792  return std::to_string(array_index);
    5793  }
    5794 
    5795  // use key from the object
    5796  case value_t::object:
    5797  {
    5798  return anchor.key();
    5799  }
    5800 
    5801  // use an empty key for all primitive types
    5802  default:
    5803  {
    5804  return "";
    5805  }
    5806  }
    5807  }
    5808 
    5810  typename IteratorType::reference value() const
    5811  {
    5812  return anchor.value();
    5813  }
    5814  };
    5815 
    5817  typename IteratorType::reference container;
    5818 
    5819  public:
    5821  iteration_proxy(typename IteratorType::reference cont)
    5822  : container(cont)
    5823  {}
    5824 
    5826  iteration_proxy_internal begin()
    5827  {
    5828  return iteration_proxy_internal(container.begin());
    5829  }
    5830 
    5832  iteration_proxy_internal end()
    5833  {
    5834  return iteration_proxy_internal(container.end());
    5835  }
    5836  };
    5837 
    5838  public:
    5852  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    5853  {
    5855  friend class basic_json;
    5856 
    5857  public:
    5867  using iterator_category = std::bidirectional_iterator_tag;
    5868 
    5870  const_iterator() = default;
    5871 
    5873  const_iterator(pointer object) : m_object(object)
    5874  {
    5875  assert(m_object != nullptr);
    5876 
    5877  switch (m_object->m_type)
    5878  {
    5880  {
    5881  m_it.object_iterator = typename object_t::iterator();
    5882  break;
    5883  }
    5884 
    5886  {
    5887  m_it.array_iterator = typename array_t::iterator();
    5888  break;
    5889  }
    5890 
    5891  default:
    5892  {
    5893  m_it.primitive_iterator = primitive_iterator_t();
    5894  break;
    5895  }
    5896  }
    5897  }
    5898 
    5900  const_iterator(const iterator& other) : m_object(other.m_object)
    5901  {
    5902  assert(m_object != nullptr);
    5903 
    5904  switch (m_object->m_type)
    5905  {
    5907  {
    5908  m_it.object_iterator = other.m_it.object_iterator;
    5909  break;
    5910  }
    5911 
    5913  {
    5914  m_it.array_iterator = other.m_it.array_iterator;
    5915  break;
    5916  }
    5917 
    5918  default:
    5919  {
    5920  m_it.primitive_iterator = other.m_it.primitive_iterator;
    5921  break;
    5922  }
    5923  }
    5924  }
    5925 
    5927  const_iterator(const const_iterator& other) noexcept
    5928  : m_object(other.m_object), m_it(other.m_it)
    5929  {}
    5930 
    5933  std::is_nothrow_move_constructible<pointer>::value and
    5934  std::is_nothrow_move_assignable<pointer>::value and
    5935  std::is_nothrow_move_constructible<internal_iterator>::value and
    5936  std::is_nothrow_move_assignable<internal_iterator>::value
    5937  )
    5938  {
    5939  std::swap(m_object, other.m_object);
    5940  std::swap(m_it, other.m_it);
    5941  return *this;
    5942  }
    5943 
    5944  private:
    5946  void set_begin()
    5947  {
    5948  assert(m_object != nullptr);
    5949 
    5950  switch (m_object->m_type)
    5951  {
    5953  {
    5954  assert(m_object->m_value.object != nullptr);
    5955  m_it.object_iterator = m_object->m_value.object->begin();
    5956  break;
    5957  }
    5958 
    5960  {
    5961  assert(m_object->m_value.array != nullptr);
    5962  m_it.array_iterator = m_object->m_value.array->begin();
    5963  break;
    5964  }
    5965 
    5967  {
    5968  // set to end so begin()==end() is true: null is empty
    5969  m_it.primitive_iterator.set_end();
    5970  break;
    5971  }
    5972 
    5973  default:
    5974  {
    5975  m_it.primitive_iterator.set_begin();
    5976  break;
    5977  }
    5978  }
    5979  }
    5980 
    5982  void set_end()
    5983  {
    5984  assert(m_object != nullptr);
    5985 
    5986  switch (m_object->m_type)
    5987  {
    5989  {
    5990  assert(m_object->m_value.object != nullptr);
    5991  m_it.object_iterator = m_object->m_value.object->end();
    5992  break;
    5993  }
    5994 
    5996  {
    5997  assert(m_object->m_value.array != nullptr);
    5998  m_it.array_iterator = m_object->m_value.array->end();
    5999  break;
    6000  }
    6001 
    6002  default:
    6003  {
    6004  m_it.primitive_iterator.set_end();
    6005  break;
    6006  }
    6007  }
    6008  }
    6009 
    6010  public:
    6013  {
    6014  assert(m_object != nullptr);
    6015 
    6016  switch (m_object->m_type)
    6017  {
    6019  {
    6020  assert(m_object->m_value.object);
    6021  assert(m_it.object_iterator != m_object->m_value.object->end());
    6022  return m_it.object_iterator->second;
    6023  }
    6024 
    6026  {
    6027  assert(m_object->m_value.array);
    6028  assert(m_it.array_iterator != m_object->m_value.array->end());
    6029  return *m_it.array_iterator;
    6030  }
    6031 
    6033  {
    6034  throw std::out_of_range("cannot get value");
    6035  }
    6036 
    6037  default:
    6038  {
    6039  if (m_it.primitive_iterator.is_begin())
    6040  {
    6041  return *m_object;
    6042  }
    6043  else
    6044  {
    6045  throw std::out_of_range("cannot get value");
    6046  }
    6047  }
    6048  }
    6049  }
    6050 
    6053  {
    6054  assert(m_object != nullptr);
    6055 
    6056  switch (m_object->m_type)
    6057  {
    6059  {
    6060  assert(m_object->m_value.object);
    6061  assert(m_it.object_iterator != m_object->m_value.object->end());
    6062  return &(m_it.object_iterator->second);
    6063  }
    6064 
    6066  {
    6067  assert(m_object->m_value.array);
    6068  assert(m_it.array_iterator != m_object->m_value.array->end());
    6069  return &*m_it.array_iterator;
    6070  }
    6071 
    6072  default:
    6073  {
    6074  if (m_it.primitive_iterator.is_begin())
    6075  {
    6076  return m_object;
    6077  }
    6078  else
    6079  {
    6080  throw std::out_of_range("cannot get value");
    6081  }
    6082  }
    6083  }
    6084  }
    6085 
    6088  {
    6089  auto result = *this;
    6090  ++(*this);
    6091  return result;
    6092  }
    6093 
    6096  {
    6097  assert(m_object != nullptr);
    6098 
    6099  switch (m_object->m_type)
    6100  {
    6102  {
    6103  ++m_it.object_iterator;
    6104  break;
    6105  }
    6106 
    6108  {
    6109  ++m_it.array_iterator;
    6110  break;
    6111  }
    6112 
    6113  default:
    6114  {
    6115  ++m_it.primitive_iterator;
    6116  break;
    6117  }
    6118  }
    6119 
    6120  return *this;
    6121  }
    6122 
    6125  {
    6126  auto result = *this;
    6127  --(*this);
    6128  return result;
    6129  }
    6130 
    6133  {
    6134  assert(m_object != nullptr);
    6135 
    6136  switch (m_object->m_type)
    6137  {
    6139  {
    6140  --m_it.object_iterator;
    6141  break;
    6142  }
    6143 
    6145  {
    6146  --m_it.array_iterator;
    6147  break;
    6148  }
    6149 
    6150  default:
    6151  {
    6152  --m_it.primitive_iterator;
    6153  break;
    6154  }
    6155  }
    6156 
    6157  return *this;
    6158  }
    6159 
    6161  bool operator==(const const_iterator& other) const
    6162  {
    6163  // if objects are not the same, the comparison is undefined
    6164  if (m_object != other.m_object)
    6165  {
    6166  throw std::domain_error("cannot compare iterators of different containers");
    6167  }
    6168 
    6169  assert(m_object != nullptr);
    6170 
    6171  switch (m_object->m_type)
    6172  {
    6174  {
    6175  return (m_it.object_iterator == other.m_it.object_iterator);
    6176  }
    6177 
    6179  {
    6180  return (m_it.array_iterator == other.m_it.array_iterator);
    6181  }
    6182 
    6183  default:
    6184  {
    6185  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6186  }
    6187  }
    6188  }
    6189 
    6191  bool operator!=(const const_iterator& other) const
    6192  {
    6193  return not operator==(other);
    6194  }
    6195 
    6197  bool operator<(const const_iterator& other) const
    6198  {
    6199  // if objects are not the same, the comparison is undefined
    6200  if (m_object != other.m_object)
    6201  {
    6202  throw std::domain_error("cannot compare iterators of different containers");
    6203  }
    6204 
    6205  assert(m_object != nullptr);
    6206 
    6207  switch (m_object->m_type)
    6208  {
    6210  {
    6211  throw std::domain_error("cannot compare order of object iterators");
    6212  }
    6213 
    6215  {
    6216  return (m_it.array_iterator < other.m_it.array_iterator);
    6217  }
    6218 
    6219  default:
    6220  {
    6221  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6222  }
    6223  }
    6224  }
    6225 
    6227  bool operator<=(const const_iterator& other) const
    6228  {
    6229  return not other.operator < (*this);
    6230  }
    6231 
    6233  bool operator>(const const_iterator& other) const
    6234  {
    6235  return not operator<=(other);
    6236  }
    6237 
    6239  bool operator>=(const const_iterator& other) const
    6240  {
    6241  return not operator<(other);
    6242  }
    6243 
    6246  {
    6247  assert(m_object != nullptr);
    6248 
    6249  switch (m_object->m_type)
    6250  {
    6252  {
    6253  throw std::domain_error("cannot use offsets with object iterators");
    6254  }
    6255 
    6257  {
    6258  m_it.array_iterator += i;
    6259  break;
    6260  }
    6261 
    6262  default:
    6263  {
    6264  m_it.primitive_iterator += i;
    6265  break;
    6266  }
    6267  }
    6268 
    6269  return *this;
    6270  }
    6271 
    6274  {
    6275  return operator+=(-i);
    6276  }
    6277 
    6280  {
    6281  auto result = *this;
    6282  result += i;
    6283  return result;
    6284  }
    6285 
    6288  {
    6289  auto result = *this;
    6290  result -= i;
    6291  return result;
    6292  }
    6293 
    6296  {
    6297  assert(m_object != nullptr);
    6298 
    6299  switch (m_object->m_type)
    6300  {
    6302  {
    6303  throw std::domain_error("cannot use offsets with object iterators");
    6304  }
    6305 
    6307  {
    6308  return m_it.array_iterator - other.m_it.array_iterator;
    6309  }
    6310 
    6311  default:
    6312  {
    6313  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6314  }
    6315  }
    6316  }
    6317 
    6320  {
    6321  assert(m_object != nullptr);
    6322 
    6323  switch (m_object->m_type)
    6324  {
    6326  {
    6327  throw std::domain_error("cannot use operator[] for object iterators");
    6328  }
    6329 
    6331  {
    6332  return *(m_it.array_iterator + n);
    6333  }
    6334 
    6336  {
    6337  throw std::out_of_range("cannot get value");
    6338  }
    6339 
    6340  default:
    6341  {
    6342  if (m_it.primitive_iterator == -n)
    6343  {
    6344  return *m_object;
    6345  }
    6346  else
    6347  {
    6348  throw std::out_of_range("cannot get value");
    6349  }
    6350  }
    6351  }
    6352  }
    6353 
    6355  typename object_t::key_type key() const
    6356  {
    6357  assert(m_object != nullptr);
    6358 
    6359  if (m_object->is_object())
    6360  {
    6361  return m_it.object_iterator->first;
    6362  }
    6363  else
    6364  {
    6365  throw std::domain_error("cannot use key() for non-object iterators");
    6366  }
    6367  }
    6368 
    6371  {
    6372  return operator*();
    6373  }
    6374 
    6375  private:
    6377  pointer m_object = nullptr;
    6379  internal_iterator m_it = internal_iterator();
    6380  };
    6381 
    6394  class iterator : public const_iterator
    6395  {
    6396  public:
    6398  using pointer = typename basic_json::pointer;
    6400 
    6402  iterator() = default;
    6403 
    6405  iterator(pointer object) noexcept
    6406  : base_iterator(object)
    6407  {}
    6408 
    6410  iterator(const iterator& other) noexcept
    6411  : base_iterator(other)
    6412  {}
    6413 
    6415  iterator& operator=(iterator other) noexcept(
    6416  std::is_nothrow_move_constructible<pointer>::value and
    6417  std::is_nothrow_move_assignable<pointer>::value and
    6418  std::is_nothrow_move_constructible<internal_iterator>::value and
    6419  std::is_nothrow_move_assignable<internal_iterator>::value
    6420  )
    6421  {
    6422  base_iterator::operator=(other);
    6423  return *this;
    6424  }
    6425 
    6428  {
    6429  return const_cast<reference>(base_iterator::operator*());
    6430  }
    6431 
    6434  {
    6435  return const_cast<pointer>(base_iterator::operator->());
    6436  }
    6437 
    6440  {
    6441  iterator result = *this;
    6442  base_iterator::operator++();
    6443  return result;
    6444  }
    6445 
    6448  {
    6449  base_iterator::operator++();
    6450  return *this;
    6451  }
    6452 
    6455  {
    6456  iterator result = *this;
    6457  base_iterator::operator--();
    6458  return result;
    6459  }
    6460 
    6463  {
    6464  base_iterator::operator--();
    6465  return *this;
    6466  }
    6467 
    6470  {
    6471  base_iterator::operator+=(i);
    6472  return *this;
    6473  }
    6474 
    6477  {
    6478  base_iterator::operator-=(i);
    6479  return *this;
    6480  }
    6481 
    6484  {
    6485  auto result = *this;
    6486  result += i;
    6487  return result;
    6488  }
    6489 
    6492  {
    6493  auto result = *this;
    6494  result -= i;
    6495  return result;
    6496  }
    6497 
    6498  difference_type operator-(const iterator& other) const
    6499  {
    6500  return base_iterator::operator-(other);
    6501  }
    6502 
    6505  {
    6506  return const_cast<reference>(base_iterator::operator[](n));
    6507  }
    6508 
    6511  {
    6512  return const_cast<reference>(base_iterator::value());
    6513  }
    6514  };
    6515 
    6533  template<typename Base>
    6534  class json_reverse_iterator : public std::reverse_iterator<Base>
    6535  {
    6536  public:
    6538  using base_iterator = std::reverse_iterator<Base>;
    6540  using reference = typename Base::reference;
    6541 
    6543  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6544  : base_iterator(it)
    6545  {}
    6546 
    6549  : base_iterator(it)
    6550  {}
    6551 
    6554  {
    6555  return base_iterator::operator++(1);
    6556  }
    6557 
    6560  {
    6561  base_iterator::operator++();
    6562  return *this;
    6563  }
    6564 
    6567  {
    6568  return base_iterator::operator--(1);
    6569  }
    6570 
    6573  {
    6574  base_iterator::operator--();
    6575  return *this;
    6576  }
    6577 
    6580  {
    6581  base_iterator::operator+=(i);
    6582  return *this;
    6583  }
    6584 
    6587  {
    6588  auto result = *this;
    6589  result += i;
    6590  return result;
    6591  }
    6592 
    6595  {
    6596  auto result = *this;
    6597  result -= i;
    6598  return result;
    6599  }
    6600 
    6603  {
    6604  return this->base() - other.base();
    6605  }
    6606 
    6609  {
    6610  return *(this->operator+(n));
    6611  }
    6612 
    6614  typename object_t::key_type key() const
    6615  {
    6616  auto it = --this->base();
    6617  return it.key();
    6618  }
    6619 
    6622  {
    6623  auto it = --this->base();
    6624  return it.operator * ();
    6625  }
    6626  };
    6627 
    6628 
    6629  private:
    6631  // lexer and parser //
    6633 
    6641  class lexer
    6642  {
    6643  public:
    6645  enum class token_type
    6646  {
    6647  uninitialized,
    6648  literal_true,
    6649  literal_false,
    6650  literal_null,
    6651  value_string,
    6652  value_number,
    6653  begin_array,
    6654  begin_object,
    6655  end_array,
    6656  end_object,
    6657  name_separator,
    6658  value_separator,
    6659  parse_error,
    6660  end_of_input
    6661  };
    6662 
    6664  using lexer_char_t = unsigned char;
    6665 
    6667  explicit lexer(const string_t& s) noexcept
    6668  : m_stream(nullptr), m_buffer(s)
    6669  {
    6670  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    6671  assert(m_content != nullptr);
    6672  m_start = m_cursor = m_content;
    6673  m_limit = m_content + s.size();
    6674  }
    6675 
    6677  explicit lexer(std::istream* s) noexcept
    6678  : m_stream(s), m_buffer()
    6679  {
    6680  assert(m_stream != nullptr);
    6681  getline(*m_stream, m_buffer);
    6682  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    6683  assert(m_content != nullptr);
    6684  m_start = m_cursor = m_content;
    6685  m_limit = m_content + m_buffer.size();
    6686  }
    6687 
    6689  lexer() = default;
    6690 
    6691  // switch off unwanted functions
    6692  lexer(const lexer&) = delete;
    6693  lexer operator=(const lexer&) = delete;
    6694 
    6710  static string_t to_unicode(const std::size_t codepoint1,
    6711  const std::size_t codepoint2 = 0)
    6712  {
    6713  string_t result;
    6714 
    6715  // calculate the codepoint from the given code points
    6716  std::size_t codepoint = codepoint1;
    6717 
    6718  // check if codepoint1 is a high surrogate
    6719  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    6720  {
    6721  // check if codepoint2 is a low surrogate
    6722  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    6723  {
    6724  codepoint =
    6725  // high surrogate occupies the most significant 22 bits
    6726  (codepoint1 << 10)
    6727  // low surrogate occupies the least significant 15 bits
    6728  + codepoint2
    6729  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    6730  // in the result so we have to subtract with:
    6731  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    6732  - 0x35FDC00;
    6733  }
    6734  else
    6735  {
    6736  throw std::invalid_argument("missing or wrong low surrogate");
    6737  }
    6738  }
    6739 
    6740  if (codepoint < 0x80)
    6741  {
    6742  // 1-byte characters: 0xxxxxxx (ASCII)
    6743  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    6744  }
    6745  else if (codepoint <= 0x7ff)
    6746  {
    6747  // 2-byte characters: 110xxxxx 10xxxxxx
    6748  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    6749  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6750  }
    6751  else if (codepoint <= 0xffff)
    6752  {
    6753  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    6754  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    6755  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    6756  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6757  }
    6758  else if (codepoint <= 0x10ffff)
    6759  {
    6760  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    6761  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    6762  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    6763  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    6764  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6765  }
    6766  else
    6767  {
    6768  throw std::out_of_range("code points above 0x10FFFF are invalid");
    6769  }
    6770 
    6771  return result;
    6772  }
    6773 
    6775  static std::string token_type_name(token_type t)
    6776  {
    6777  switch (t)
    6778  {
    6779  case token_type::uninitialized:
    6780  return "<uninitialized>";
    6781  case token_type::literal_true:
    6782  return "true literal";
    6783  case token_type::literal_false:
    6784  return "false literal";
    6785  case token_type::literal_null:
    6786  return "null literal";
    6787  case token_type::value_string:
    6788  return "string literal";
    6789  case token_type::value_number:
    6790  return "number literal";
    6791  case token_type::begin_array:
    6792  return "'['";
    6793  case token_type::begin_object:
    6794  return "'{'";
    6795  case token_type::end_array:
    6796  return "']'";
    6797  case token_type::end_object:
    6798  return "'}'";
    6799  case token_type::name_separator:
    6800  return "':'";
    6801  case token_type::value_separator:
    6802  return "','";
    6803  case token_type::parse_error:
    6804  return "<parse error>";
    6805  case token_type::end_of_input:
    6806  return "end of input";
    6807  default:
    6808  {
    6809  // catch non-enum values
    6810  return "unknown token"; // LCOV_EXCL_LINE
    6811  }
    6812  }
    6813  }
    6814 
    6825  token_type scan() noexcept
    6826  {
    6827  // pointer for backtracking information
    6828  m_marker = nullptr;
    6829 
    6830  // remember the begin of the token
    6831  m_start = m_cursor;
    6832  assert(m_start != nullptr);
    6833 
    6834 
    6835  {
    6836  lexer_char_t yych;
    6837  unsigned int yyaccept = 0;
    6838  static const unsigned char yybm[] =
    6839  {
    6840  0, 0, 0, 0, 0, 0, 0, 0,
    6841  0, 32, 32, 0, 0, 32, 0, 0,
    6842  64, 64, 64, 64, 64, 64, 64, 64,
    6843  64, 64, 64, 64, 64, 64, 64, 64,
    6844  96, 64, 0, 64, 64, 64, 64, 64,
    6845  64, 64, 64, 64, 64, 64, 64, 64,
    6846  192, 192, 192, 192, 192, 192, 192, 192,
    6847  192, 192, 64, 64, 64, 64, 64, 64,
    6848  64, 64, 64, 64, 64, 64, 64, 64,
    6849  64, 64, 64, 64, 64, 64, 64, 64,
    6850  64, 64, 64, 64, 64, 64, 64, 64,
    6851  64, 64, 64, 64, 0, 64, 64, 64,
    6852  64, 64, 64, 64, 64, 64, 64, 64,
    6853  64, 64, 64, 64, 64, 64, 64, 64,
    6854  64, 64, 64, 64, 64, 64, 64, 64,
    6855  64, 64, 64, 64, 64, 64, 64, 64,
    6856  64, 64, 64, 64, 64, 64, 64, 64,
    6857  64, 64, 64, 64, 64, 64, 64, 64,
    6858  64, 64, 64, 64, 64, 64, 64, 64,
    6859  64, 64, 64, 64, 64, 64, 64, 64,
    6860  64, 64, 64, 64, 64, 64, 64, 64,
    6861  64, 64, 64, 64, 64, 64, 64, 64,
    6862  64, 64, 64, 64, 64, 64, 64, 64,
    6863  64, 64, 64, 64, 64, 64, 64, 64,
    6864  64, 64, 64, 64, 64, 64, 64, 64,
    6865  64, 64, 64, 64, 64, 64, 64, 64,
    6866  64, 64, 64, 64, 64, 64, 64, 64,
    6867  64, 64, 64, 64, 64, 64, 64, 64,
    6868  64, 64, 64, 64, 64, 64, 64, 64,
    6869  64, 64, 64, 64, 64, 64, 64, 64,
    6870  64, 64, 64, 64, 64, 64, 64, 64,
    6871  64, 64, 64, 64, 64, 64, 64, 64,
    6872  };
    6873  if ((m_limit - m_cursor) < 5)
    6874  {
    6875  yyfill(); // LCOV_EXCL_LINE;
    6876  }
    6877  yych = *m_cursor;
    6878  if (yych <= ':')
    6879  {
    6880  if (yych <= ' ')
    6881  {
    6882  if (yych <= '\n')
    6883  {
    6884  if (yych <= 0x00)
    6885  {
    6886  goto basic_json_parser_28;
    6887  }
    6888  if (yych <= 0x08)
    6889  {
    6890  goto basic_json_parser_30;
    6891  }
    6892  if (yych >= '\n')
    6893  {
    6894  goto basic_json_parser_4;
    6895  }
    6896  }
    6897  else
    6898  {
    6899  if (yych == '\r')
    6900  {
    6901  goto basic_json_parser_2;
    6902  }
    6903  if (yych <= 0x1F)
    6904  {
    6905  goto basic_json_parser_30;
    6906  }
    6907  }
    6908  }
    6909  else
    6910  {
    6911  if (yych <= ',')
    6912  {
    6913  if (yych == '"')
    6914  {
    6915  goto basic_json_parser_27;
    6916  }
    6917  if (yych <= '+')
    6918  {
    6919  goto basic_json_parser_30;
    6920  }
    6921  goto basic_json_parser_16;
    6922  }
    6923  else
    6924  {
    6925  if (yych <= '/')
    6926  {
    6927  if (yych <= '-')
    6928  {
    6929  goto basic_json_parser_23;
    6930  }
    6931  goto basic_json_parser_30;
    6932  }
    6933  else
    6934  {
    6935  if (yych <= '0')
    6936  {
    6937  goto basic_json_parser_24;
    6938  }
    6939  if (yych <= '9')
    6940  {
    6941  goto basic_json_parser_26;
    6942  }
    6943  goto basic_json_parser_18;
    6944  }
    6945  }
    6946  }
    6947  }
    6948  else
    6949  {
    6950  if (yych <= 'n')
    6951  {
    6952  if (yych <= ']')
    6953  {
    6954  if (yych == '[')
    6955  {
    6956  goto basic_json_parser_8;
    6957  }
    6958  if (yych <= '\\')
    6959  {
    6960  goto basic_json_parser_30;
    6961  }
    6962  goto basic_json_parser_10;
    6963  }
    6964  else
    6965  {
    6966  if (yych == 'f')
    6967  {
    6968  goto basic_json_parser_22;
    6969  }
    6970  if (yych <= 'm')
    6971  {
    6972  goto basic_json_parser_30;
    6973  }
    6974  goto basic_json_parser_20;
    6975  }
    6976  }
    6977  else
    6978  {
    6979  if (yych <= '{')
    6980  {
    6981  if (yych == 't')
    6982  {
    6983  goto basic_json_parser_21;
    6984  }
    6985  if (yych <= 'z')
    6986  {
    6987  goto basic_json_parser_30;
    6988  }
    6989  goto basic_json_parser_12;
    6990  }
    6991  else
    6992  {
    6993  if (yych <= '}')
    6994  {
    6995  if (yych <= '|')
    6996  {
    6997  goto basic_json_parser_30;
    6998  }
    6999  goto basic_json_parser_14;
    7000  }
    7001  else
    7002  {
    7003  if (yych == 0xEF)
    7004  {
    7005  goto basic_json_parser_6;
    7006  }
    7007  goto basic_json_parser_30;
    7008  }
    7009  }
    7010  }
    7011  }
    7012 basic_json_parser_2:
    7013  ++m_cursor;
    7014  yych = *m_cursor;
    7015  goto basic_json_parser_5;
    7016 basic_json_parser_3:
    7017  {
    7018  return scan();
    7019  }
    7020 basic_json_parser_4:
    7021  ++m_cursor;
    7022  if (m_limit <= m_cursor)
    7023  {
    7024  yyfill(); // LCOV_EXCL_LINE;
    7025  }
    7026  yych = *m_cursor;
    7027 basic_json_parser_5:
    7028  if (yybm[0 + yych] & 32)
    7029  {
    7030  goto basic_json_parser_4;
    7031  }
    7032  goto basic_json_parser_3;
    7033 basic_json_parser_6:
    7034  yyaccept = 0;
    7035  yych = *(m_marker = ++m_cursor);
    7036  if (yych == 0xBB)
    7037  {
    7038  goto basic_json_parser_64;
    7039  }
    7040 basic_json_parser_7:
    7041  {
    7042  return token_type::parse_error;
    7043  }
    7044 basic_json_parser_8:
    7045  ++m_cursor;
    7046  {
    7047  return token_type::begin_array;
    7048  }
    7049 basic_json_parser_10:
    7050  ++m_cursor;
    7051  {
    7052  return token_type::end_array;
    7053  }
    7054 basic_json_parser_12:
    7055  ++m_cursor;
    7056  {
    7057  return token_type::begin_object;
    7058  }
    7059 basic_json_parser_14:
    7060  ++m_cursor;
    7061  {
    7062  return token_type::end_object;
    7063  }
    7064 basic_json_parser_16:
    7065  ++m_cursor;
    7066  {
    7067  return token_type::value_separator;
    7068  }
    7069 basic_json_parser_18:
    7070  ++m_cursor;
    7071  {
    7072  return token_type::name_separator;
    7073  }
    7074 basic_json_parser_20:
    7075  yyaccept = 0;
    7076  yych = *(m_marker = ++m_cursor);
    7077  if (yych == 'u')
    7078  {
    7079  goto basic_json_parser_60;
    7080  }
    7081  goto basic_json_parser_7;
    7082 basic_json_parser_21:
    7083  yyaccept = 0;
    7084  yych = *(m_marker = ++m_cursor);
    7085  if (yych == 'r')
    7086  {
    7087  goto basic_json_parser_56;
    7088  }
    7089  goto basic_json_parser_7;
    7090 basic_json_parser_22:
    7091  yyaccept = 0;
    7092  yych = *(m_marker = ++m_cursor);
    7093  if (yych == 'a')
    7094  {
    7095  goto basic_json_parser_51;
    7096  }
    7097  goto basic_json_parser_7;
    7098 basic_json_parser_23:
    7099  yych = *++m_cursor;
    7100  if (yych <= '/')
    7101  {
    7102  goto basic_json_parser_7;
    7103  }
    7104  if (yych <= '0')
    7105  {
    7106  goto basic_json_parser_50;
    7107  }
    7108  if (yych <= '9')
    7109  {
    7110  goto basic_json_parser_41;
    7111  }
    7112  goto basic_json_parser_7;
    7113 basic_json_parser_24:
    7114  yyaccept = 1;
    7115  yych = *(m_marker = ++m_cursor);
    7116  if (yych <= 'D')
    7117  {
    7118  if (yych == '.')
    7119  {
    7120  goto basic_json_parser_43;
    7121  }
    7122  }
    7123  else
    7124  {
    7125  if (yych <= 'E')
    7126  {
    7127  goto basic_json_parser_44;
    7128  }
    7129  if (yych == 'e')
    7130  {
    7131  goto basic_json_parser_44;
    7132  }
    7133  }
    7134 basic_json_parser_25:
    7135  {
    7136  return token_type::value_number;
    7137  }
    7138 basic_json_parser_26:
    7139  yyaccept = 1;
    7140  yych = *(m_marker = ++m_cursor);
    7141  goto basic_json_parser_42;
    7142 basic_json_parser_27:
    7143  yyaccept = 0;
    7144  yych = *(m_marker = ++m_cursor);
    7145  if (yych <= 0x0F)
    7146  {
    7147  goto basic_json_parser_7;
    7148  }
    7149  goto basic_json_parser_32;
    7150 basic_json_parser_28:
    7151  ++m_cursor;
    7152  {
    7153  return token_type::end_of_input;
    7154  }
    7155 basic_json_parser_30:
    7156  yych = *++m_cursor;
    7157  goto basic_json_parser_7;
    7158 basic_json_parser_31:
    7159  ++m_cursor;
    7160  if (m_limit <= m_cursor)
    7161  {
    7162  yyfill(); // LCOV_EXCL_LINE;
    7163  }
    7164  yych = *m_cursor;
    7165 basic_json_parser_32:
    7166  if (yybm[0 + yych] & 64)
    7167  {
    7168  goto basic_json_parser_31;
    7169  }
    7170  if (yych <= 0x0F)
    7171  {
    7172  goto basic_json_parser_33;
    7173  }
    7174  if (yych <= '"')
    7175  {
    7176  goto basic_json_parser_35;
    7177  }
    7178  goto basic_json_parser_34;
    7179 basic_json_parser_33:
    7180  m_cursor = m_marker;
    7181  if (yyaccept == 0)
    7182  {
    7183  goto basic_json_parser_7;
    7184  }
    7185  else
    7186  {
    7187  goto basic_json_parser_25;
    7188  }
    7189 basic_json_parser_34:
    7190  ++m_cursor;
    7191  if (m_limit <= m_cursor)
    7192  {
    7193  yyfill(); // LCOV_EXCL_LINE;
    7194  }
    7195  yych = *m_cursor;
    7196  if (yych <= 'e')
    7197  {
    7198  if (yych <= '/')
    7199  {
    7200  if (yych == '"')
    7201  {
    7202  goto basic_json_parser_31;
    7203  }
    7204  if (yych <= '.')
    7205  {
    7206  goto basic_json_parser_33;
    7207  }
    7208  goto basic_json_parser_31;
    7209  }
    7210  else
    7211  {
    7212  if (yych <= '\\')
    7213  {
    7214  if (yych <= '[')
    7215  {
    7216  goto basic_json_parser_33;
    7217  }
    7218  goto basic_json_parser_31;
    7219  }
    7220  else
    7221  {
    7222  if (yych == 'b')
    7223  {
    7224  goto basic_json_parser_31;
    7225  }
    7226  goto basic_json_parser_33;
    7227  }
    7228  }
    7229  }
    7230  else
    7231  {
    7232  if (yych <= 'q')
    7233  {
    7234  if (yych <= 'f')
    7235  {
    7236  goto basic_json_parser_31;
    7237  }
    7238  if (yych == 'n')
    7239  {
    7240  goto basic_json_parser_31;
    7241  }
    7242  goto basic_json_parser_33;
    7243  }
    7244  else
    7245  {
    7246  if (yych <= 's')
    7247  {
    7248  if (yych <= 'r')
    7249  {
    7250  goto basic_json_parser_31;
    7251  }
    7252  goto basic_json_parser_33;
    7253  }
    7254  else
    7255  {
    7256  if (yych <= 't')
    7257  {
    7258  goto basic_json_parser_31;
    7259  }
    7260  if (yych <= 'u')
    7261  {
    7262  goto basic_json_parser_37;
    7263  }
    7264  goto basic_json_parser_33;
    7265  }
    7266  }
    7267  }
    7268 basic_json_parser_35:
    7269  ++m_cursor;
    7270  {
    7271  return token_type::value_string;
    7272  }
    7273 basic_json_parser_37:
    7274  ++m_cursor;
    7275  if (m_limit <= m_cursor)
    7276  {
    7277  yyfill(); // LCOV_EXCL_LINE;
    7278  }
    7279  yych = *m_cursor;
    7280  if (yych <= '@')
    7281  {
    7282  if (yych <= '/')
    7283  {
    7284  goto basic_json_parser_33;
    7285  }
    7286  if (yych >= ':')
    7287  {
    7288  goto basic_json_parser_33;
    7289  }
    7290  }
    7291  else
    7292  {
    7293  if (yych <= 'F')
    7294  {
    7295  goto basic_json_parser_38;
    7296  }
    7297  if (yych <= '`')
    7298  {
    7299  goto basic_json_parser_33;
    7300  }
    7301  if (yych >= 'g')
    7302  {
    7303  goto basic_json_parser_33;
    7304  }
    7305  }
    7306 basic_json_parser_38:
    7307  ++m_cursor;
    7308  if (m_limit <= m_cursor)
    7309  {
    7310  yyfill(); // LCOV_EXCL_LINE;
    7311  }
    7312  yych = *m_cursor;
    7313  if (yych <= '@')
    7314  {
    7315  if (yych <= '/')
    7316  {
    7317  goto basic_json_parser_33;
    7318  }
    7319  if (yych >= ':')
    7320  {
    7321  goto basic_json_parser_33;
    7322  }
    7323  }
    7324  else
    7325  {
    7326  if (yych <= 'F')
    7327  {
    7328  goto basic_json_parser_39;
    7329  }
    7330  if (yych <= '`')
    7331  {
    7332  goto basic_json_parser_33;
    7333  }
    7334  if (yych >= 'g')
    7335  {
    7336  goto basic_json_parser_33;
    7337  }
    7338  }
    7339 basic_json_parser_39:
    7340  ++m_cursor;
    7341  if (m_limit <= m_cursor)
    7342  {
    7343  yyfill(); // LCOV_EXCL_LINE;
    7344  }
    7345  yych = *m_cursor;
    7346  if (yych <= '@')
    7347  {
    7348  if (yych <= '/')
    7349  {
    7350  goto basic_json_parser_33;
    7351  }
    7352  if (yych >= ':')
    7353  {
    7354  goto basic_json_parser_33;
    7355  }
    7356  }
    7357  else
    7358  {
    7359  if (yych <= 'F')
    7360  {
    7361  goto basic_json_parser_40;
    7362  }
    7363  if (yych <= '`')
    7364  {
    7365  goto basic_json_parser_33;
    7366  }
    7367  if (yych >= 'g')
    7368  {
    7369  goto basic_json_parser_33;
    7370  }
    7371  }
    7372 basic_json_parser_40:
    7373  ++m_cursor;
    7374  if (m_limit <= m_cursor)
    7375  {
    7376  yyfill(); // LCOV_EXCL_LINE;
    7377  }
    7378  yych = *m_cursor;
    7379  if (yych <= '@')
    7380  {
    7381  if (yych <= '/')
    7382  {
    7383  goto basic_json_parser_33;
    7384  }
    7385  if (yych <= '9')
    7386  {
    7387  goto basic_json_parser_31;
    7388  }
    7389  goto basic_json_parser_33;
    7390  }
    7391  else
    7392  {
    7393  if (yych <= 'F')
    7394  {
    7395  goto basic_json_parser_31;
    7396  }
    7397  if (yych <= '`')
    7398  {
    7399  goto basic_json_parser_33;
    7400  }
    7401  if (yych <= 'f')
    7402  {
    7403  goto basic_json_parser_31;
    7404  }
    7405  goto basic_json_parser_33;
    7406  }
    7407 basic_json_parser_41:
    7408  yyaccept = 1;
    7409  m_marker = ++m_cursor;
    7410  if ((m_limit - m_cursor) < 3)
    7411  {
    7412  yyfill(); // LCOV_EXCL_LINE;
    7413  }
    7414  yych = *m_cursor;
    7415 basic_json_parser_42:
    7416  if (yybm[0 + yych] & 128)
    7417  {
    7418  goto basic_json_parser_41;
    7419  }
    7420  if (yych <= 'D')
    7421  {
    7422  if (yych != '.')
    7423  {
    7424  goto basic_json_parser_25;
    7425  }
    7426  }
    7427  else
    7428  {
    7429  if (yych <= 'E')
    7430  {
    7431  goto basic_json_parser_44;
    7432  }
    7433  if (yych == 'e')
    7434  {
    7435  goto basic_json_parser_44;
    7436  }
    7437  goto basic_json_parser_25;
    7438  }
    7439 basic_json_parser_43:
    7440  yych = *++m_cursor;
    7441  if (yych <= '/')
    7442  {
    7443  goto basic_json_parser_33;
    7444  }
    7445  if (yych <= '9')
    7446  {
    7447  goto basic_json_parser_48;
    7448  }
    7449  goto basic_json_parser_33;
    7450 basic_json_parser_44:
    7451  yych = *++m_cursor;
    7452  if (yych <= ',')
    7453  {
    7454  if (yych != '+')
    7455  {
    7456  goto basic_json_parser_33;
    7457  }
    7458  }
    7459  else
    7460  {
    7461  if (yych <= '-')
    7462  {
    7463  goto basic_json_parser_45;
    7464  }
    7465  if (yych <= '/')
    7466  {
    7467  goto basic_json_parser_33;
    7468  }
    7469  if (yych <= '9')
    7470  {
    7471  goto basic_json_parser_46;
    7472  }
    7473  goto basic_json_parser_33;
    7474  }
    7475 basic_json_parser_45:
    7476  yych = *++m_cursor;
    7477  if (yych <= '/')
    7478  {
    7479  goto basic_json_parser_33;
    7480  }
    7481  if (yych >= ':')
    7482  {
    7483  goto basic_json_parser_33;
    7484  }
    7485 basic_json_parser_46:
    7486  ++m_cursor;
    7487  if (m_limit <= m_cursor)
    7488  {
    7489  yyfill(); // LCOV_EXCL_LINE;
    7490  }
    7491  yych = *m_cursor;
    7492  if (yych <= '/')
    7493  {
    7494  goto basic_json_parser_25;
    7495  }
    7496  if (yych <= '9')
    7497  {
    7498  goto basic_json_parser_46;
    7499  }
    7500  goto basic_json_parser_25;
    7501 basic_json_parser_48:
    7502  yyaccept = 1;
    7503  m_marker = ++m_cursor;
    7504  if ((m_limit - m_cursor) < 3)
    7505  {
    7506  yyfill(); // LCOV_EXCL_LINE;
    7507  }
    7508  yych = *m_cursor;
    7509  if (yych <= 'D')
    7510  {
    7511  if (yych <= '/')
    7512  {
    7513  goto basic_json_parser_25;
    7514  }
    7515  if (yych <= '9')
    7516  {
    7517  goto basic_json_parser_48;
    7518  }
    7519  goto basic_json_parser_25;
    7520  }
    7521  else
    7522  {
    7523  if (yych <= 'E')
    7524  {
    7525  goto basic_json_parser_44;
    7526  }
    7527  if (yych == 'e')
    7528  {
    7529  goto basic_json_parser_44;
    7530  }
    7531  goto basic_json_parser_25;
    7532  }
    7533 basic_json_parser_50:
    7534  yyaccept = 1;
    7535  yych = *(m_marker = ++m_cursor);
    7536  if (yych <= 'D')
    7537  {
    7538  if (yych == '.')
    7539  {
    7540  goto basic_json_parser_43;
    7541  }
    7542  goto basic_json_parser_25;
    7543  }
    7544  else
    7545  {
    7546  if (yych <= 'E')
    7547  {
    7548  goto basic_json_parser_44;
    7549  }
    7550  if (yych == 'e')
    7551  {
    7552  goto basic_json_parser_44;
    7553  }
    7554  goto basic_json_parser_25;
    7555  }
    7556 basic_json_parser_51:
    7557  yych = *++m_cursor;
    7558  if (yych != 'l')
    7559  {
    7560  goto basic_json_parser_33;
    7561  }
    7562  yych = *++m_cursor;
    7563  if (yych != 's')
    7564  {
    7565  goto basic_json_parser_33;
    7566  }
    7567  yych = *++m_cursor;
    7568  if (yych != 'e')
    7569  {
    7570  goto basic_json_parser_33;
    7571  }
    7572  ++m_cursor;
    7573  {
    7574  return token_type::literal_false;
    7575  }
    7576 basic_json_parser_56:
    7577  yych = *++m_cursor;
    7578  if (yych != 'u')
    7579  {
    7580  goto basic_json_parser_33;
    7581  }
    7582  yych = *++m_cursor;
    7583  if (yych != 'e')
    7584  {
    7585  goto basic_json_parser_33;
    7586  }
    7587  ++m_cursor;
    7588  {
    7589  return token_type::literal_true;
    7590  }
    7591 basic_json_parser_60:
    7592  yych = *++m_cursor;
    7593  if (yych != 'l')
    7594  {
    7595  goto basic_json_parser_33;
    7596  }
    7597  yych = *++m_cursor;
    7598  if (yych != 'l')
    7599  {
    7600  goto basic_json_parser_33;
    7601  }
    7602  ++m_cursor;
    7603  {
    7604  return token_type::literal_null;
    7605  }
    7606 basic_json_parser_64:
    7607  yych = *++m_cursor;
    7608  if (yych != 0xBF)
    7609  {
    7610  goto basic_json_parser_33;
    7611  }
    7612  ++m_cursor;
    7613  {
    7614  return scan();
    7615  }
    7616  }
    7617 
    7618 
    7619  }
    7620 
    7622  void yyfill() noexcept
    7623  {
    7624  if (m_stream == nullptr or not * m_stream)
    7625  {
    7626  return;
    7627  }
    7628 
    7629  const ssize_t offset_start = m_start - m_content;
    7630  const ssize_t offset_marker = m_marker - m_start;
    7631  const ssize_t offset_cursor = m_cursor - m_start;
    7632 
    7633  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7634  std::string line;
    7635  assert(m_stream != nullptr);
    7636  std::getline(*m_stream, line);
    7637  m_buffer += "\n" + line; // add line with newline symbol
    7638 
    7639  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7640  assert(m_content != nullptr);
    7641  m_start = m_content;
    7642  m_marker = m_start + offset_marker;
    7643  m_cursor = m_start + offset_cursor;
    7644  m_limit = m_start + m_buffer.size() - 1;
    7645  }
    7646 
    7648  string_t get_token() const noexcept
    7649  {
    7650  assert(m_start != nullptr);
    7651  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7652  static_cast<size_t>(m_cursor - m_start));
    7653  }
    7654 
    7676  string_t get_string() const
    7677  {
    7678  string_t result;
    7679  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    7680 
    7681  // iterate the result between the quotes
    7682  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    7683  {
    7684  // process escaped characters
    7685  if (*i == '\\')
    7686  {
    7687  // read next character
    7688  ++i;
    7689 
    7690  switch (*i)
    7691  {
    7692  // the default escapes
    7693  case 't':
    7694  {
    7695  result += "\t";
    7696  break;
    7697  }
    7698  case 'b':
    7699  {
    7700  result += "\b";
    7701  break;
    7702  }
    7703  case 'f':
    7704  {
    7705  result += "\f";
    7706  break;
    7707  }
    7708  case 'n':
    7709  {
    7710  result += "\n";
    7711  break;
    7712  }
    7713  case 'r':
    7714  {
    7715  result += "\r";
    7716  break;
    7717  }
    7718  case '\\':
    7719  {
    7720  result += "\\";
    7721  break;
    7722  }
    7723  case '/':
    7724  {
    7725  result += "/";
    7726  break;
    7727  }
    7728  case '"':
    7729  {
    7730  result += "\"";
    7731  break;
    7732  }
    7733 
    7734  // unicode
    7735  case 'u':
    7736  {
    7737  // get code xxxx from uxxxx
    7738  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    7739  4).c_str(), nullptr, 16);
    7740 
    7741  // check if codepoint is a high surrogate
    7742  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    7743  {
    7744  // make sure there is a subsequent unicode
    7745  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    7746  {
    7747  throw std::invalid_argument("missing low surrogate");
    7748  }
    7749 
    7750  // get code yyyy from uxxxx\uyyyy
    7751  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    7752  (i + 7), 4).c_str(), nullptr, 16);
    7753  result += to_unicode(codepoint, codepoint2);
    7754  // skip the next 10 characters (xxxx\uyyyy)
    7755  i += 10;
    7756  }
    7757  else
    7758  {
    7759  // add unicode character(s)
    7760  result += to_unicode(codepoint);
    7761  // skip the next four characters (xxxx)
    7762  i += 4;
    7763  }
    7764  break;
    7765  }
    7766  }
    7767  }
    7768  else
    7769  {
    7770  // all other characters are just copied to the end of the
    7771  // string
    7772  result.append(1, static_cast<typename string_t::value_type>(*i));
    7773  }
    7774  }
    7775 
    7776  return result;
    7777  }
    7778 
    7799  long double str_to_float_t(long double* /* type */, char** endptr) const
    7800  {
    7801  return std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    7802  }
    7803 
    7805  double str_to_float_t(double*, char** endptr) const
    7806  {
    7807  return std::strtod(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    7808  }
    7809 
    7811  float str_to_float_t(float*, char** endptr) const
    7812  {
    7813  return std::strtof(reinterpret_cast<typename string_t::const_pointer>(m_start), endptr);
    7814  }
    7815 
    7833  number_float_t get_number() const
    7834  {
    7835  // conversion
    7836  typename string_t::value_type* endptr;
    7837  assert(m_start != nullptr);
    7838  number_float_t float_val = str_to_float_t(static_cast<number_float_t*>(nullptr), &endptr);
    7839 
    7840  // return float_val if the whole number was translated and NAN
    7841  // otherwise
    7842  return (reinterpret_cast<lexer_char_t*>(endptr) == m_cursor) ? float_val : NAN;
    7843  }
    7844 
    7845  private:
    7847  std::istream* m_stream = nullptr;
    7849  string_t m_buffer;
    7851  const lexer_char_t* m_content = nullptr;
    7853  const lexer_char_t* m_start = nullptr;
    7855  const lexer_char_t* m_marker = nullptr;
    7857  const lexer_char_t* m_cursor = nullptr;
    7859  const lexer_char_t* m_limit = nullptr;
    7860  };
    7861 
    7867  class parser
    7868  {
    7869  public:
    7871  parser(const string_t& s, parser_callback_t cb = nullptr)
    7872  : callback(cb), m_lexer(s)
    7873  {
    7874  // read first token
    7875  get_token();
    7876  }
    7877 
    7879  parser(std::istream& _is, parser_callback_t cb = nullptr)
    7880  : callback(cb), m_lexer(&_is)
    7881  {
    7882  // read first token
    7883  get_token();
    7884  }
    7885 
    7887  basic_json parse()
    7888  {
    7889  basic_json result = parse_internal(true);
    7890 
    7891  expect(lexer::token_type::end_of_input);
    7892 
    7893  // return parser result and replace it with null in case the
    7894  // top-level value was discarded by the callback function
    7895  return result.is_discarded() ? basic_json() : result;
    7896  }
    7897 
    7898  private:
    7900  basic_json parse_internal(bool keep)
    7901  {
    7902  auto result = basic_json(value_t::discarded);
    7903 
    7904  switch (last_token)
    7905  {
    7906  case lexer::token_type::begin_object:
    7907  {
    7908  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    7909  {
    7910  // explicitly set result to object to cope with {}
    7911  result.m_type = value_t::object;
    7912  result.m_value = json_value(value_t::object);
    7913  }
    7914 
    7915  // read next token
    7916  get_token();
    7917 
    7918  // closing } -> we are done
    7919  if (last_token == lexer::token_type::end_object)
    7920  {
    7921  get_token();
    7922  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    7923  {
    7924  result = basic_json(value_t::discarded);
    7925  }
    7926  return result;
    7927  }
    7928 
    7929  // no comma is expected here
    7930  unexpect(lexer::token_type::value_separator);
    7931 
    7932  // otherwise: parse key-value pairs
    7933  do
    7934  {
    7935  // ugly, but could be fixed with loop reorganization
    7936  if (last_token == lexer::token_type::value_separator)
    7937  {
    7938  get_token();
    7939  }
    7940 
    7941  // store key
    7942  expect(lexer::token_type::value_string);
    7943  const auto key = m_lexer.get_string();
    7944 
    7945  bool keep_tag = false;
    7946  if (keep)
    7947  {
    7948  if (callback)
    7949  {
    7950  basic_json k(key);
    7951  keep_tag = callback(depth, parse_event_t::key, k);
    7952  }
    7953  else
    7954  {
    7955  keep_tag = true;
    7956  }
    7957  }
    7958 
    7959  // parse separator (:)
    7960  get_token();
    7961  expect(lexer::token_type::name_separator);
    7962 
    7963  // parse and add value
    7964  get_token();
    7965  auto value = parse_internal(keep);
    7966  if (keep and keep_tag and not value.is_discarded())
    7967  {
    7968  result[key] = std::move(value);
    7969  }
    7970  }
    7971  while (last_token == lexer::token_type::value_separator);
    7972 
    7973  // closing }
    7974  expect(lexer::token_type::end_object);
    7975  get_token();
    7976  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    7977  {
    7978  result = basic_json(value_t::discarded);
    7979  }
    7980 
    7981  return result;
    7982  }
    7983 
    7984  case lexer::token_type::begin_array:
    7985  {
    7986  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    7987  {
    7988  // explicitly set result to object to cope with []
    7989  result.m_type = value_t::array;
    7990  result.m_value = json_value(value_t::array);
    7991  }
    7992 
    7993  // read next token
    7994  get_token();
    7995 
    7996  // closing ] -> we are done
    7997  if (last_token == lexer::token_type::end_array)
    7998  {
    7999  get_token();
    8000  if (callback and not callback(--depth, parse_event_t::array_end, result))
    8001  {
    8002  result = basic_json(value_t::discarded);
    8003  }
    8004  return result;
    8005  }
    8006 
    8007  // no comma is expected here
    8008  unexpect(lexer::token_type::value_separator);
    8009 
    8010  // otherwise: parse values
    8011  do
    8012  {
    8013  // ugly, but could be fixed with loop reorganization
    8014  if (last_token == lexer::token_type::value_separator)
    8015  {
    8016  get_token();
    8017  }
    8018 
    8019  // parse value
    8020  auto value = parse_internal(keep);
    8021  if (keep and not value.is_discarded())
    8022  {
    8023  result.push_back(std::move(value));
    8024  }
    8025  }
    8026  while (last_token == lexer::token_type::value_separator);
    8027 
    8028  // closing ]
    8029  expect(lexer::token_type::end_array);
    8030  get_token();
    8031  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    8032  {
    8033  result = basic_json(value_t::discarded);
    8034  }
    8035 
    8036  return result;
    8037  }
    8038 
    8039  case lexer::token_type::literal_null:
    8040  {
    8041  get_token();
    8042  result.m_type = value_t::null;
    8043  break;
    8044  }
    8045 
    8046  case lexer::token_type::value_string:
    8047  {
    8048  const auto s = m_lexer.get_string();
    8049  get_token();
    8050  result = basic_json(s);
    8051  break;
    8052  }
    8053 
    8054  case lexer::token_type::literal_true:
    8055  {
    8056  get_token();
    8057  result.m_type = value_t::boolean;
    8058  result.m_value = true;
    8059  break;
    8060  }
    8061 
    8062  case lexer::token_type::literal_false:
    8063  {
    8064  get_token();
    8065  result.m_type = value_t::boolean;
    8066  result.m_value = false;
    8067  break;
    8068  }
    8069 
    8070  case lexer::token_type::value_number:
    8071  {
    8072  result.m_value = m_lexer.get_number();
    8073 
    8074  // NAN is returned if token could not be translated
    8075  // completely
    8076  if (std::isnan(result.m_value.number_float))
    8077  {
    8078  throw std::invalid_argument(std::string("parse error - ") +
    8079  m_lexer.get_token() + " is not a number");
    8080  }
    8081 
    8082  get_token();
    8083 
    8084  // check if conversion loses precision (special case -0.0 always loses precision)
    8085  const auto int_val = static_cast<number_integer_t>(result.m_value.number_float);
    8086  if (result.m_value.number_float == static_cast<number_float_t>(int_val) and
    8087  result.m_value.number_integer != json_value(-0.0f).number_integer)
    8088  {
    8089  // we would not lose precision -> return int
    8090  result.m_type = value_t::number_integer;
    8091  result.m_value = int_val;
    8092  }
    8093  else
    8094  {
    8095  // we would lose precision -> return float
    8096  result.m_type = value_t::number_float;
    8097  }
    8098  break;
    8099  }
    8100 
    8101  default:
    8102  {
    8103  // the last token was unexpected
    8104  unexpect(last_token);
    8105  }
    8106  }
    8107 
    8108  if (keep and callback and not callback(depth, parse_event_t::value, result))
    8109  {
    8110  result = basic_json(value_t::discarded);
    8111  }
    8112  return result;
    8113  }
    8114 
    8116  typename lexer::token_type get_token()
    8117  {
    8118  last_token = m_lexer.scan();
    8119  return last_token;
    8120  }
    8121 
    8122  void expect(typename lexer::token_type t) const
    8123  {
    8124  if (t != last_token)
    8125  {
    8126  std::string error_msg = "parse error - unexpected ";
    8127  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8128  lexer::token_type_name(last_token));
    8129  error_msg += "; expected " + lexer::token_type_name(t);
    8130  throw std::invalid_argument(error_msg);
    8131  }
    8132  }
    8133 
    8134  void unexpect(typename lexer::token_type t) const
    8135  {
    8136  if (t == last_token)
    8137  {
    8138  std::string error_msg = "parse error - unexpected ";
    8139  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8140  lexer::token_type_name(last_token));
    8141  throw std::invalid_argument(error_msg);
    8142  }
    8143  }
    8144 
    8145  private:
    8147  int depth = 0;
    8149  parser_callback_t callback;
    8151  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8153  lexer m_lexer;
    8154  };
    8155 };
    8156 
    8157 
    8159 // presets //
    8161 
    8171 }
    8172 
    8173 
    8175 // nonmember functions //
    8177 
    8178 // specialization of std::swap, and std::hash
    8179 namespace std
    8180 {
    8186 template <>
    8187 inline void swap(nlohmann::json& j1,
    8188  nlohmann::json& j2) noexcept(
    8189  is_nothrow_move_constructible<nlohmann::json>::value and
    8190  is_nothrow_move_assignable<nlohmann::json>::value
    8191  )
    8192 {
    8193  j1.swap(j2);
    8194 }
    8195 
    8197 template <>
    8198 struct hash<nlohmann::json>
    8199 {
    8205  std::size_t operator()(const nlohmann::json& j) const
    8206  {
    8207  // a naive hashing via the string representation
    8208  const auto& h = hash<nlohmann::json::string_t>();
    8209  return h(j.dump());
    8210  }
    8211 };
    8212 }
    8213 
    8226 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8227 {
    8228  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8229 }
    8230 
    8231 // restore GCC/clang diagnostic settings
    8232 #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    8233  #pragma GCC diagnostic pop
    8234 #endif
    8235 
    8236 #endif
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6191
    +
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4463
    +
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6439
    +
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:5072
    +
    typename std::allocator_traits< allocator_type >::pointer pointer
    the type of an element pointer
    Definition: json.hpp:229
    +
    json_reverse_iterator operator-(difference_type i) const
    subtract from iterator
    Definition: json.hpp:6594
    +
    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:1519
    +
    const_reference operator[](size_type idx) const
    access specified array element
    Definition: json.hpp:2961
    +
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:5863
    +
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:3997
    +
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6132
    +
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5285
    +
    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:5932
    +
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:5859
    +
    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:1791
    +
    const_reference operator[](T *key) const
    read-only access specified object element
    Definition: json.hpp:3210
    +
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4545
    +
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4492
    +
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6566
    +
    StringType string_t
    a type for a string
    Definition: json.hpp:443
    +
    void push_back(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4384
    +
    basic_json(boolean_t val)
    create a boolean (explicit)
    Definition: json.hpp:1141
    +
    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:1479
    +
    iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6447
    +
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:4928
    +
    ArrayType< basic_json, AllocatorType< basic_json >> array_t
    a type for an array
    Definition: json.hpp:396
    +
    const_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6095
    +
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6602
    +
    basic_json<> json
    default JSON class
    Definition: json.hpp:8170
    +
    reference front()
    access the first element
    Definition: json.hpp:3328
    +
    bool is_array() const noexcept
    return whether value is an array
    Definition: json.hpp:2104
    +
    const_iterator find(typename object_t::key_type key) const
    find an element in a JSON object
    Definition: json.hpp:3708
    +
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6538
    +
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6543
    +
    a class to store JSON values
    Definition: json.hpp:191
    +
    json_reverse_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6572
    +
    basic_json(const object_t &val)
    create an object (explicit)
    Definition: json.hpp:943
    +
    friend bool operator==(std::nullptr_t, const_reference v) noexcept
    comparison: equal
    Definition: json.hpp:4907
    +
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4298
    +
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3808
    +
    reference operator[](T *key)
    access specified object element
    Definition: json.hpp:3161
    +
    bool is_string() const noexcept
    return whether value is a string
    Definition: json.hpp:2123
    +
    iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6469
    +
    const PointerType get_ptr() const noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2598
    +
    basic_json(const CompatibleStringType &val)
    create a string (implicit)
    Definition: json.hpp:1123
    +
    reference operator+=(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4324
    +
    basic_json(size_type cnt, const basic_json &val)
    construct an array with count copies of given value
    Definition: json.hpp:1543
    +
    a mutable random access iterator for the basic_json class
    Definition: json.hpp:6394
    +
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6476
    +
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5247
    +
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:3002
    STL namespace.
    -
    difference_type operator-(const iterator &other) const
    Definition: json.hpp:6478
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6350
    -
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:3996
    -
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3834
    -
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:5907
    -
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:2812
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6335
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3824
    -
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:341
    -
    reference operator*()
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6407
    -
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:3913
    -
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2076
    -
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6267
    -
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2138
    -
    basic_json(const CompatibleArrayType &val)
    create an array (implicit)
    Definition: json.hpp:1030
    -
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:5845
    -
    const_reverse_iterator rend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3921
    -
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3608
    -
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:1987
    -
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3765
    -
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:2860
    -
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4349
    -
    AllocatorType< basic_json > allocator_type
    the allocator type
    Definition: json.hpp:225
    -
    basic_json(const number_float_t val)
    create a floating-point number (explicit)
    Definition: json.hpp:1259
    -
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3084
    -
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2034
    -
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6463
    -
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:820
    -
    basic_json(const typename string_t::value_type *val)
    create a string (explicit)
    Definition: json.hpp:1083
    -
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3682
    -
    basic_json(const value_t value_type)
    create an empty value with a given type
    Definition: json.hpp:867
    -
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5109
    -
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6442
    -
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:4982
    -
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6032
    -
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3041
    -
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3858
    -
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6520
    -
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4098
    -
    static allocator_type get_allocator()
    returns the allocator associated with the container
    Definition: json.hpp:250
    +
    difference_type operator-(const iterator &other) const
    Definition: json.hpp:6498
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6370
    +
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:4005
    +
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3843
    +
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:5927
    +
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:2821
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6355
    +
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3833
    +
    ObjectType< StringType, basic_json, std::less< StringType >, AllocatorType< std::pair< const StringType, basic_json >>> object_t
    a type for an object
    Definition: json.hpp:350
    +
    reference operator*()
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6427
    +
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:3922
    +
    bool is_object() const noexcept
    return whether value is an object
    Definition: json.hpp:2085
    +
    const_iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6287
    +
    bool is_discarded() const noexcept
    return whether value is discarded
    Definition: json.hpp:2147
    +
    basic_json(const CompatibleArrayType &val)
    create an array (implicit)
    Definition: json.hpp:1039
    +
    typename basic_json::const_reference reference
    defines a reference to the type iterated over (value_type)
    Definition: json.hpp:5865
    +
    const_reverse_iterator rend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3930
    +
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3617
    +
    bool is_boolean() const noexcept
    return whether value is a boolean
    Definition: json.hpp:1996
    +
    iterator begin()
    returns an iterator to the first element
    Definition: json.hpp:3774
    +
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:2869
    +
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4358
    +
    AllocatorType< basic_json > allocator_type
    the allocator type
    Definition: json.hpp:226
    +
    basic_json(const number_float_t val)
    create a floating-point number (explicit)
    Definition: json.hpp:1268
    +
    reference operator[](T *(&key)[n])
    access specified object element
    Definition: json.hpp:3093
    +
    bool is_number_integer() const noexcept
    return whether value is an integer number
    Definition: json.hpp:2043
    +
    iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6483
    +
    std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t
    per-element parser callback type
    Definition: json.hpp:829
    +
    basic_json(const typename string_t::value_type *val)
    create a string (explicit)
    Definition: json.hpp:1092
    +
    iterator find(typename object_t::key_type key)
    find an element in a JSON object
    Definition: json.hpp:3691
    +
    basic_json(const value_t value_type)
    create an empty value with a given type
    Definition: json.hpp:876
    +
    friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than or equal
    Definition: json.hpp:5116
    +
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6462
    +
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:4989
    +
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:6052
    +
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3050
    +
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3867
    +
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6540
    +
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4107
    +
    static allocator_type get_allocator()
    returns the allocator associated with the container
    Definition: json.hpp:251
    object (unordered set of name/value pairs)
    -
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2625
    -
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2720
    -
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6528
    -
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:1908
    -
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5164
    -
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3268
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6594
    -
    bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:1949
    -
    namespace for Niels Lohmann
    Definition: json.hpp:79
    -
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:5841
    -
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:4663
    -
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:3882
    -
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4399
    -
    basic_json(const number_integer_t val)
    create an integer number (explicit)
    Definition: json.hpp:1166
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6484
    -
    std::size_t size_type
    a type to represent container sizes
    Definition: json.hpp:222
    -
    const_reverse_iterator rbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3890
    -
    ~basic_json()
    destructor
    Definition: json.hpp:1808
    -
    basic_json(const basic_json &other)
    copy constructor
    Definition: json.hpp:1683
    -
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6259
    -
    value_t
    the JSON type enumeration
    Definition: json.hpp:612
    -
    const value_type & const_reference
    the type of an element const reference
    Definition: json.hpp:216
    -
    basic_json(const CompatibleNumberIntegerType val) noexcept
    create an integer number (implicit)
    Definition: json.hpp:1230
    -
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2640
    -
    bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:1968
    -
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:4731
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6490
    -
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6104
    -
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2490
    -
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3646
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4219
    -
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6413
    -
    basic_json value_type
    the type of elements in a basic_json container
    Definition: json.hpp:210
    +
    ReferenceType get_ref()
    get a reference value (implicit)
    Definition: json.hpp:2634
    +
    reference at(size_type idx)
    access specified array element with bounds checking
    Definition: json.hpp:2729
    +
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6548
    +
    value_t type() const noexcept
    return the type of the JSON value (explicit)
    Definition: json.hpp:1917
    +
    friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
    serialize to stream
    Definition: json.hpp:5171
    +
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3277
    +
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6614
    +
    bool is_structured() const noexcept
    return whether type is structured
    Definition: json.hpp:1958
    +
    namespace for Niels Lohmann
    Definition: json.hpp:88
    +
    typename basic_json::difference_type difference_type
    a type to represent differences between iterators
    Definition: json.hpp:5861
    +
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:4672
    +
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:3891
    +
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4408
    +
    basic_json(const number_integer_t val)
    create an integer number (explicit)
    Definition: json.hpp:1175
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6504
    +
    std::size_t size_type
    a type to represent container sizes
    Definition: json.hpp:223
    +
    const_reverse_iterator rbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3899
    +
    ~basic_json()
    destructor
    Definition: json.hpp:1817
    +
    basic_json(const basic_json &other)
    copy constructor
    Definition: json.hpp:1692
    +
    const_iterator operator+(difference_type i)
    add to iterator
    Definition: json.hpp:6279
    +
    value_t
    the JSON type enumeration
    Definition: json.hpp:621
    +
    const value_type & const_reference
    the type of an element const reference
    Definition: json.hpp:218
    +
    basic_json(const CompatibleNumberIntegerType val) noexcept
    create an integer number (implicit)
    Definition: json.hpp:1239
    +
    ReferenceType get_ref() const
    get a reference value (implicit)
    Definition: json.hpp:2649
    +
    bool is_null() const noexcept
    return whether value is null
    Definition: json.hpp:1977
    +
    void swap(string_t &other)
    exchanges the values
    Definition: json.hpp:4740
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6510
    +
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6124
    +
    ValueType get() const
    get a value (explicit)
    Definition: json.hpp:2499
    +
    void erase(const size_type idx)
    remove element from a JSON array given an index
    Definition: json.hpp:3655
    +
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4228
    +
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6433
    +
    basic_json value_type
    the type of elements in a basic_json container
    Definition: json.hpp:213
    array (ordered collection of values)
    -
    const_reference front() const
    access the first element
    Definition: json.hpp:3327
    -
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6219
    -
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4594
    -
    std::ptrdiff_t difference_type
    a type to represent differences between iterators
    Definition: json.hpp:219
    -
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6225
    -
    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:1378
    -
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6275
    -
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:4811
    -
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2011
    -
    BooleanType boolean_t
    a type for a boolean
    Definition: json.hpp:460
    -
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3967
    -
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4040
    -
    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:3294
    -
    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:4632
    -
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3119
    -
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3944
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6601
    +
    const_reference front() const
    access the first element
    Definition: json.hpp:3336
    +
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6239
    +
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4603
    +
    std::ptrdiff_t difference_type
    a type to represent differences between iterators
    Definition: json.hpp:221
    +
    const_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6245
    +
    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:1387
    +
    difference_type operator-(const const_iterator &other) const
    return difference
    Definition: json.hpp:6295
    +
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:4820
    +
    bool is_number() const noexcept
    return whether value is a number
    Definition: json.hpp:2020
    +
    BooleanType boolean_t
    a type for a boolean
    Definition: json.hpp:469
    +
    const_reverse_iterator crend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3976
    +
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:4049
    +
    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:3303
    +
    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:4641
    +
    const_reference operator[](T *(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3128
    +
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3953
    +
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6621
    -
    const_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:5853
    -
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:4765
    -
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6385
    -
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6177
    -
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:1877
    -
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:4944
    -
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6253
    -
    basic_json(const int val)
    create an integer number from an enum type (explicit)
    Definition: json.hpp:1195
    -
    basic_json(const array_t &val)
    create an array (explicit)
    Definition: json.hpp:993
    -
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5203
    -
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3525
    -
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6533
    -
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2574
    -
    const_iterator(const iterator &other)
    copy constructor given a nonconst iterator
    Definition: json.hpp:5880
    -
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:4953
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3420
    -
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6207
    -
    basic_json(const CompatibleNumberFloatType val) noexcept
    create an floating-point number (implicit)
    Definition: json.hpp:1305
    -
    reference back()
    access the last element
    Definition: json.hpp:3353
    -
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2057
    -
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6067
    -
    typename std::allocator_traits< allocator_type >::const_pointer const_pointer
    the type of an element const pointer
    Definition: json.hpp:230
    -
    basic_json(const string_t &val)
    create a string (explicit)
    Definition: json.hpp:1059
    -
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6390
    -
    const_reference back() const
    access the last element
    Definition: json.hpp:3363
    -
    basic_json(InputIT first, InputIT last)
    construct a JSON container given an iterator range
    Definition: json.hpp:1580
    -
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5232
    -
    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:3730
    -
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4160
    -
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4325
    -
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6141
    -
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6539
    -
    basic_json(std::nullptr_t) noexcept
    create a null object (explicitly)
    Definition: json.hpp:911
    -
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6213
    -
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5087
    -
    basic_json(basic_json &&other) noexcept
    move constructor
    Definition: json.hpp:1752
    -
    const_iterator begin() const
    returns a const iterator to the first element
    Definition: json.hpp:3775
    -
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:2764
    -
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6559
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:5832
    -
    a template for a reverse iterator class
    Definition: json.hpp:233
    -
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:4697
    -
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:5847
    -
    bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:1929
    -
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4427
    -
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:4891
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6588
    -
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:528
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6299
    -
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:5992
    -
    value_type & reference
    the type of an element reference
    Definition: json.hpp:213
    -
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5268
    -
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:593
    -
    std::size_t operator()(const nlohmann::json &j) const
    return a hash value for a JSON object
    Definition: json.hpp:8149
    -
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5146
    -
    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:6395
    -
    basic_json(const CompatibleObjectType &val)
    create an object (implicit)
    Definition: json.hpp:966
    -
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:2907
    -
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6434
    -
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6566
    -
    parse_event_t
    JSON callback events.
    Definition: json.hpp:755
    -
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6471
    +
    const_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:5873
    +
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:4774
    +
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6405
    +
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6197
    +
    string_t dump(const int indent=-1) const
    serialization
    Definition: json.hpp:1886
    +
    friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    comparison: not equal
    Definition: json.hpp:4951
    +
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6273
    +
    basic_json(const int val)
    create an integer number from an enum type (explicit)
    Definition: json.hpp:1204
    +
    basic_json(const array_t &val)
    create an array (explicit)
    Definition: json.hpp:1002
    +
    static basic_json parse(const string_t &s, parser_callback_t cb=nullptr)
    deserialize from string
    Definition: json.hpp:5210
    +
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3534
    +
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6553
    +
    PointerType get_ptr() noexcept
    get a pointer value (implicit)
    Definition: json.hpp:2583
    +
    const_iterator(const iterator &other)
    copy constructor given a nonconst iterator
    Definition: json.hpp:5900
    +
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:4960
    +
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3429
    +
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6227
    +
    basic_json(const CompatibleNumberFloatType val) noexcept
    create an floating-point number (implicit)
    Definition: json.hpp:1314
    +
    reference back()
    access the last element
    Definition: json.hpp:3362
    +
    bool is_number_float() const noexcept
    return whether value is a floating-point number
    Definition: json.hpp:2066
    +
    const_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6087
    +
    typename std::allocator_traits< allocator_type >::const_pointer const_pointer
    the type of an element const pointer
    Definition: json.hpp:231
    +
    basic_json(const string_t &val)
    create a string (explicit)
    Definition: json.hpp:1068
    +
    iterator(const iterator &other) noexcept
    copy constructor
    Definition: json.hpp:6410
    +
    const_reference back() const
    access the last element
    Definition: json.hpp:3372
    +
    basic_json(InputIT first, InputIT last)
    construct a JSON container given an iterator range
    Definition: json.hpp:1589
    +
    static basic_json parse(std::istream &i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5239
    +
    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:3739
    +
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4169
    +
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4334
    +
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6161
    +
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6559
    +
    basic_json(std::nullptr_t) noexcept
    create a null object (explicitly)
    Definition: json.hpp:920
    +
    bool operator>(const const_iterator &other) const
    comparison: greater than
    Definition: json.hpp:6233
    +
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5094
    +
    basic_json(basic_json &&other) noexcept
    move constructor
    Definition: json.hpp:1761
    +
    const_iterator begin() const
    returns a const iterator to the first element
    Definition: json.hpp:3784
    +
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:2773
    +
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6579
    +
    a const random access iterator for the basic_json class
    Definition: json.hpp:5852
    +
    a template for a reverse iterator class
    Definition: json.hpp:234
    +
    void swap(object_t &other)
    exchanges the values
    Definition: json.hpp:4706
    +
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:5867
    +
    bool is_primitive() const noexcept
    return whether type is primitive
    Definition: json.hpp:1938
    +
    iterator insert(const_iterator pos, const basic_json &val)
    inserts element
    Definition: json.hpp:4436
    +
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:4898
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6608
    +
    NumberIntegerType number_integer_t
    a type for a number (integer)
    Definition: json.hpp:537
    +
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6319
    +
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:6012
    +
    value_type & reference
    the type of an element reference
    Definition: json.hpp:216
    +
    friend std::istream & operator<<(basic_json &j, std::istream &i)
    deserialize from stream
    Definition: json.hpp:5275
    +
    NumberFloatType number_float_t
    a type for a number (floating-point)
    Definition: json.hpp:602
    +
    std::size_t operator()(const nlohmann::json &j) const
    return a hash value for a JSON object
    Definition: json.hpp:8205
    +
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5153
    +
    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:6415
    +
    basic_json(const CompatibleObjectType &val)
    create an object (implicit)
    Definition: json.hpp:975
    +
    reference operator[](size_type idx)
    access specified array element
    Definition: json.hpp:2916
    +
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6454
    +
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6586
    +
    parse_event_t
    JSON callback events.
    Definition: json.hpp:764
    +
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6491
    diff --git a/namespacemembers.html b/namespacemembers.html index 5e3ce211a..79a1d7d26 100644 --- a/namespacemembers.html +++ b/namespacemembers.html @@ -94,7 +94,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    diff --git a/namespacemembers_type.html b/namespacemembers_type.html index 8b6d886cf..c39995823 100644 --- a/namespacemembers_type.html +++ b/namespacemembers_type.html @@ -94,7 +94,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/namespacenlohmann.html b/namespacenlohmann.html index 5b8f03901..d47c55155 100644 --- a/namespacenlohmann.html +++ b/namespacenlohmann.html @@ -116,7 +116,7 @@ Typedefs diff --git a/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html b/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html index b844dd8ee..a230de5d3 100644 --- a/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html +++ b/namespacenlohmann_1_1anonymous__namespace_02json_8hpp_03.html @@ -105,7 +105,7 @@ Classes diff --git a/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html b/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html index ff4e26c55..89381c4f9 100644 --- a/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html +++ b/namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

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

    Since
    version 1.0.0
    -

    Definition at line 8114 of file json.hpp.

    +

    Definition at line 8170 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 c320a3bd3..bf1b9b80b 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4-members.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4-members.html @@ -98,7 +98,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html b/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html index a65dca5db..399ae4e32 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4.html @@ -111,11 +111,11 @@ Public Member Functions struct std::hash< nlohmann::json > -

    Definition at line 8142 of file json.hpp.

    +

    Definition at line 8198 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 c9b64c691..14167ad17 100644 --- a/structstd_1_1hash_3_01nlohmann_1_1json_01_4_afd03f6ad53db22868ca4163a8200b2f9.html +++ b/structstd_1_1hash_3_01nlohmann_1_1json_01_4_afd03f6ad53db22868ca4163a8200b2f9.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    Since
    version 1.0.0
    -

    Definition at line 8149 of file json.hpp.

    +

    Definition at line 8205 of file json.hpp.

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