From 67a54a4a08bcfd4d6271ace02a5729fe7e6d6c73 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 24 Jan 2016 11:12:02 +0100 Subject: [PATCH] Update --- Nodes.xml | 18 +- Tokens.xml | 32 +- annotated.html | 2 +- classes.html | 2 +- classnlohmann_1_1basic__json-members.html | 8 +- classnlohmann_1_1basic__json.html | 28 +- ...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 | 2 +- ...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 | 12 +- ...son_a0703ae5cbd2daac5e6c0ae01d3a1b114.html | 12 +- ...son_a07c9c38a1f01675759e05d5d34627343.html | 14 +- ...son_a088460b5d95f384a4f2ec9e52f4f66ba.html | 8 +- ...son_a0afa4512f03406db0d0432657e9c7361.html | 8 +- ...son_a0ff73601e88f8ace62ff0b453ebb9043.html | 317 ++++++++++++++++++ ...son_a114095c452ca2f4ba976548df3da68be.html | 8 +- ...son_a11c3dd843c21c58daa651e84046a82af.html | 8 +- ...son_a122640e7e2db1814fc7bbb3c122ec76e.html | 10 +- ...son_a13e5642dbfa1602c937d295a085413cc.html | 8 +- ...son_a1683189bd539313b5559f07961166c8b.html | 8 +- ...son_a16a275d0201e9aedc87c933c764b8869.html | 12 +- ...son_a1b058496e6a67565a096233cd113505b.html | 8 +- ...son_a1dc0c521042807e216d11110d2f002ff.html | 8 +- ...son_a231b02148577b69a154b2ce2c87a5522.html | 8 +- ...son_a234f03dce002783748ca401a42bc6472.html | 8 +- ...son_a26b7e4876af25eae5800ce43f93aaef2.html | 12 +- ...son_a2adfc8d24bea3908398cbf325b5dc1d7.html | 12 +- ...son_a2f07bcf7e75c34396476dd1790f26ce8.html | 12 +- ...son_a2f1f7ca08995781acb63bd66b26ad1c1.html | 8 +- ...son_a3173944e7b1809a333def4078a0b92a3.html | 12 +- ...son_a317b01b0fba3ac458561f1634759ea3b.html | 10 +- ...son_a3287df6546c905fb0a5786deb4b1cf32.html | 12 +- ...son_a33f1632cfdbf460b4913f4e8a43dd9e4.html | 8 +- ...son_a34d6a60dd99e9f33b8273a1c8db5669b.html | 10 +- ...son_a3d4e4bab95b24ccab42ed37e0ede2d98.html | 8 +- ...son_a42f9133f978dde4cce5851b2c2434a0c.html | 8 +- ...son_a4361aa791f3980abb239e4155a3450cb.html | 14 +- ...son_a457fec897d7b6283c60ca236ebb1f5e8.html | 8 +- ...son_a48c8d153bc2fd1af655063a4b984feac.html | 8 +- ...son_a4943b7f16ddc4e0df33c0cae7ef14471.html | 12 +- ...son_a4ad3f27ecece8f644e8dca69a97eb67f.html | 12 +- ...son_a4bf695ddf4a00ea8feea2c725ec847f1.html | 12 +- ...son_a4d688b5ff534d3ab4e284b3191061529.html | 12 +- ...son_a5114ed5eb394a2805da0bd1acba95ae2.html | 12 +- ...son_a53a2abfdd4f72c7df5aba1155bf03e48.html | 8 +- ...son_a57703688bee6b9736ab3a430d8d246f2.html | 10 +- ...son_a57a96ab3ff1ce7b48a754129fb12c982.html | 12 +- ...son_a5a2d4dbcdbc8ea065b87daf52cd786b9.html | 8 +- ...son_a5c8bb5200f5eac10d31e26be46e5b1ac.html | 10 +- ...son_a5d428360d75a52f6af74751d1cc912c6.html | 8 +- ...son_a5e34c5435e557d0bf666bd7311211405.html | 10 +- ...son_a5f0aad50ed7e8aec3128fe018c18b3fe.html | 8 +- ...son_a5fd8b54389698edf0c08e2dd001f610b.html | 8 +- ...son_a60ca396028b8d9714c6e10efbf475af6.html | 10 +- ...son_a63691315292df8e1522b00d37ebb1ffc.html | 8 +- ...son_a652414dd930cb3af3b6f454cc535a23e.html | 12 +- ...son_a656939a3dc9a6047e4afacd9e11b83a6.html | 8 +- ...son_a66f936cfbd252f85bd3dc2598e37a64b.html | 12 +- ...son_a6944904b3b59769b1cf62ac2532cbe33.html | 8 +- ...son_a696ced74d8edc0b63a000a72907ab109.html | 8 +- ...son_a6a7f45095675ac6fd1d018a0e41874be.html | 14 +- ...son_a6b7428e8c1169497f47b81667001cbfb.html | 14 +- ...son_a6bbd3e72a870f1ba81ff6886b063b0fe.html | 8 +- ...son_a6dff6a02a2be250b8f8dc2f47be65544.html | 12 +- ...son_a6e2e21da48f5d9471716cd868a068327.html | 10 +- ...son_a71eba33d906745e66f340952b79fbce3.html | 8 +- ...son_a72442ccbb378b4464a24a2da1e784041.html | 12 +- ...son_a72ba20783ecb3eec98bd6a3b870d565c.html | 14 +- ...son_a74472977b798c7b7989e6e7cb960ecff.html | 8 +- ...son_a74a943800c7f103d0990d7eef82c6453.html | 10 +- ...son_a74ccfa471a0c061876b247f820f3c741.html | 16 +- ...son_a75a1754e0d39f33095d3102a8bdb9881.html | 16 +- ...son_a76cfc5062bf6223396ab82c753cd4634.html | 8 +- ...son_a7c08f966200af98db0313a3b517ce0a9.html | 12 +- ...son_a7c19a5c3be6cc755377ee41eade78baf.html | 14 +- ...son_a7d0db3b728d820d4984df78d97d2b104.html | 8 +- ...son_a7d1b990f2c12fecb57db1504fdadd0bb.html | 12 +- ...son_a7dab69b10b98e7bc694339720e37fb2b.html | 14 +- ...son_a7f97a91ad8f1d5cf0b9213bd24f247c4.html | 10 +- ...son_a80ceaa3bdd346292273b309e08525c1c.html | 8 +- ...son_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html | 12 +- ...son_a87db51b6b936fb2ea293cdbc8702dcb8.html | 10 +- ...son_a8b526709d395142b68d21abfbfff17c3.html | 12 +- ...son_a8c40cd9ead4de7c82f28268bdf0ec98a.html | 12 +- ...son_a8e34088252a3ee6b2377f3a1f26dd1ba.html | 10 +- ...son_a8e4e11999b4e7faa8f31f21164ebd65a.html | 10 +- ...son_a8fa74698f4061e18ec664009f3af1ddf.html | 16 +- ...son_a930e14150ffa067bcf56d35cb00271e1.html | 8 +- ...son_a960962c683909619d1d2fbbe856c022e.html | 12 +- ...son_a9730b9f7bc2150e641fe20198d4477c7.html | 10 +- ...son_a98e05a2c9b8f74bd60442772cddeee52.html | 10 +- ...son_a9993148cb0473365e52998c7315f9ada.html | 8 +- ...son_a9a73d1b71c9e913aa2888d8b40c72ee9.html | 10 +- ...son_a9c26c5d0f4a519c7236149b9aeb3ef9e.html | 8 +- ...son_a9f17a0690155e3a5603246ccec81499e.html | 8 +- ...son_aa0422e861b4cbd7cdcaad7a11a1304a9.html | 16 +- ...son_aa1f3b3f1dca79392d6727b81f9668c6c.html | 12 +- ...son_aa5413178b8041f7ac685dec4b040dd2c.html | 14 +- ...son_aa6a24b176f9599a21d662cc5f8e1ca76.html | 8 +- ...son_aa6c32f669a2e523666072003d0ea46f4.html | 8 +- ...son_aa71e977d31f470689883ac60d16ea4ac.html | 12 +- ...son_aabe4661644ea549089f0886c2551d2ac.html | 8 +- ...son_aac185a137428a7337aa620de07bfbbd7.html | 10 +- ...son_aacd442b66140c764c594ac8ad7dfd5b3.html | 10 +- ...son_aacf6c869f6a9c66ac1bc99e93f310044.html | 8 +- ...son_aad7eff162b0b991ef233503c592c1e2a.html | 301 +++++++++++++++++ ...son_aaf363408931d76472ded14017e59c9e8.html | 10 +- ...son_aafa839f2a74dc1b5060314b3423143b8.html | 8 +- ...son_ab14e3503305622fb5ab01a7f490916e8.html | 14 +- ...son_ab2162bc76e10d8736cab9b2039956054.html | 14 +- ...son_ab74b2398f29acc6ffbf48f1b8974a848.html | 8 +- ...son_ab7d60fb6cb8e8f5740e588f9dc953819.html | 8 +- ...son_ab9a20bd1d391e9cb968db50c246f728d.html | 12 +- ...son_ab9da2afc6f77295f25252725fde142a6.html | 12 +- ...son_abe8f3224ca4041908ddb466cb9caecf1.html | 12 +- ...son_ac160789f17d206a5404981ca0957e303.html | 8 +- ...son_ac4011bd0781e51afe4994d2b09fd27e9.html | 8 +- ...son_ac8163abe518595f19dbee68db1caaaf7.html | 8 +- ...son_ac82abedf356d252e0589850c3d8b35ba.html | 8 +- ...son_ac943391891fcde0a71a15ce990e0f7f4.html | 8 +- ...son_acd08f9179c8c1e9f2cd7575a724ce27e.html | 8 +- ...son_acdf4445333649ec94198f09a62144884.html | 14 +- ...son_ace8338e57fdb11e1955c2a0c2d782069.html | 8 +- ...son_ad1f617d29e8923dd40c89153f792b1bc.html | 8 +- ...son_ad2c4513cef5d8db760c4b2d871eea42c.html | 8 +- ...son_ad497cbc4f80c8d79662ee6e19bf145dd.html | 18 +- ...son_ad6734c2b91b1b77aa2b43b65c3619c05.html | 8 +- ...son_ad8e0c5d04f016d1b3ac7369e5c73bedf.html | 14 +- ...son_ada8e01109a60088e4db2a670d4903b54.html | 12 +- ...son_adbd4c16c9ac641b2a4736bc2c6787d83.html | 8 +- ...son_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html | 317 ++++++++++++++++++ ...son_ade7bd6e0fe221fec9d3fa9b430f5ce76.html | 8 +- ...son_adeaef2ab021997a11a826c378c2365e1.html | 8 +- ...son_adf5dea6fa9d7075ff89ca0796ab47a7e.html | 8 +- ...son_ae347859ec88176ef76a0cbe5b4514fcf.html | 10 +- ...son_ae50f22a1c646b8627e88f1313cceffd4.html | 8 +- ...son_ae7e36437700ef7353ad9961c8dd16a95.html | 300 +++++++++++++++++ ...son_ae874cfc1746b560c53a03bcf5b7bbeed.html | 8 +- ...son_ae928414b2805cf6ef56b4e4f8d235416.html | 8 +- ...son_ae960d2d6bc7b94fe39cc5e9f106edfa9.html | 12 +- ...son_aea1c863b719b4ca5b77188c171bbfafe.html | 8 +- ...son_af073eec08d2e68924098aef09e9a10ba.html | 12 +- ...son_af0ebd1757acb971a6504b4acabf88584.html | 12 +- ...son_af127fb69c580c17821da5f5be57e3585.html | 8 +- ...son_af1e3f9e079136abca2530c8191c56292.html | 10 +- ...son_af2730bc8ffa6b28916875c13ee7b83f5.html | 14 +- ...son_af661bc209bf22097e2f76607a11b56bf.html | 8 +- ...son_af6b6050ccd906dddf7c9f47fe3ad62a5.html | 12 +- ...son_af709c079de0ac3507143ea2c60699bd0.html | 12 +- ...son_af74581d177dafc38df5a126ccd358999.html | 10 +- ...son_af7d0adc984d04fc70c3d29fcd63e096a.html | 14 +- ...son_afc4223b5ad03b1b76e925374a8fff98e.html | 8 +- 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 | 4 +- 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 | 10 +- 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 | 280 ++++++++-------- namespacemembers.html | 2 +- namespacemembers_type.html | 2 +- namespacenlohmann.html | 2 +- ..._1anonymous__namespace_02json_8hpp_03.html | 2 +- ...ann_a2bfd99e845a2e5cd90aeaf1b1431f474.html | 4 +- search/all_d.js | 2 +- search/functions_b.js | 2 +- ...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 +- 259 files changed, 2476 insertions(+), 917 deletions(-) create mode 100644 classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html create mode 100644 classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html create mode 100644 classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html create mode 100644 classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html diff --git a/Nodes.xml b/Nodes.xml index cc041899d..77e257265 100644 --- a/Nodes.xml +++ b/Nodes.xml @@ -989,13 +989,23 @@ operator[] - classnlohmann_1_1basic__json_a266c4dd24d11a86e4831523af5d9df4d.html - a266c4dd24d11a86e4831523af5d9df4d + classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html + adc5605cf6f8ff0cc6c3bb04a5d7c2f2d operator[] - classnlohmann_1_1basic__json_a9daafb4c15ed5a008cb825bbd8c29d87.html - a9daafb4c15ed5a008cb825bbd8c29d87 + classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html + aad7eff162b0b991ef233503c592c1e2a + + + operator[] + classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html + a0ff73601e88f8ace62ff0b453ebb9043 + + + operator[] + classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html + ae7e36437700ef7353ad9961c8dd16a95 parse diff --git a/Tokens.xml b/Tokens.xml index 0a5661b94..33b3c184a 100644 --- a/Tokens.xml +++ b/Tokens.xml @@ -899,8 +899,8 @@ instm nlohmann::basic_json - classnlohmann_1_1basic__json_a266c4dd24d11a86e4831523af5d9df4d.html - a266c4dd24d11a86e4831523af5d9df4d + classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html + adc5605cf6f8ff0cc6c3bb04a5d7c2f2d access specified object element json.hpp @@ -911,8 +911,32 @@ instm nlohmann::basic_json - classnlohmann_1_1basic__json_a9daafb4c15ed5a008cb825bbd8c29d87.html - a9daafb4c15ed5a008cb825bbd8c29d87 + classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html + aad7eff162b0b991ef233503c592c1e2a + read-only access specified object element + json.hpp + + + + operator[] + cpp + instm + nlohmann::basic_json + + classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html + a0ff73601e88f8ace62ff0b453ebb9043 + access specified object element + json.hpp + + + + operator[] + cpp + instm + nlohmann::basic_json + + classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html + ae7e36437700ef7353ad9961c8dd16a95 read-only access specified object element json.hpp diff --git a/annotated.html b/annotated.html index d58d642de..feddffdcf 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 0ae73d80d..87f2543dc 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 42be24f8f..f2410aba8 100644 --- a/classnlohmann_1_1basic__json-members.html +++ b/classnlohmann_1_1basic__json-members.html @@ -205,8 +205,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[](size_type idx) const nlohmann::basic_jsoninline operator[](const typename object_t::key_type &key)nlohmann::basic_jsoninline operator[](const typename object_t::key_type &key) const nlohmann::basic_jsoninline - operator[](const T(&key)[n])nlohmann::basic_jsoninline - operator[](const T(&key)[n]) const nlohmann::basic_jsoninline + operator[](T *(&key)[n])nlohmann::basic_jsoninline + operator[](T *(&key)[n]) const nlohmann::basic_jsoninline + operator[](T *key)nlohmann::basic_jsoninline + operator[](T *key) const nlohmann::basic_jsoninline parse(const string_t &s, parser_callback_t cb=nullptr)nlohmann::basic_jsoninlinestatic parse(std::istream &i, parser_callback_t cb=nullptr)nlohmann::basic_jsoninlinestatic parse(std::istream &&i, parser_callback_t cb=nullptr)nlohmann::basic_jsoninlinestatic @@ -238,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 fb9a3e9cd..0df9ca799 100644 --- a/classnlohmann_1_1basic__json.html +++ b/classnlohmann_1_1basic__json.html @@ -366,7 +366,7 @@ value access ReferenceType get_ref () const  get a reference value (implicit) More...
  -template<typename ValueType , typename std::enable_if< not std::is_pointer< ValueType >::value and not std::is_same< ValueType, typename string_t::value_type >::value and not std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>::value , int >::type = 0> +template<typename ValueType , typename std::enable_if< not std::is_pointer< ValueType >::value and not std::is_same< ValueType, typename string_t::value_type >::value and not std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>::value , int >::type = 0>  operator ValueType () const  get a value (implicit) More...
  @@ -397,14 +397,22 @@ element access const_reference operator[] (const typename object_t::key_type &key) const  read-only access specified object element More...
  -template<typename T , std::size_t n> -reference operator[] (const T(&key)[n]) - access specified object element More...
-  -template<typename T , std::size_t n> -const_reference operator[] (const T(&key)[n]) const - read-only access specified object element More...
-  +template<typename T , std::size_t n> +reference operator[] (T *(&key)[n]) + access specified object element More...
+  +template<typename T , std::size_t n> +const_reference operator[] (T *(&key)[n]) const + read-only access specified object element More...
+  +template<typename T > +reference operator[] (T *key) + access specified object element More...
+  +template<typename T > +const_reference operator[] (T *key) const + read-only access specified object element More...
+  template<class ValueType , typename std::enable_if< std::is_convertible< basic_json_t, ValueType >::value , int >::type = 0> ValueType value (const typename object_t::key_type &key, ValueType default_value) const  access specified object element with default value More...
@@ -670,7 +678,7 @@ class nlohmann::basic_json diff --git a/classnlohmann_1_1basic__json_1_1const__iterator-members.html b/classnlohmann_1_1basic__json_1_1const__iterator-members.html index 959f8848b..baa7f0239 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 02fe77f70..4a08f771f 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 5766 of file json.hpp.

+

Definition at line 5832 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 09de0b7a3..e5240d596 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 6038 of file json.hpp.

+

Definition at line 6104 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 421ad6078..453b24216 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 6147 of file json.hpp.

+

Definition at line 6213 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 8594721ac..d0a4cf4f4 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 6233 of file json.hpp.

+

Definition at line 6299 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 b27391a46..e0027b154 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 5846 of file json.hpp.

+

Definition at line 5912 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 3619ca0a1..2840a0258 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 5966 of file json.hpp.

+

Definition at line 6032 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 a97a7aca1..7ea640b74 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 6075 of file json.hpp.

+

Definition at line 6141 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 f59b57599..12c0f7285 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 5926 of file json.hpp.

+

Definition at line 5992 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 03e1c606d..c43aa5f38 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 5777 of file json.hpp.

+

Definition at line 5843 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 000b15091..7fbb2cf36 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 5814 of file json.hpp.

+

Definition at line 5880 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 bf9148ed8..aaa921b79 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 6201 of file json.hpp.

+

Definition at line 6267 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 9d3f82b86..a40158e6a 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 5773 of file json.hpp.

+

Definition at line 5839 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 e2932acd6..b72b7de70 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 6153 of file json.hpp.

+

Definition at line 6219 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 a91aca028..0db82635e 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 5787 of file json.hpp.

+

Definition at line 5853 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 d6769e74d..ad9d838ac 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 0e90b7c1a..cf03845c0 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 6269 of file json.hpp.

+

Definition at line 6335 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 b188aa72a..746145126 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 6159 of file json.hpp.

+

Definition at line 6225 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 24bdba3be..0d84e7e10 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 6284 of file json.hpp.

+

Definition at line 6350 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 fba416eec..1351132a5 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 6105 of file json.hpp.

+

Definition at line 6171 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 3463102b7..23650c8e1 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 6046 of file json.hpp.

+

Definition at line 6112 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 98ef59cb2..9a2a51f91 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 6009 of file json.hpp.

+

Definition at line 6075 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 7b2c3255f..e11ea6765 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 5775 of file json.hpp.

+

Definition at line 5841 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 bb77df581..1e3f7dd1c 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 6193 of file json.hpp.

+

Definition at line 6259 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 a5e91cf25..31d594f04 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 6111 of file json.hpp.

+

Definition at line 6177 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 80ea012b1..d1a3776d7 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 5769 of file json.hpp.

+

Definition at line 5835 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 6d93d5190..578a1a91f 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 5779 of file json.hpp.

+

Definition at line 5845 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 560ed8aae..bad553415 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 6209 of file json.hpp.

+

Definition at line 6275 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 5d5eb9310..93297dfee 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 6001 of file json.hpp.

+

Definition at line 6067 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 87c582571..da1a7e89f 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 5781 of file json.hpp.

+

Definition at line 5847 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 0ff6d1a51..0dfeb1585 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 6141 of file json.hpp.

+

Definition at line 6207 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 e0f91828b..7ec51dd54 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 6187 of file json.hpp.

+

Definition at line 6253 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 dd2bbc03f..3f9b8c168 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 5841 of file json.hpp.

+

Definition at line 5907 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 fa1b6c825..16966aedb 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 3b37900f0..fbe7bd57d 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 6308 of file json.hpp.

+

Definition at line 6374 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 bce462ea9..eb1e14fa7 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 6361 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_a0a43bd93e6e46645ed0b93d3af7bfe22.html b/classnlohmann_1_1basic__json_1_1iterator_a0a43bd93e6e46645ed0b93d3af7bfe22.html index 30ce1c629..d6b56e228 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 6390 of file json.hpp.

+

Definition at line 6456 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 f34564583..d25193e92 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 6405 of file json.hpp.

+

Definition at line 6471 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 17491c062..a258179da 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 6418 of file json.hpp.

+

Definition at line 6484 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 baca0671c..ece7f26bf 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 6347 of file json.hpp.

+

Definition at line 6413 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 2c1b96946..95f0a5b2f 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 6376 of file json.hpp.

+

Definition at line 6442 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 cf9e31515..9b7a69ec2 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 6412 of file json.hpp.

+

Definition at line 6478 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 005169cd8..849e59a5a 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 6341 of file json.hpp.

+

Definition at line 6407 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 781abb236..5ae566336 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 6368 of file json.hpp.

+

Definition at line 6434 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 2909baa33..6a3fd912f 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 7346f2d0b..c202c34d5 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 6329 of file json.hpp.

+

Definition at line 6395 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 a0a636a08..49fc506cf 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 6383 of file json.hpp.

+

Definition at line 6449 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 910b59afb..3b7405f31 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 6324 of file json.hpp.

+

Definition at line 6390 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 36e147b0f..4eba072fe 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 6353 of file json.hpp.

+

Definition at line 6419 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 4a833e3b8..a717ff799 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 6313 of file json.hpp.

+

Definition at line 6379 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 8d11bddee..f76cbd9eb 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 6319 of file json.hpp.

+

Definition at line 6385 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 a43d04e8e..e45f4e2be 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 6397 of file json.hpp.

+

Definition at line 6463 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 560871e05..07012287a 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 6311 of file json.hpp.

+

Definition at line 6377 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 31fc5c285..545998506 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 6424 of file json.hpp.

+

Definition at line 6490 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 7f969eab5..516615abc 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 6312 of file json.hpp.

+

Definition at line 6378 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 8a0958b57..986e01ce3 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 00e8b0e4f..ae5a44c9e 100644 --- a/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html +++ b/classnlohmann_1_1basic__json_1_1json__reverse__iterator.html @@ -174,7 +174,7 @@ class nlohmann::basic_json::json_reverse_iterator< Base > diff --git a/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a03e542423284327d3801cf078f1c2b44.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a03e542423284327d3801cf078f1c2b44.html index 11df95cde..2c1282097 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 6508 of file json.hpp.

+

Definition at line 6574 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 df05be1a4..744049a59 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 6457 of file json.hpp.

+

Definition at line 6523 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 e5030a854..4bc0d1efd 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 6473 of file json.hpp.

+

Definition at line 6539 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 ca8f6f4b3..47968bf45 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 6500 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_a2a1dc92fbec862883c8b89755c787c99.html b/classnlohmann_1_1basic__json_1_1json__reverse__iterator_a2a1dc92fbec862883c8b89755c787c99.html index 212cbf5e6..432aa21ef 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 6493 of file json.hpp.

+

Definition at line 6559 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 9ca2ac02d..2b8e53645 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 6454 of file json.hpp.

+

Definition at line 6520 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 f17072e74..d097a1823 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 6535 of file json.hpp.

+

Definition at line 6601 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 d98b2a32c..6bfb83016 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 6480 of file json.hpp.

+

Definition at line 6546 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 4ec7854e6..1592d1447 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 6462 of file json.hpp.

+

Definition at line 6528 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 7ef803c73..08d6dbcff 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 6467 of file json.hpp.

+

Definition at line 6533 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 a10bae563..6a8c02c72 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 6452 of file json.hpp.

+

Definition at line 6518 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 943f780e4..e742a4a3f 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 6516 of file json.hpp.

+

Definition at line 6582 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 b259349cb..bd3549bc4 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 6486 of file json.hpp.

+

Definition at line 6552 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 b5f693beb..8bcb3cb3b 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 6522 of file json.hpp.

+

Definition at line 6588 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 c81d98757..05fca118d 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 6528 of file json.hpp.

+

Definition at line 6594 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 e0a645e5a..ef4a5e64d 100644 --- a/classnlohmann_1_1basic__json_a01a2643289b69cd71d9b3f3fc209b748.html +++ b/classnlohmann_1_1basic__json_a01a2643289b69cd71d9b3f3fc209b748.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -263,13 +265,13 @@ template<template< typename U, typename V, typename...Args > class Obje
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:3664
+
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
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 3664 of file json.hpp.

+

Definition at line 3730 of file json.hpp.

@@ -279,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 a361c7628..9026ea193 100644 --- a/classnlohmann_1_1basic__json_a0703ae5cbd2daac5e6c0ae01d3a1b114.html +++ b/classnlohmann_1_1basic__json_a0703ae5cbd2daac5e6c0ae01d3a1b114.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -267,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Logarithmic in the size of the container, O(log(size())).
Example
The example shows how push_back and += can be used to add elements to a JSON object. Note how the null value was silently converted to a JSON object.
1 #include <json.hpp>
2 
3 using 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:4223
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
{"one":1,"two":2}
 null
@@ -276,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 4333 of file json.hpp.

+

Definition at line 4399 of file json.hpp.

@@ -286,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html b/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html index 96d31ab10..511385af3 100644 --- a/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html +++ b/classnlohmann_1_1basic__json_a07c9c38a1f01675759e05d5d34627343.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -280,15 +282,15 @@ 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:3699
+
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:4361
+
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4427
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 4388 of file json.hpp.

+

Definition at line 4454 of file json.hpp.

@@ -298,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 5e5735f06..9cd57342d 100644 --- a/classnlohmann_1_1basic__json_a088460b5d95f384a4f2ec9e52f4f66ba.html +++ b/classnlohmann_1_1basic__json_a088460b5d95f384a4f2ec9e52f4f66ba.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ true diff --git a/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html b/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html index 70a6692ed..cdd10cfed 100644 --- a/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html +++ b/classnlohmann_1_1basic__json_a0afa4512f03406db0d0432657e9c7361.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -324,7 +326,7 @@ false diff --git a/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html b/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html new file mode 100644 index 000000000..b1600c2d7 --- /dev/null +++ b/classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html @@ -0,0 +1,317 @@ + + + + + + +JSON for Modern C++: nlohmann::basic_json::operator[] + + + + + + + + + + + +
+
+ + + + + + +
+
JSON for Modern C++ +  1.0.0 +
+
+
+ + + + + +
+
+ + +
+ +
+ + +
+
+ + + + + +
+ + + +
+
+
+template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
+
+template<typename T >
+ + + + + +
+ + + + + + + + +
reference nlohmann::basic_json::operator[] (T * key)
+
+inline
+
+

Returns a reference to the element at with specified key key.

+
Note
If key is not found in the object, then it is silently added to the object and filled with a null value to make key a valid reference. In case the value was null before, it is converted to an object.
+
Parameters
+ + +
[in]keykey of the element to access
+
+
+
Returns
reference to the element at key key
+
Exceptions
+ + +
std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with null"
+
+
+
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
+
Output (play with this example online):
2
+
+{
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
+
+{
+    "five": {
+        "really": {
+            "nested": true
+        }
+    },
+    "four": null,
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
+
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/operatorarray__key_type.cpp -o operatorarray__key_type 
+
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
+ +

Definition at line 3152 of file json.hpp.

+ +
+
+
+
+ + + + diff --git a/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html b/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html index 3b887ec70..8b2840291 100644 --- a/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html +++ b/classnlohmann_1_1basic__json_a114095c452ca2f4ba976548df3da68be.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html b/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html index ed593eeda..6f263cb15 100644 --- a/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html +++ b/classnlohmann_1_1basic__json_a11c3dd843c21c58daa651e84046a82af.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html index 1eaaec5ba..20186b95f 100644 --- a/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html +++ b/classnlohmann_1_1basic__json_a122640e7e2db1814fc7bbb3c122ec76e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -285,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__equal.cpp -o operator__equal 
Since
version 1.0.0
-

Definition at line 4745 of file json.hpp.

+

Definition at line 4811 of file json.hpp.

@@ -295,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 ec912f4f6..a98370315 100644 --- a/classnlohmann_1_1basic__json_a13e5642dbfa1602c937d295a085413cc.html +++ b/classnlohmann_1_1basic__json_a13e5642dbfa1602c937d295a085413cc.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 f97a20d07..e3f3e4535 100644 --- a/classnlohmann_1_1basic__json_a1683189bd539313b5559f07961166c8b.html +++ b/classnlohmann_1_1basic__json_a1683189bd539313b5559f07961166c8b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 d06c2620a..dcf3d3e77 100644 --- a/classnlohmann_1_1basic__json_a16a275d0201e9aedc87c933c764b8869.html +++ b/classnlohmann_1_1basic__json_a16a275d0201e9aedc87c933c764b8869.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -269,7 +271,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Logarithmic in the size of the container.
Example
The example below shows how object elements can be read using at.
1 #include <json.hpp>
2 
3 using 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:2718
+
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2720
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
"il brutto"
 out of range
@@ -279,7 +281,7 @@ out of range
 value() for access by value with a default value
Since
version 1.0.0
-

Definition at line 2858 of file json.hpp.

+

Definition at line 2860 of file json.hpp.

@@ -289,7 +291,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html b/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html index 7d567201c..cb6067a02 100644 --- a/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html +++ b/classnlohmann_1_1basic__json_a1b058496e6a67565a096233cd113505b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -289,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 3011b2377..4fc555d02 100644 --- a/classnlohmann_1_1basic__json_a1dc0c521042807e216d11110d2f002ff.html +++ b/classnlohmann_1_1basic__json_a1dc0c521042807e216d11110d2f002ff.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -293,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 a66394ad1..bf3aaebda 100644 --- a/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html +++ b/classnlohmann_1_1basic__json_a231b02148577b69a154b2ce2c87a5522.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -287,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 3082dcc55..6689902e3 100644 --- a/classnlohmann_1_1basic__json_a234f03dce002783748ca401a42bc6472.html +++ b/classnlohmann_1_1basic__json_a234f03dce002783748ca401a42bc6472.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -283,7 +285,7 @@ true diff --git a/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html b/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html index 6e9e32e1c..4c0e7321c 100644 --- a/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html +++ b/classnlohmann_1_1basic__json_a26b7e4876af25eae5800ce43f93aaef2.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -291,7 +293,7 @@ value() with null"
Complexity
Logarithmic in the size of the container.
Example
The example below shows how object elements can be queried with a default value.
1 #include <json.hpp>
2 
3 using 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:3202
+
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
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 
@@ -300,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 3202 of file json.hpp.

+

Definition at line 3268 of file json.hpp.

@@ -310,7 +312,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html b/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html index 96e0fa55a..8bb596670 100644 --- a/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html +++ b/classnlohmann_1_1basic__json_a2adfc8d24bea3908398cbf325b5dc1d7.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,13 +266,13 @@ Illustration from cppreference.com
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:3878
+
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
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 3824 of file json.hpp.

+

Definition at line 3890 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html b/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html index 81751bd87..5d09f95da 100644 --- a/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html +++ b/classnlohmann_1_1basic__json_a2f07bcf7e75c34396476dd1790f26ce8.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -267,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Logarithmic in the size of the container, O(log(size())).
Example
The example shows how push_back and += can be used to add elements to a JSON object. Note how the null value was silently converted to a JSON object.
1 #include <json.hpp>
2 
3 using 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:4223
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
{"one":1,"two":2}
 null
@@ -276,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 4309 of file json.hpp.

+

Definition at line 4375 of file json.hpp.

@@ -286,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html b/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html index e6fb407ad..5cd54b246 100644 --- a/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html +++ b/classnlohmann_1_1basic__json_a2f1f7ca08995781acb63bd66b26ad1c1.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -289,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 289f04e29..0c50a30ab 100644 --- a/classnlohmann_1_1basic__json_a3173944e7b1809a333def4078a0b92a3.html +++ b/classnlohmann_1_1basic__json_a3173944e7b1809a333def4078a0b92a3.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -267,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Amortized constant.
Example
The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
1 #include <json.hpp>
2 
3 using 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:4223
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
[1,2,3,4,5]
 null
@@ -276,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 4249 of file json.hpp.

+

Definition at line 4315 of file json.hpp.

@@ -286,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html b/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html index 7e11abc18..61523d41b 100644 --- a/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html +++ b/classnlohmann_1_1basic__json_a317b01b0fba3ac458561f1634759ea3b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -255,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 3922 of file json.hpp.

+

Definition at line 3988 of file json.hpp.

@@ -265,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 ebac2ee0c..2a60380c9 100644 --- a/classnlohmann_1_1basic__json_a3287df6546c905fb0a5786deb4b1cf32.html +++ b/classnlohmann_1_1basic__json_a3287df6546c905fb0a5786deb4b1cf32.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -279,7 +281,7 @@ template<template< typename U, typename V, typename...Args > class Obje
object (unordered set of name/value pairs)
namespace for Niels Lohmann
Definition: json.hpp:79
array (ordered collection of values)
-
bool empty() const noexcept
checks whether the container is empty
Definition: json.hpp:3974
+
bool empty() const noexcept
checks whether the container is empty
Definition: json.hpp:4040
Output (play with this example online):
true
 false
 false
@@ -292,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 3974 of file json.hpp.

+

Definition at line 4040 of file json.hpp.

@@ -302,7 +304,7 @@ false diff --git a/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html b/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html index 8e76d5f19..4a9b76e41 100644 --- a/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html +++ b/classnlohmann_1_1basic__json_a33f1632cfdbf460b4913f4e8a43dd9e4.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -278,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 592442486..915be803c 100644 --- a/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html +++ b/classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -294,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 5098 of file json.hpp.

+

Definition at line 5164 of file json.hpp.

@@ -304,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 fe2b727f1..e957fd1fb 100644 --- a/classnlohmann_1_1basic__json_a3d4e4bab95b24ccab42ed37e0ede2d98.html +++ b/classnlohmann_1_1basic__json_a3d4e4bab95b24ccab42ed37e0ede2d98.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,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 0b347c161..d5e9b075b 100644 --- a/classnlohmann_1_1basic__json_a42f9133f978dde4cce5851b2c2434a0c.html +++ b/classnlohmann_1_1basic__json_a42f9133f978dde4cce5851b2c2434a0c.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html b/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html index e4f4aa118..826b32675 100644 --- a/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html +++ b/classnlohmann_1_1basic__json_a4361aa791f3980abb239e4155a3450cb.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,14 +266,14 @@ Illustration from cppreference.com
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:3733
+
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:5766
+
a const random access iterator for the basic_json class
Definition: json.hpp:5832
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 3709 of file json.hpp.

+

Definition at line 3775 of file json.hpp.

@@ -281,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html b/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html index e92e93625..40ed716e9 100644 --- a/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html +++ b/classnlohmann_1_1basic__json_a457fec897d7b6283c60ca236ebb1f5e8.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,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 09338baa4..4868238d5 100644 --- a/classnlohmann_1_1basic__json_a48c8d153bc2fd1af655063a4b984feac.html +++ b/classnlohmann_1_1basic__json_a48c8d153bc2fd1af655063a4b984feac.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -286,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 778099221..474ae9487 100644 --- a/classnlohmann_1_1basic__json_a4943b7f16ddc4e0df33c0cae7ef14471.html +++ b/classnlohmann_1_1basic__json_a4943b7f16ddc4e0df33c0cae7ef14471.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,13 +266,13 @@ Illustration from cppreference.com
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:3901
+
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
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 3901 of file json.hpp.

+

Definition at line 3967 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html b/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html index 7bffb021e..322cd3d80 100644 --- a/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html +++ b/classnlohmann_1_1basic__json_a4ad3f27ecece8f644e8dca69a97eb67f.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,13 +266,13 @@ Illustration from cppreference.com
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:3901
+
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
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 3855 of file json.hpp.

+

Definition at line 3921 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html b/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html index 29dcc5389..2577cbd7d 100644 --- a/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html +++ b/classnlohmann_1_1basic__json_a4bf695ddf4a00ea8feea2c725ec847f1.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -269,13 +271,13 @@ template<template< typename U, typename V, typename...Args > class Obje
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:4566
+
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
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 4631 of file json.hpp.

+

Definition at line 4697 of file json.hpp.

@@ -285,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 7b667d2ce..a0013f318 100644 --- a/classnlohmann_1_1basic__json_a4d688b5ff534d3ab4e284b3191061529.html +++ b/classnlohmann_1_1basic__json_a4d688b5ff534d3ab4e284b3191061529.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,13 +266,13 @@ Illustration from cppreference.com
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:3878
+
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
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 3878 of file json.hpp.

+

Definition at line 3944 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html b/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html index 1cc904fc9..445800850 100644 --- a/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html +++ b/classnlohmann_1_1basic__json_a5114ed5eb394a2805da0bd1acba95ae2.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -267,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Amortized constant.
Example
The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
1 #include <json.hpp>
2 
3 using 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:4223
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
[1,2,3,4,5]
 null
@@ -276,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 4259 of file json.hpp.

+

Definition at line 4325 of file json.hpp.

@@ -286,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html b/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html index 1cd0cdf2d..6d322bbf9 100644 --- a/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html +++ b/classnlohmann_1_1basic__json_a53a2abfdd4f72c7df5aba1155bf03e48.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -278,7 +280,7 @@ false diff --git a/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html b/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html index e78df104e..95c47ee10 100644 --- a/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html +++ b/classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ use operator[] with null" 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 2905 of file json.hpp.

+

Definition at line 2907 of file json.hpp.

@@ -287,7 +289,7 @@ use operator[] with null" diff --git a/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html b/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html index 244913a8a..7c8767cf2 100644 --- a/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html +++ b/classnlohmann_1_1basic__json_a57a96ab3ff1ce7b48a754129fb12c982.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -270,13 +272,13 @@ use swap() with boolean"
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:4566
+
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
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 4665 of file json.hpp.

+

Definition at line 4731 of file json.hpp.

@@ -286,7 +288,7 @@ string = the bad diff --git a/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html b/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html index 5e553c8bc..d52c90efc 100644 --- a/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html +++ b/classnlohmann_1_1basic__json_a5a2d4dbcdbc8ea065b87daf52cd786b9.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -273,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 25d70861f..3064b2f03 100644 --- a/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html +++ b/classnlohmann_1_1basic__json_a5c8bb5200f5eac10d31e26be46e5b1ac.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 4999 of file json.hpp.

+

Definition at line 5065 of file json.hpp.

@@ -291,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 adf02b93d..667b75098 100644 --- a/classnlohmann_1_1basic__json_a5d428360d75a52f6af74751d1cc912c6.html +++ b/classnlohmann_1_1basic__json_a5d428360d75a52f6af74751d1cc912c6.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html index ee93ff539..87358446d 100644 --- a/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html +++ b/classnlohmann_1_1basic__json_a5e34c5435e557d0bf666bd7311211405.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -294,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 5080 of file json.hpp.

+

Definition at line 5146 of file json.hpp.

@@ -304,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 187b3ef94..e69a8eb8a 100644 --- a/classnlohmann_1_1basic__json_a5f0aad50ed7e8aec3128fe018c18b3fe.html +++ b/classnlohmann_1_1basic__json_a5f0aad50ed7e8aec3128fe018c18b3fe.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -298,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 0eed2ae84..6ed92caa2 100644 --- a/classnlohmann_1_1basic__json_a5fd8b54389698edf0c08e2dd001f610b.html +++ b/classnlohmann_1_1basic__json_a5fd8b54389698edf0c08e2dd001f610b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 9b71db585..9befc5890 100644 --- a/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html +++ b/classnlohmann_1_1basic__json_a60ca396028b8d9714c6e10efbf475af6.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -297,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 5202 of file json.hpp.

+

Definition at line 5268 of file json.hpp.

@@ -307,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 dfafdf369..65a9a2fb6 100644 --- a/classnlohmann_1_1basic__json_a63691315292df8e1522b00d37ebb1ffc.html +++ b/classnlohmann_1_1basic__json_a63691315292df8e1522b00d37ebb1ffc.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -282,7 +284,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 332f7bd3e..6964ab50a 100644 --- a/classnlohmann_1_1basic__json_a652414dd930cb3af3b6f454cc535a23e.html +++ b/classnlohmann_1_1basic__json_a652414dd930cb3af3b6f454cc535a23e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -269,7 +271,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Logarithmic in the size of the container.
Example
The example below shows how object elements can be read and written using at.
1 #include <json.hpp>
2 
3 using 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:2718
+
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2720
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
"il brutto"
 {"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
@@ -280,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 2810 of file json.hpp.

+

Definition at line 2812 of file json.hpp.

@@ -290,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 524b9c014..8724c0653 100644 --- a/classnlohmann_1_1basic__json_a656939a3dc9a6047e4afacd9e11b83a6.html +++ b/classnlohmann_1_1basic__json_a656939a3dc9a6047e4afacd9e11b83a6.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -283,7 +285,7 @@ true diff --git a/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html b/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html index a2426b2ff..80daa3ddf 100644 --- a/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html +++ b/classnlohmann_1_1basic__json_a66f936cfbd252f85bd3dc2598e37a64b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -267,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Amortized constant.
Example
The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
1 #include <json.hpp>
2 
3 using 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:4223
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
[1,2,3,4,5]
 null
@@ -276,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 4223 of file json.hpp.

+

Definition at line 4289 of file json.hpp.

@@ -286,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html b/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html index 10d563f5d..4ffb08ed6 100644 --- a/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html +++ b/classnlohmann_1_1basic__json_a6944904b3b59769b1cf62ac2532cbe33.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -276,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 139469d9e..275fcf579 100644 --- a/classnlohmann_1_1basic__json_a696ced74d8edc0b63a000a72907ab109.html +++ b/classnlohmann_1_1basic__json_a696ced74d8edc0b63a000a72907ab109.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -280,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html b/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html index 5ed2da597..da3f02bd0 100644 --- a/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html +++ b/classnlohmann_1_1basic__json_a6a7f45095675ac6fd1d018a0e41874be.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -294,9 +296,9 @@ 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:3758
-
iterator begin()
returns an iterator to the first element
Definition: json.hpp:3699
-
iterator find(typename object_t::key_type key)
find an element in a JSON object
Definition: json.hpp:3616
+
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
Output (play with this example online):
["bravo","charly"]
 42
@@ -314,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 29618502e..e41c1c902 100644
--- a/classnlohmann_1_1basic__json_a6b7428e8c1169497f47b81667001cbfb.html
+++ b/classnlohmann_1_1basic__json_a6b7428e8c1169497f47b81667001cbfb.html
@@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
           operator[]
           operator[]
           operator[]
-          operator[]
-          operator[]
+          operator[]
+          operator[]
+          operator[]
+          operator[]
           parse
           parse
           parse
@@ -287,15 +289,15 @@ 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:3699
+
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:4361
+
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4427
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 4417 of file json.hpp.

+

Definition at line 4483 of file json.hpp.

@@ -305,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 5f71e44a7..5d192e763 100644 --- a/classnlohmann_1_1basic__json_a6bbd3e72a870f1ba81ff6886b063b0fe.html +++ b/classnlohmann_1_1basic__json_a6bbd3e72a870f1ba81ff6886b063b0fe.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 1dcdf4112..bd179ad8e 100644 --- a/classnlohmann_1_1basic__json_a6dff6a02a2be250b8f8dc2f47be65544.html +++ b/classnlohmann_1_1basic__json_a6dff6a02a2be250b8f8dc2f47be65544.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -270,7 +272,7 @@ range"
Complexity
Linear in distance between idx and the end of the container.
Example
The example shows the effect of erase.
1 #include <json.hpp>
2 
3 using 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:3354
+
InteratorType erase(InteratorType pos)
remove element given an iterator
Definition: json.hpp:3420
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
@@ -280,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 3580 of file json.hpp.

+

Definition at line 3646 of file json.hpp.

@@ -290,7 +292,7 @@ range" diff --git a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html index bf225d6e7..99365d2d2 100644 --- a/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html +++ b/classnlohmann_1_1basic__json_a6e2e21da48f5d9471716cd868a068327.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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__notequal.cpp -o operator__notequal 
Since
version 1.0.0
-

Definition at line 4855 of file json.hpp.

+

Definition at line 4921 of file json.hpp.

@@ -291,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 05b7568f8..b130488fa 100644 --- a/classnlohmann_1_1basic__json_a71eba33d906745e66f340952b79fbce3.html +++ b/classnlohmann_1_1basic__json_a71eba33d906745e66f340952b79fbce3.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 465519151..2d40839d7 100644 --- a/classnlohmann_1_1basic__json_a72442ccbb378b4464a24a2da1e784041.html +++ b/classnlohmann_1_1basic__json_a72442ccbb378b4464a24a2da1e784041.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -289,7 +291,7 @@ value() with null"
Complexity
Logarithmic in the size of the container.
Example
The example below shows how object elements can be queried with a default value.
1 #include <json.hpp>
2 
3 using 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:3202
+
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
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 
@@ -298,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 3228 of file json.hpp.

+

Definition at line 3294 of file json.hpp.

@@ -308,7 +310,7 @@ value() with null" diff --git a/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html b/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html index 9b54a8857..f8188697d 100644 --- a/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html +++ b/classnlohmann_1_1basic__json_a72ba20783ecb3eec98bd6a3b870d565c.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,14 +266,14 @@ Illustration from cppreference.com
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:3792
+
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:5766
+
a const random access iterator for the basic_json class
Definition: json.hpp:5832
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 3792 of file json.hpp.

+

Definition at line 3858 of file json.hpp.

@@ -281,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html b/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html index 9f2d9e72a..9a8031f7f 100644 --- a/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html +++ b/classnlohmann_1_1basic__json_a74472977b798c7b7989e6e7cb960ecff.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,7 +286,7 @@ null diff --git a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html index dcb835b21..9da378c9e 100644 --- a/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html +++ b/classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 5043 of file json.hpp.

+

Definition at line 5109 of file json.hpp.

@@ -291,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 ebd505a12..2fa7f0cbb 100644 --- a/classnlohmann_1_1basic__json_a74ccfa471a0c061876b247f820f3c741.html +++ b/classnlohmann_1_1basic__json_a74ccfa471a0c061876b247f820f3c741.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -272,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  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:8048
+
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:4153
+
void clear() noexcept
clears the contents
Definition: json.hpp:4219
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:5137
+
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
Output (play with this example online):
{
     "Image": {
@@ -318,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 5166 of file json.hpp.

+

Definition at line 5232 of file json.hpp.

@@ -328,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 dcf55b4ec..b71d55f4d 100644 --- a/classnlohmann_1_1basic__json_a75a1754e0d39f33095d3102a8bdb9881.html +++ b/classnlohmann_1_1basic__json_a75a1754e0d39f33095d3102a8bdb9881.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -287,10 +289,10 @@ of range"
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:3699
-
iterator find(typename object_t::key_type key)
find an element in a JSON object
Definition: json.hpp:3616
+
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:3354
+
InteratorType erase(InteratorType pos)
remove element given an iterator
Definition: json.hpp:3420
Output (play with this example online):
null
 null
 null
@@ -305,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 3354 of file json.hpp.

+

Definition at line 3420 of file json.hpp.

@@ -315,7 +317,7 @@ null diff --git a/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html b/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html index 858e9b937..3e20ff92f 100644 --- a/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html +++ b/classnlohmann_1_1basic__json_a76cfc5062bf6223396ab82c753cd4634.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html b/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html index d1123fcb3..2d9d1fc92 100644 --- a/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html +++ b/classnlohmann_1_1basic__json_a7c08f966200af98db0313a3b517ce0a9.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -263,14 +265,14 @@ Illustration from cppreference.com
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:3847
+
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
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 3847 of file json.hpp.

+

Definition at line 3913 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html b/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html index df29fcb00..2b1eab4e8 100644 --- a/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html +++ b/classnlohmann_1_1basic__json_a7c19a5c3be6cc755377ee41eade78baf.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -262,8 +264,8 @@ 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:3758
-
iterator find(typename object_t::key_type key)
find an element in a JSON object
Definition: json.hpp:3616
+
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
Output (play with this example online):
"two" was found: true
 value at key "two": 2
@@ -271,7 +273,7 @@ value at key "two": 2
 
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 3633 of file json.hpp.

+

Definition at line 3699 of file json.hpp.

@@ -281,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 564746b6d..158b47c4d 100644 --- a/classnlohmann_1_1basic__json_a7d0db3b728d820d4984df78d97d2b104.html +++ b/classnlohmann_1_1basic__json_a7d0db3b728d820d4984df78d97d2b104.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 a49c228e6..02588fc72 100644 --- a/classnlohmann_1_1basic__json_a7d1b990f2c12fecb57db1504fdadd0bb.html +++ b/classnlohmann_1_1basic__json_a7d1b990f2c12fecb57db1504fdadd0bb.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -269,7 +271,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
log(size()) + count(key)
Example
The example shows the effect of erase.
1 #include <json.hpp>
2 
3 using 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:3354
+
InteratorType erase(InteratorType pos)
remove element given an iterator
Definition: json.hpp:3420
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 
@@ -280,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 3542 of file json.hpp.

+

Definition at line 3608 of file json.hpp.

@@ -290,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 1f4a32537..f9440f746 100644 --- a/classnlohmann_1_1basic__json_a7dab69b10b98e7bc694339720e37fb2b.html +++ b/classnlohmann_1_1basic__json_a7dab69b10b98e7bc694339720e37fb2b.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -262,8 +264,8 @@ 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:3758
-
iterator find(typename object_t::key_type key)
find an element in a JSON object
Definition: json.hpp:3616
+
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
Output (play with this example online):
"two" was found: true
 value at key "two": 2
@@ -271,7 +273,7 @@ value at key "two": 2
 
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 3616 of file json.hpp.

+

Definition at line 3682 of file json.hpp.

@@ -281,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 e433afb0b..cbebe62cf 100644 --- a/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html +++ b/classnlohmann_1_1basic__json_a7f97a91ad8f1d5cf0b9213bd24f247c4.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 4887 of file json.hpp.

+

Definition at line 4953 of file json.hpp.

@@ -291,7 +293,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html b/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html index 019939701..ae90e7d59 100644 --- a/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html +++ b/classnlohmann_1_1basic__json_a80ceaa3bdd346292273b309e08525c1c.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 b63b28170..42c284b58 100644 --- a/classnlohmann_1_1basic__json_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html +++ b/classnlohmann_1_1basic__json_a83cbbfbf5d3ecbad6de8ece0be6b36c4.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -261,7 +263,7 @@ template<template< typename U, typename V, typename...Args > class Obje -
Example
The following code shows an example for front.
1 #include <json.hpp>
2 
3 using 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:3253
+
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
object (unordered set of name/value pairs)
namespace for Niels Lohmann
Definition: json.hpp:79
@@ -275,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 3253 of file json.hpp.

+

Definition at line 3319 of file json.hpp.

@@ -285,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 866ee00fd..d63424c39 100644 --- a/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html +++ b/classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 5021 of file json.hpp.

+

Definition at line 5087 of file json.hpp.

@@ -291,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 894dcb9c5..85058d4db 100644 --- a/classnlohmann_1_1basic__json_a8b526709d395142b68d21abfbfff17c3.html +++ b/classnlohmann_1_1basic__json_a8b526709d395142b68d21abfbfff17c3.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -261,7 +263,7 @@ template<template< typename U, typename V, typename...Args > class Obje -
Example
The following code shows an example for front.
1 #include <json.hpp>
2 
3 using 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:3253
+
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
object (unordered set of name/value pairs)
namespace for Niels Lohmann
Definition: json.hpp:79
@@ -275,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 3261 of file json.hpp.

+

Definition at line 3327 of file json.hpp.

@@ -285,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 19af3a73f..80c77e488 100644 --- a/classnlohmann_1_1basic__json_a8c40cd9ead4de7c82f28268bdf0ec98a.html +++ b/classnlohmann_1_1basic__json_a8c40cd9ead4de7c82f28268bdf0ec98a.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -272,7 +274,7 @@ template<template< typename U, typename V, typename...Args > class Obje
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:4153
+
void clear() noexcept
clears the contents
Definition: json.hpp:4219
Output (play with this example online):
null
 false
 0
@@ -283,7 +285,7 @@ false
 
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/clear.cpp -o clear 
Since
version 1.0.0
-

Definition at line 4153 of file json.hpp.

+

Definition at line 4219 of file json.hpp.

@@ -293,7 +295,7 @@ false diff --git a/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html b/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html index f88a02142..11a1a3c25 100644 --- a/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html +++ b/classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -278,7 +280,7 @@ operator[] with null" value() for access by value with a default value
Since
version 1.0.0
-

Definition at line 3039 of file json.hpp.

+

Definition at line 3041 of file json.hpp.

@@ -288,7 +290,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html b/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html index eb4476b4f..706b2f68a 100644 --- a/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html +++ b/classnlohmann_1_1basic__json_a8e4e11999b4e7faa8f31f21164ebd65a.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -255,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 3930 of file json.hpp.

+

Definition at line 3996 of file json.hpp.

@@ -265,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 aa09f1332..442df04b9 100644 --- a/classnlohmann_1_1basic__json_a8fa74698f4061e18ec664009f3af1ddf.html +++ b/classnlohmann_1_1basic__json_a8fa74698f4061e18ec664009f3af1ddf.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -290,16 +292,16 @@ 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:3758
-
iterator begin()
returns an iterator to the first element
Definition: json.hpp:3699
+
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:4361
+
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4427
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 4470 of file json.hpp.

+

Definition at line 4536 of file json.hpp.

@@ -309,7 +311,7 @@ belong to container" diff --git a/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html b/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html index 35e4b0a29..5e6b28408 100644 --- a/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html +++ b/classnlohmann_1_1basic__json_a930e14150ffa067bcf56d35cb00271e1.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -271,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 0f9b5570b..281fa0ee5 100644 --- a/classnlohmann_1_1basic__json_a960962c683909619d1d2fbbe856c022e.html +++ b/classnlohmann_1_1basic__json_a960962c683909619d1d2fbbe856c022e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -267,7 +269,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Amortized constant.
Example
The example shows how push_back and += can be used to add elements to a JSON array. Note how the null value was silently converted to a JSON array.
1 #include <json.hpp>
2 
3 using 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:4223
+
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:4289
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
[1,2,3,4,5]
 null
@@ -276,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 4283 of file json.hpp.

+

Definition at line 4349 of file json.hpp.

@@ -286,7 +288,7 @@ null diff --git a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html index 20f9cdf95..0b43ba940 100644 --- a/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html +++ b/classnlohmann_1_1basic__json_a9730b9f7bc2150e641fe20198d4477c7.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 4825 of file json.hpp.

+

Definition at line 4891 of file json.hpp.

@@ -291,7 +293,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html index 09f35fa41..d59da57c3 100644 --- a/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html +++ b/classnlohmann_1_1basic__json_a98e05a2c9b8f74bd60442772cddeee52.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 4834 of file json.hpp.

+

Definition at line 4900 of file json.hpp.

@@ -291,7 +293,7 @@ null == nullptr true diff --git a/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html b/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html index 5fe31def9..617ea00d1 100644 --- a/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html +++ b/classnlohmann_1_1basic__json_a9993148cb0473365e52998c7315f9ada.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -280,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html b/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html index 4b9ba1ccd..a91c9c7a8 100644 --- a/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html +++ b/classnlohmann_1_1basic__json_a9a73d1b71c9e913aa2888d8b40c72ee9.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -271,7 +273,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Linear in cnt.
-
Example
The following code shows examples for the basic_json(size_type, const basic_json&) constructor.
1 #include <json.hpp>
2 
3 using 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:8048
+
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
Output (play with this example online):
[]
@@ -290,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 33083a696..b9bd00ad2 100644 --- a/classnlohmann_1_1basic__json_a9c26c5d0f4a519c7236149b9aeb3ef9e.html +++ b/classnlohmann_1_1basic__json_a9c26c5d0f4a519c7236149b9aeb3ef9e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -280,7 +282,7 @@ false diff --git a/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html b/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html index 9759c570a..3e34ff68b 100644 --- a/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html +++ b/classnlohmann_1_1basic__json_a9f17a0690155e3a5603246ccec81499e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ true diff --git a/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html b/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html index bc5c27a4f..7db3ae700 100644 --- a/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html +++ b/classnlohmann_1_1basic__json_aa0422e861b4cbd7cdcaad7a11a1304a9.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -272,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  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:8048
+
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:4153
+
void clear() noexcept
clears the contents
Definition: json.hpp:4219
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:5137
+
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
Output (play with this example online):
{
     "Image": {
@@ -318,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 5174 of file json.hpp.

+

Definition at line 5240 of file json.hpp.

@@ -328,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 e43ddbc95..1b4621bb6 100644 --- a/classnlohmann_1_1basic__json_aa1f3b3f1dca79392d6727b81f9668c6c.html +++ b/classnlohmann_1_1basic__json_aa1f3b3f1dca79392d6727b81f9668c6c.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -265,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
object (unordered set of name/value pairs)
namespace for Niels Lohmann
Definition: json.hpp:79
array (ordered collection of values)
-
reference back()
access the last element
Definition: json.hpp:3287
+
reference back()
access the last element
Definition: json.hpp:3353
Output (play with this example online):
true
 17
 23.42
@@ -275,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 3287 of file json.hpp.

+

Definition at line 3353 of file json.hpp.

@@ -285,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 77f55690d..839004846 100644 --- a/classnlohmann_1_1basic__json_aa5413178b8041f7ac685dec4b040dd2c.html +++ b/classnlohmann_1_1basic__json_aa5413178b8041f7ac685dec4b040dd2c.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,14 +266,14 @@ Illustration from cppreference.com
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:3792
+
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:5766
+
a const random access iterator for the basic_json class
Definition: json.hpp:5832
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 3768 of file json.hpp.

+

Definition at line 3834 of file json.hpp.

@@ -281,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html b/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html index 18e01402d..0926ecc74 100644 --- a/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html +++ b/classnlohmann_1_1basic__json_aa6a24b176f9599a21d662cc5f8e1ca76.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -270,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 0d8ce3bc4..c27773ee7 100644 --- a/classnlohmann_1_1basic__json_aa6c32f669a2e523666072003d0ea46f4.html +++ b/classnlohmann_1_1basic__json_aa6c32f669a2e523666072003d0ea46f4.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -294,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 d79b76f9e..e4a2425a3 100644 --- a/classnlohmann_1_1basic__json_aa71e977d31f470689883ac60d16ea4ac.html +++ b/classnlohmann_1_1basic__json_aa71e977d31f470689883ac60d16ea4ac.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -270,13 +272,13 @@ use swap() with string"
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:4566
+
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
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 4597 of file json.hpp.

+

Definition at line 4663 of file json.hpp.

@@ -286,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 c0ac51518..2751ca69a 100644 --- a/classnlohmann_1_1basic__json_aabe4661644ea549089f0886c2551d2ac.html +++ b/classnlohmann_1_1basic__json_aabe4661644ea549089f0886c2551d2ac.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -285,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 0870ceee9..325d594f7 100644 --- a/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html +++ b/classnlohmann_1_1basic__json_aac185a137428a7337aa620de07bfbbd7.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -268,7 +270,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Since
version 1.0.0
-

Definition at line 4699 of file json.hpp.

+

Definition at line 4765 of file json.hpp.

@@ -278,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 60661ab9a..6fa7af20a 100644 --- a/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html +++ b/classnlohmann_1_1basic__json_aacd442b66140c764c594ac8ad7dfd5b3.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -285,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 4916 of file json.hpp.

+

Definition at line 4982 of file json.hpp.

@@ -295,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 cb01be24b..3ba3fcf02 100644 --- a/classnlohmann_1_1basic__json_aacf6c869f6a9c66ac1bc99e93f310044.html +++ b/classnlohmann_1_1basic__json_aacf6c869f6a9c66ac1bc99e93f310044.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -272,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 new file mode 100644 index 000000000..30ec69472 --- /dev/null +++ b/classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html @@ -0,0 +1,301 @@ + + + + + + +JSON for Modern C++: nlohmann::basic_json::operator[] + + + + + + + + + + + +
+
+ + + + + + +
+
JSON for Modern C++ +  1.0.0 +
+
+
+ + + + + +
+
+ + +
+ +
+ + +
+
+ + + + + +
+ + + +
+
+
+template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
+
+template<typename T , std::size_t n>
+ + + + + +
+ + + + + + + + +
const_reference nlohmann::basic_json::operator[] (T *(&) key[n]) const
+
+inline
+
+

Returns a const reference to the element at with specified key key. No bounds checking is performed.

+
Warning
If the element with key key does not exist, the behavior is undefined.
+
Note
This function is required for compatibility reasons with Clang.
+
Parameters
+ + +
[in]keykey of the element to access
+
+
+
Returns
const reference to the element at key key
+
Exceptions
+ + +
std::domain_errorif JSON is not an object; example: "cannot use +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
+
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.0
+ +

Definition at line 3119 of file json.hpp.

+ +
+
+
+
+ + + + diff --git a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html index d1d549aea..d88060fff 100644 --- a/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html +++ b/classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -297,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 5212 of file json.hpp.

+

Definition at line 5278 of file json.hpp.

@@ -307,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 41429ce36..42b217bb3 100644 --- a/classnlohmann_1_1basic__json_aafa839f2a74dc1b5060314b3423143b8.html +++ b/classnlohmann_1_1basic__json_aafa839f2a74dc1b5060314b3423143b8.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -258,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 eea8e3ff4..79958c776 100644 --- a/classnlohmann_1_1basic__json_ab14e3503305622fb5ab01a7f490916e8.html +++ b/classnlohmann_1_1basic__json_ab14e3503305622fb5ab01a7f490916e8.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -280,15 +282,15 @@ 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:3758
+
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:4361
+
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4427
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 4528 of file json.hpp.

+

Definition at line 4594 of file json.hpp.

@@ -298,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 0ace6a7a2..d65ccfd1f 100644 --- a/classnlohmann_1_1basic__json_ab2162bc76e10d8736cab9b2039956054.html +++ b/classnlohmann_1_1basic__json_ab2162bc76e10d8736cab9b2039956054.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -263,14 +265,14 @@ Illustration from cppreference.com
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:6308
-
iterator end()
returns an iterator to one past the last element
Definition: json.hpp:3758
+
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
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 3758 of file json.hpp.

+

Definition at line 3824 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html b/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html index ab12eb212..7f7cac78d 100644 --- a/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html +++ b/classnlohmann_1_1basic__json_ab74b2398f29acc6ffbf48f1b8974a848.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -291,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 8d5f6a6b5..faa0039fd 100644 --- a/classnlohmann_1_1basic__json_ab7d60fb6cb8e8f5740e588f9dc953819.html +++ b/classnlohmann_1_1basic__json_ab7d60fb6cb8e8f5740e588f9dc953819.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -299,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 d544806ce..f06e07ebf 100644 --- a/classnlohmann_1_1basic__json_ab9a20bd1d391e9cb968db50c246f728d.html +++ b/classnlohmann_1_1basic__json_ab9a20bd1d391e9cb968db50c246f728d.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -276,7 +278,7 @@ template<template< typename U, typename V, typename...Args > class Obje
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:4032
+
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:4098
object (unordered set of name/value pairs)
namespace for Niels Lohmann
Definition: json.hpp:79
array (ordered collection of values)
@@ -292,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 4032 of file json.hpp.

+

Definition at line 4098 of file json.hpp.

@@ -302,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 19876338f..40e003aba 100644 --- a/classnlohmann_1_1basic__json_ab9da2afc6f77295f25252725fde142a6.html +++ b/classnlohmann_1_1basic__json_ab9da2afc6f77295f25252725fde142a6.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -265,7 +267,7 @@ template<template< typename U, typename V, typename...Args > class Obje
object (unordered set of name/value pairs)
namespace for Niels Lohmann
Definition: json.hpp:79
array (ordered collection of values)
-
reference back()
access the last element
Definition: json.hpp:3287
+
reference back()
access the last element
Definition: json.hpp:3353
Output (play with this example online):
true
 17
 23.42
@@ -275,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 3297 of file json.hpp.

+

Definition at line 3363 of file json.hpp.

@@ -285,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 3003c5c87..9dfaf026b 100644 --- a/classnlohmann_1_1basic__json_abe8f3224ca4041908ddb466cb9caecf1.html +++ b/classnlohmann_1_1basic__json_abe8f3224ca4041908ddb466cb9caecf1.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ template<template< typename U, typename V, typename...Args > class Obje
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:4094
+
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition: json.hpp:4160
Output (play with this example online):
0
 1
 1
@@ -288,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 4094 of file json.hpp.

+

Definition at line 4160 of file json.hpp.

@@ -298,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 eb4655485..cbe0eda9c 100644 --- a/classnlohmann_1_1basic__json_ac160789f17d206a5404981ca0957e303.html +++ b/classnlohmann_1_1basic__json_ac160789f17d206a5404981ca0957e303.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -280,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 fba2db6dd..79f9fe3cc 100644 --- a/classnlohmann_1_1basic__json_ac4011bd0781e51afe4994d2b09fd27e9.html +++ b/classnlohmann_1_1basic__json_ac4011bd0781e51afe4994d2b09fd27e9.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 225d146aa..77e469872 100644 --- a/classnlohmann_1_1basic__json_ac8163abe518595f19dbee68db1caaaf7.html +++ b/classnlohmann_1_1basic__json_ac8163abe518595f19dbee68db1caaaf7.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html b/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html index 2f64a913a..f1730aa3d 100644 --- a/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html +++ b/classnlohmann_1_1basic__json_ac82abedf356d252e0589850c3d8b35ba.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -273,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 6b6414079..224c6309c 100644 --- a/classnlohmann_1_1basic__json_ac943391891fcde0a71a15ce990e0f7f4.html +++ b/classnlohmann_1_1basic__json_ac943391891fcde0a71a15ce990e0f7f4.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -288,7 +290,7 @@ true diff --git a/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html b/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html index c98612eef..a4397360e 100644 --- a/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html +++ b/classnlohmann_1_1basic__json_acd08f9179c8c1e9f2cd7575a724ce27e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -289,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 b6bcb289a..445768339 100644 --- a/classnlohmann_1_1basic__json_acdf4445333649ec94198f09a62144884.html +++ b/classnlohmann_1_1basic__json_acdf4445333649ec94198f09a62144884.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -263,14 +265,14 @@ Illustration from cppreference.com
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:6308
-
iterator begin()
returns an iterator to the first element
Definition: json.hpp:3699
+
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
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 3699 of file json.hpp.

+

Definition at line 3765 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html b/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html index 767ebb8b5..5f742e717 100644 --- a/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html +++ b/classnlohmann_1_1basic__json_ace8338e57fdb11e1955c2a0c2d782069.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -271,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 afa5512ab..afadc7870 100644 --- a/classnlohmann_1_1basic__json_ad1f617d29e8923dd40c89153f792b1bc.html +++ b/classnlohmann_1_1basic__json_ad1f617d29e8923dd40c89153f792b1bc.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -290,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 b2d19a56b..a5640c0a1 100644 --- a/classnlohmann_1_1basic__json_ad2c4513cef5d8db760c4b2d871eea42c.html +++ b/classnlohmann_1_1basic__json_ad2c4513cef5d8db760c4b2d871eea42c.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -262,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 36ae4ab11..7a917c9c2 100644 --- a/classnlohmann_1_1basic__json_ad497cbc4f80c8d79662ee6e19bf145dd.html +++ b/classnlohmann_1_1basic__json_ad497cbc4f80c8d79662ee6e19bf145dd.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -297,11 +299,11 @@ erase() with null"
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:3758
-
iterator begin()
returns an iterator to the first element
Definition: json.hpp:3699
-
iterator find(typename object_t::key_type key)
find an element in a JSON object
Definition: json.hpp:3616
+
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:3354
+
InteratorType erase(InteratorType pos)
remove element given an iterator
Definition: json.hpp:3420
Output (play with this example online):
null
 null
 null
@@ -316,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 3459 of file json.hpp.

+

Definition at line 3525 of file json.hpp.

@@ -326,7 +328,7 @@ null diff --git a/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html b/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html index b7d14e761..4983096de 100644 --- a/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html +++ b/classnlohmann_1_1basic__json_ad6734c2b91b1b77aa2b43b65c3619c05.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -291,7 +293,7 @@ null diff --git a/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html b/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html index a8be688a1..27f3c05b2 100644 --- a/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html +++ b/classnlohmann_1_1basic__json_ad8e0c5d04f016d1b3ac7369e5c73bedf.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,14 +266,14 @@ Illustration from cppreference.com
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:3733
+
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:5766
+
a const random access iterator for the basic_json class
Definition: json.hpp:5832
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 3733 of file json.hpp.

+

Definition at line 3799 of file json.hpp.

@@ -281,7 +283,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html b/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html index 0d3ef93c5..8891027a6 100644 --- a/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html +++ b/classnlohmann_1_1basic__json_ada8e01109a60088e4db2a670d4903b54.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -270,7 +272,7 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Constant.
Example
The example below shows how array elements can be read and written using at.
1 #include <json.hpp>
2 
3 using 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:2718
+
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2720
namespace for Niels Lohmann
Definition: json.hpp:79
Output (play with this example online):
"third"
 ["first","second","third","fourth"]
@@ -278,7 +280,7 @@ 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 2718 of file json.hpp.

+

Definition at line 2720 of file json.hpp.

@@ -288,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 9625093b7..84e30b16c 100644 --- a/classnlohmann_1_1basic__json_adbd4c16c9ac641b2a4736bc2c6787d83.html +++ b/classnlohmann_1_1basic__json_adbd4c16c9ac641b2a4736bc2c6787d83.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 new file mode 100644 index 000000000..b4cbf975d --- /dev/null +++ b/classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html @@ -0,0 +1,317 @@ + + + + + + +JSON for Modern C++: nlohmann::basic_json::operator[] + + + + + + + + + + + +
+
+ + + + + + +
+
JSON for Modern C++ +  1.0.0 +
+
+
+ + + + + +
+
+ + +
+ +
+ + +
+
+ + + + + +
+ + + +
+
+
+template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
+
+template<typename T , std::size_t n>
+ + + + + +
+ + + + + + + + +
reference nlohmann::basic_json::operator[] (T *(&) key[n])
+
+inline
+
+

Returns a reference to the element at with specified key key.

+
Note
If key is not found in the object, then it is silently added to the object and filled with a null value to make key a valid reference. In case the value was null before, it is converted to an object.
+
Parameters
+ + +
[in]keykey of the element to access
+
+
+
Returns
reference to the element at key key
+
Exceptions
+ + +
std::domain_errorif JSON is not an object or null; example: "cannot use operator[] with null"
+
+
+
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
+
Output (play with this example online):
2
+
+{
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
+
+{
+    "five": {
+        "really": {
+            "nested": true
+        }
+    },
+    "four": null,
+    "one": 1,
+    "three": 3,
+    "two": 2
+}
+
The example code above can be translated with
g++ -std=c++11 -Isrc doc/examples/operatorarray__key_type.cpp -o operatorarray__key_type 
+
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.0
+ +

Definition at line 3084 of file json.hpp.

+ +
+
+
+
+ + + + diff --git a/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html b/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html index 708a12959..8d00f0977 100644 --- a/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html +++ b/classnlohmann_1_1basic__json_ade7bd6e0fe221fec9d3fa9b430f5ce76.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -312,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 4ffc54459..cf8bf581d 100644 --- a/classnlohmann_1_1basic__json_adeaef2ab021997a11a826c378c2365e1.html +++ b/classnlohmann_1_1basic__json_adeaef2ab021997a11a826c378c2365e1.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html b/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html index db48dd1b6..68aec651f 100644 --- a/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html +++ b/classnlohmann_1_1basic__json_adf5dea6fa9d7075ff89ca0796ab47a7e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 e7c87e870..6679f685f 100644 --- a/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html +++ b/classnlohmann_1_1basic__json_ae347859ec88176ef76a0cbe5b4514fcf.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 4878 of file json.hpp.

+

Definition at line 4944 of file json.hpp.

@@ -291,7 +293,7 @@ null != nullptr false diff --git a/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html b/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html index 2722516b1..b35b44790 100644 --- a/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html +++ b/classnlohmann_1_1basic__json_ae50f22a1c646b8627e88f1313cceffd4.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -284,7 +286,7 @@ true diff --git a/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html b/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html new file mode 100644 index 000000000..f61c817ee --- /dev/null +++ b/classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html @@ -0,0 +1,300 @@ + + + + + + +JSON for Modern C++: nlohmann::basic_json::operator[] + + + + + + + + + + + +
+
+ + + + + + +
+
JSON for Modern C++ +  1.0.0 +
+
+
+ + + + + +
+
+ + +
+ +
+ + +
+
+ + + + + +
+ + + +
+
+
+template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
+
+template<typename T >
+ + + + + +
+ + + + + + + + +
const_reference nlohmann::basic_json::operator[] (T * key) const
+
+inline
+
+

Returns a const reference to the element at with specified key key. No bounds checking is performed.

+
Warning
If the element with key key does not exist, the behavior is undefined.
+
Parameters
+ + +
[in]keykey of the element to access
+
+
+
Returns
const reference to the element at key key
+
Exceptions
+ + +
std::domain_errorif JSON is not an object; example: "cannot use +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
+
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
+ +

Definition at line 3201 of file json.hpp.

+ +
+
+
+
+ + + + diff --git a/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html b/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html index c7fc76aa0..63cb409b9 100644 --- a/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html +++ b/classnlohmann_1_1basic__json_ae874cfc1746b560c53a03bcf5b7bbeed.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html b/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html index 0801a33e8..89151b305 100644 --- a/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html +++ b/classnlohmann_1_1basic__json_ae928414b2805cf6ef56b4e4f8d235416.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -251,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 06a8eb27c..38a3fc3ef 100644 --- a/classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html +++ b/classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -269,13 +271,13 @@ 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:2718
+
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2720
namespace for Niels Lohmann
Definition: json.hpp:79
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 2950 of file json.hpp.

+

Definition at line 2952 of file json.hpp.

@@ -285,7 +287,7 @@ operator[] with null" diff --git a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html index c34f850d5..686831d90 100644 --- a/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html +++ b/classnlohmann_1_1basic__json_aea1c863b719b4ca5b77188c171bbfafe.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -281,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 2fb0189b6..7e0b6908c 100644 --- a/classnlohmann_1_1basic__json_af073eec08d2e68924098aef09e9a10ba.html +++ b/classnlohmann_1_1basic__json_af073eec08d2e68924098aef09e9a10ba.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -262,13 +264,13 @@ template<template< typename U, typename V, typename...Args > class Obje
Complexity
Constant.
Example
The example below shows how JSON arrays can be swapped.
1 #include <json.hpp>
2 
3 using 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:4566
+
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
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 4566 of file json.hpp.

+

Definition at line 4632 of file json.hpp.

@@ -278,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 f3597b501..a0dd33438 100644 --- a/classnlohmann_1_1basic__json_af0ebd1757acb971a6504b4acabf88584.html +++ b/classnlohmann_1_1basic__json_af0ebd1757acb971a6504b4acabf88584.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -264,13 +266,13 @@ Illustration from cppreference.com
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:3816
+
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
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 3816 of file json.hpp.

+

Definition at line 3882 of file json.hpp.

@@ -280,7 +282,7 @@ Illustration from cppreference.com diff --git a/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html b/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html index 0a410380a..6488ff03f 100644 --- a/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html +++ b/classnlohmann_1_1basic__json_af127fb69c580c17821da5f5be57e3585.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -285,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 d43fd7258..329547044 100644 --- a/classnlohmann_1_1basic__json_af1e3f9e079136abca2530c8191c56292.html +++ b/classnlohmann_1_1basic__json_af1e3f9e079136abca2530c8191c56292.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -302,7 +304,7 @@ initializer list"
Complexity
Linear in the size of the initializer list init.
-
Example
The example below shows how JSON values are created from initializer lists
1 #include <json.hpp>
2 
3 using 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:8048
+
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
Output (play with this example online):
{}
@@ -326,7 +328,7 @@ initializer list"
 
diff --git a/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html b/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html index 02cf008d2..5cf30d62f 100644 --- a/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html +++ b/classnlohmann_1_1basic__json_af2730bc8ffa6b28916875c13ee7b83f5.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -272,12 +274,12 @@ 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:8048
+
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
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:5137
+
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
Output (play with this example online):
{
     "Image": {
@@ -317,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 5137 of file json.hpp.

+

Definition at line 5203 of file json.hpp.

@@ -327,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 ee05b36c8..3d9f15313 100644 --- a/classnlohmann_1_1basic__json_af661bc209bf22097e2f76607a11b56bf.html +++ b/classnlohmann_1_1basic__json_af661bc209bf22097e2f76607a11b56bf.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -277,7 +279,7 @@ false diff --git a/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html b/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html index 7fa515b07..5155e41ba 100644 --- a/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html +++ b/classnlohmann_1_1basic__json_af6b6050ccd906dddf7c9f47fe3ad62a5.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -269,14 +271,14 @@ 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:2718
+
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:2720
namespace for Niels Lohmann
Definition: json.hpp:79
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 2762 of file json.hpp.

+

Definition at line 2764 of file json.hpp.

@@ -286,7 +288,7 @@ out of range diff --git a/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html b/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html index 6915ea21c..663a72bb1 100644 --- a/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html +++ b/classnlohmann_1_1basic__json_af709c079de0ac3507143ea2c60699bd0.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); operator[] operator[] operator[] - operator[] - operator[] + operator[] + operator[] + operator[] + operator[] parse parse parse @@ -235,7 +237,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
-template<typename ValueType , typename std::enable_if< not std::is_pointer< ValueType >::value and not std::is_same< ValueType, typename string_t::value_type >::value and not std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>::value , int >::type = 0>
+template<typename ValueType , typename std::enable_if< not std::is_pointer< ValueType >::value and not std::is_same< ValueType, typename string_t::value_type >::value and not std::is_same< ValueType, std::initializer_list< typename string_t::value_type >>::value , int >::type = 0> - - + + + + @@ -295,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 2991 of file json.hpp.

+

Definition at line 2993 of file json.hpp.

@@ -305,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 3b653c90f..903dd3996 100644 --- a/classnlohmann_1_1basic__json_af7d0adc984d04fc70c3d29fcd63e096a.html +++ b/classnlohmann_1_1basic__json_af7d0adc984d04fc70c3d29fcd63e096a.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); - - + + + + @@ -280,15 +282,15 @@ 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:3699
+
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:4361
+
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:4427
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 4361 of file json.hpp.

+

Definition at line 4427 of file json.hpp.

@@ -298,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 e9c924475..ddf9791b3 100644 --- a/classnlohmann_1_1basic__json_afc4223b5ad03b1b76e925374a8fff98e.html +++ b/classnlohmann_1_1basic__json_afc4223b5ad03b1b76e925374a8fff98e.html @@ -195,8 +195,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); - - + + + + @@ -289,7 +291,7 @@ template<template< typename U, typename V, typename...Args > class Obje diff --git a/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/dir_68267d1309a1af8e8297ef4c3efbcdba.html index d8664c8e1..2bb857098 100644 --- a/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -92,7 +92,7 @@ Files diff --git a/functions.html b/functions.html index e2a7789cf..ddab415b2 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 60417f8cf..00caab95f 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 9d7f5bff5..1b6079a17 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 fec50f3f3..876ca287d 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 1e4ea7b4c..df878037e 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 3bd93d598..30075a3bd 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 e79228c1c..dc064af6c 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 d7e6f7c5b..47cbf8f7d 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 6042e1603..7b8e2c517 100644 --- a/functions_func.html +++ b/functions_func.html @@ -356,7 +356,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : nlohmann::basic_json::const_iterator , nlohmann::basic_json::iterator , nlohmann::basic_json::json_reverse_iterator< Base > -, nlohmann::basic_json +, nlohmann::basic_json @@ -416,7 +416,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_g.html b/functions_g.html index 642638b60..721ed0ead 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 a1e5de506..108acfda3 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 830788382..bebcc64e8 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 da8356fe4..ea482d1db 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 2bcba0f90..5c160368c 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 c805af5b6..420a3cf19 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 86e92979f..613bf10fd 100644 --- a/functions_o.html +++ b/functions_o.html @@ -180,7 +180,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , nlohmann::basic_json
  • operator<< -: nlohmann::basic_json +: nlohmann::basic_json
  • operator<=() : nlohmann::basic_json::const_iterator @@ -193,7 +193,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • operator==() : nlohmann::basic_json::const_iterator -, nlohmann::basic_json +, nlohmann::basic_json
  • operator>() : nlohmann::basic_json::const_iterator @@ -204,19 +204,19 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , nlohmann::basic_json
  • operator>> -: nlohmann::basic_json +: nlohmann::basic_json
  • operator[]() : nlohmann::basic_json::const_iterator , nlohmann::basic_json::iterator , nlohmann::basic_json::json_reverse_iterator< Base > -, nlohmann::basic_json +, nlohmann::basic_json
  • diff --git a/functions_p.html b/functions_p.html index 5406ae006..f22cb6df7 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 493f6560f..200060f1f 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 093ebb34d..abcab2073 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 8b1ec0c39..984dc3e0a 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 fb9dd8fbf..51d6a5e92 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 bd497b418..1757f9020 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 ac73f4287..75a49563c 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 17be06950..66a5065ab 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 a8d6d202e..dcad75a46 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 e9f93b838..39979c0b7 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 47f2824cb..3eb653d9b 100644 --- a/json_8hpp_source.html +++ b/json_8hpp_source.html @@ -83,215 +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  and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
    2679  , int>::type = 0>
    2680  operator ValueType() const
    2681  {
    2682  // delegate the call to get<>() const
    2683  return get<ValueType>();
    2684  }
    2685 
    2687 
    2688 
    2690  // element access //
    2692 
    2695 
    2719  {
    2720  // at only works for arrays
    2721  if (is_array())
    2722  {
    2723  try
    2724  {
    2725  assert(m_value.array != nullptr);
    2726  return m_value.array->at(idx);
    2727  }
    2728  catch (std::out_of_range&)
    2729  {
    2730  // create better exception explanation
    2731  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2732  }
    2733  }
    2734  else
    2735  {
    2736  throw std::domain_error("cannot use at() with " + type_name());
    2737  }
    2738  }
    2739 
    2763  {
    2764  // at only works for arrays
    2765  if (is_array())
    2766  {
    2767  try
    2768  {
    2769  assert(m_value.array != nullptr);
    2770  return m_value.array->at(idx);
    2771  }
    2772  catch (std::out_of_range&)
    2773  {
    2774  // create better exception explanation
    2775  throw std::out_of_range("array index " + std::to_string(idx) + " is out of range");
    2776  }
    2777  }
    2778  else
    2779  {
    2780  throw std::domain_error("cannot use at() with " + type_name());
    2781  }
    2782  }
    2783 
    2810  reference at(const typename object_t::key_type& key)
    2811  {
    2812  // at only works for objects
    2813  if (is_object())
    2814  {
    2815  try
    2816  {
    2817  assert(m_value.object != nullptr);
    2818  return m_value.object->at(key);
    2819  }
    2820  catch (std::out_of_range&)
    2821  {
    2822  // create better exception explanation
    2823  throw std::out_of_range("key '" + key + "' not found");
    2824  }
    2825  }
    2826  else
    2827  {
    2828  throw std::domain_error("cannot use at() with " + type_name());
    2829  }
    2830  }
    2831 
    2858  const_reference at(const typename object_t::key_type& key) const
    2859  {
    2860  // at only works for objects
    2861  if (is_object())
    2862  {
    2863  try
    2864  {
    2865  assert(m_value.object != nullptr);
    2866  return m_value.object->at(key);
    2867  }
    2868  catch (std::out_of_range&)
    2869  {
    2870  // create better exception explanation
    2871  throw std::out_of_range("key '" + key + "' not found");
    2872  }
    2873  }
    2874  else
    2875  {
    2876  throw std::domain_error("cannot use at() with " + type_name());
    2877  }
    2878  }
    2879 
    2906  {
    2907  // implicitly convert null to object
    2908  if (is_null())
    2909  {
    2910  m_type = value_t::array;
    2911  m_value.array = create<array_t>();
    2912  }
    2913 
    2914  // [] only works for arrays
    2915  if (is_array())
    2916  {
    2917  assert(m_value.array != nullptr);
    2918  for (size_t i = m_value.array->size(); i <= idx; ++i)
    2919  {
    2920  m_value.array->push_back(basic_json());
    2921  }
    2922 
    2923  return m_value.array->operator[](idx);
    2924  }
    2925  else
    2926  {
    2927  throw std::domain_error("cannot use operator[] with " + type_name());
    2928  }
    2929  }
    2930 
    2951  {
    2952  // at only works for arrays
    2953  if (is_array())
    2954  {
    2955  assert(m_value.array != nullptr);
    2956  return m_value.array->operator[](idx);
    2957  }
    2958  else
    2959  {
    2960  throw std::domain_error("cannot use operator[] with " + type_name());
    2961  }
    2962  }
    2963 
    2991  reference operator[](const typename object_t::key_type& key)
    2992  {
    2993  // implicitly convert null to object
    2994  if (is_null())
    2995  {
    2996  m_type = value_t::object;
    2997  m_value.object = create<object_t>();
    2998  }
    2999 
    3000  // [] only works for objects
    3001  if (is_object())
    3002  {
    3003  assert(m_value.object != nullptr);
    3004  return m_value.object->operator[](key);
    3005  }
    3006  else
    3007  {
    3008  throw std::domain_error("cannot use operator[] with " + type_name());
    3009  }
    3010  }
    3011 
    3039  const_reference operator[](const typename object_t::key_type& key) const
    3040  {
    3041  // [] only works for objects
    3042  if (is_object())
    3043  {
    3044  assert(m_value.object != nullptr);
    3045  assert(m_value.object->find(key) != m_value.object->end());
    3046  return m_value.object->find(key)->second;
    3047  }
    3048  else
    3049  {
    3050  throw std::domain_error("cannot use operator[] with " + type_name());
    3051  }
    3052  }
    3053 
    3083  template<typename T, std::size_t n>
    3084  reference operator[](const T (&key)[n])
    3085  {
    3086  // implicitly convert null to object
    3087  if (is_null())
    3088  {
    3089  m_type = value_t::object;
    3090  m_value = value_t::object;
    3091  }
    3092 
    3093  // at only works for objects
    3094  if (is_object())
    3095  {
    3096  assert(m_value.object != nullptr);
    3097  return m_value.object->operator[](key);
    3098  }
    3099  else
    3100  {
    3101  throw std::domain_error("cannot use operator[] with " + type_name());
    3102  }
    3103  }
    3104 
    3134  template<typename T, std::size_t n>
    3135  const_reference operator[](const T (&key)[n]) const
    3136  {
    3137  // at only works for objects
    3138  if (is_object())
    3139  {
    3140  assert(m_value.object != nullptr);
    3141  assert(m_value.object->find(key) != m_value.object->end());
    3142  return m_value.object->find(key)->second;
    3143  }
    3144  else
    3145  {
    3146  throw std::domain_error("cannot use operator[] with " + type_name());
    3147  }
    3148  }
    3149 
    3198  template <class ValueType, typename
    3199  std::enable_if<
    3200  std::is_convertible<basic_json_t, ValueType>::value
    3201  , int>::type = 0>
    3202  ValueType value(const typename object_t::key_type& key, ValueType default_value) const
    3203  {
    3204  // at only works for objects
    3205  if (is_object())
    3206  {
    3207  // if key is found, return value and given default value otherwise
    3208  const auto it = find(key);
    3209  if (it != end())
    3210  {
    3211  return *it;
    3212  }
    3213  else
    3214  {
    3215  return default_value;
    3216  }
    3217  }
    3218  else
    3219  {
    3220  throw std::domain_error("cannot use value() with " + type_name());
    3221  }
    3222  }
    3223 
    3228  string_t value(const typename object_t::key_type& key, const char* default_value) const
    3229  {
    3230  return value(key, string_t(default_value));
    3231  }
    3232 
    3254  {
    3255  return *begin();
    3256  }
    3257 
    3262  {
    3263  return *cbegin();
    3264  }
    3265 
    3288  {
    3289  auto tmp = end();
    3290  --tmp;
    3291  return *tmp;
    3292  }
    3293 
    3298  {
    3299  auto tmp = cend();
    3300  --tmp;
    3301  return *tmp;
    3302  }
    3303 
    3348  template <class InteratorType, typename
    3349  std::enable_if<
    3350  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3351  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3352  , int>::type
    3353  = 0>
    3354  InteratorType erase(InteratorType pos)
    3355  {
    3356  // make sure iterator fits the current value
    3357  if (this != pos.m_object)
    3358  {
    3359  throw std::domain_error("iterator does not fit current value");
    3360  }
    3361 
    3362  InteratorType result = end();
    3363 
    3364  switch (m_type)
    3365  {
    3366  case value_t::boolean:
    3367  case value_t::number_float:
    3368  case value_t::number_integer:
    3369  case value_t::string:
    3370  {
    3371  if (not pos.m_it.primitive_iterator.is_begin())
    3372  {
    3373  throw std::out_of_range("iterator out of range");
    3374  }
    3375 
    3376  if (is_string())
    3377  {
    3378  delete m_value.string;
    3379  m_value.string = nullptr;
    3380  }
    3381 
    3382  m_type = value_t::null;
    3383  break;
    3384  }
    3385 
    3386  case value_t::object:
    3387  {
    3388  assert(m_value.object != nullptr);
    3389  result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
    3390  break;
    3391  }
    3392 
    3393  case value_t::array:
    3394  {
    3395  assert(m_value.array != nullptr);
    3396  result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
    3397  break;
    3398  }
    3399 
    3400  default:
    3401  {
    3402  throw std::domain_error("cannot use erase() with " + type_name());
    3403  }
    3404  }
    3405 
    3406  return result;
    3407  }
    3408 
    3453  template <class InteratorType, typename
    3454  std::enable_if<
    3455  std::is_same<InteratorType, typename basic_json_t::iterator>::value or
    3456  std::is_same<InteratorType, typename basic_json_t::const_iterator>::value
    3457  , int>::type
    3458  = 0>
    3459  InteratorType erase(InteratorType first, InteratorType last)
    3460  {
    3461  // make sure iterator fits the current value
    3462  if (this != first.m_object or this != last.m_object)
    3463  {
    3464  throw std::domain_error("iterators do not fit current value");
    3465  }
    3466 
    3467  InteratorType result = end();
    3468 
    3469  switch (m_type)
    3470  {
    3471  case value_t::boolean:
    3472  case value_t::number_float:
    3473  case value_t::number_integer:
    3474  case value_t::string:
    3475  {
    3476  if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
    3477  {
    3478  throw std::out_of_range("iterators out of range");
    3479  }
    3480 
    3481  if (is_string())
    3482  {
    3483  delete m_value.string;
    3484  m_value.string = nullptr;
    3485  }
    3486 
    3487  m_type = value_t::null;
    3488  break;
    3489  }
    3490 
    3491  case value_t::object:
    3492  {
    3493  assert(m_value.object != nullptr);
    3494  result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
    3495  last.m_it.object_iterator);
    3496  break;
    3497  }
    3498 
    3499  case value_t::array:
    3500  {
    3501  assert(m_value.array != nullptr);
    3502  result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
    3503  last.m_it.array_iterator);
    3504  break;
    3505  }
    3506 
    3507  default:
    3508  {
    3509  throw std::domain_error("cannot use erase() with " + type_name());
    3510  }
    3511  }
    3512 
    3513  return result;
    3514  }
    3515 
    3542  size_type erase(const typename object_t::key_type& key)
    3543  {
    3544  // this erase only works for objects
    3545  if (is_object())
    3546  {
    3547  assert(m_value.object != nullptr);
    3548  return m_value.object->erase(key);
    3549  }
    3550  else
    3551  {
    3552  throw std::domain_error("cannot use erase() with " + type_name());
    3553  }
    3554  }
    3555 
    3580  void erase(const size_type idx)
    3581  {
    3582  // this erase only works for arrays
    3583  if (is_array())
    3584  {
    3585  if (idx >= size())
    3586  {
    3587  throw std::out_of_range("index out of range");
    3588  }
    3589 
    3590  assert(m_value.array != nullptr);
    3591  m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
    3592  }
    3593  else
    3594  {
    3595  throw std::domain_error("cannot use erase() with " + type_name());
    3596  }
    3597  }
    3598 
    3616  iterator find(typename object_t::key_type key)
    3617  {
    3618  auto result = end();
    3619 
    3620  if (is_object())
    3621  {
    3622  assert(m_value.object != nullptr);
    3623  result.m_it.object_iterator = m_value.object->find(key);
    3624  }
    3625 
    3626  return result;
    3627  }
    3628 
    3633  const_iterator find(typename object_t::key_type key) const
    3634  {
    3635  auto result = cend();
    3636 
    3637  if (is_object())
    3638  {
    3639  assert(m_value.object != nullptr);
    3640  result.m_it.object_iterator = m_value.object->find(key);
    3641  }
    3642 
    3643  return result;
    3644  }
    3645 
    3664  size_type count(typename object_t::key_type key) const
    3665  {
    3666  // return 0 for all nonobject types
    3667  assert(not is_object() or m_value.object != nullptr);
    3668  return is_object() ? m_value.object->count(key) : 0;
    3669  }
    3670 
    3672 
    3673 
    3675  // iterators //
    3677 
    3680 
    3700  {
    3701  iterator result(this);
    3702  result.set_begin();
    3703  return result;
    3704  }
    3705 
    3710  {
    3711  return cbegin();
    3712  }
    3713 
    3734  {
    3735  const_iterator result(this);
    3736  result.set_begin();
    3737  return result;
    3738  }
    3739 
    3759  {
    3760  iterator result(this);
    3761  result.set_end();
    3762  return result;
    3763  }
    3764 
    3769  {
    3770  return cend();
    3771  }
    3772 
    3793  {
    3794  const_iterator result(this);
    3795  result.set_end();
    3796  return result;
    3797  }
    3798 
    3817  {
    3818  return reverse_iterator(end());
    3819  }
    3820 
    3825  {
    3826  return crbegin();
    3827  }
    3828 
    3848  {
    3849  return reverse_iterator(begin());
    3850  }
    3851 
    3856  {
    3857  return crend();
    3858  }
    3859 
    3879  {
    3880  return const_reverse_iterator(cend());
    3881  }
    3882 
    3902  {
    3903  return const_reverse_iterator(cbegin());
    3904  }
    3905 
    3906  private:
    3907  // forward declaration
    3908  template<typename IteratorType> class iteration_proxy;
    3909 
    3910  public:
    3922  static iteration_proxy<iterator> iterator_wrapper(reference cont)
    3923  {
    3924  return iteration_proxy<iterator>(cont);
    3925  }
    3926 
    3930  static iteration_proxy<const_iterator> iterator_wrapper(const_reference cont)
    3931  {
    3932  return iteration_proxy<const_iterator>(cont);
    3933  }
    3934 
    3936 
    3937 
    3939  // capacity //
    3941 
    3944 
    3974  bool empty() const noexcept
    3975  {
    3976  switch (m_type)
    3977  {
    3978  case value_t::null:
    3979  {
    3980  // null values are empty
    3981  return true;
    3982  }
    3983 
    3984  case value_t::array:
    3985  {
    3986  assert(m_value.array != nullptr);
    3987  return m_value.array->empty();
    3988  }
    3989 
    3990  case value_t::object:
    3991  {
    3992  assert(m_value.object != nullptr);
    3993  return m_value.object->empty();
    3994  }
    3995 
    3996  default:
    3997  {
    3998  // all other types are nonempty
    3999  return false;
    4000  }
    4001  }
    4002  }
    4003 
    4032  size_type size() const noexcept
    4033  {
    4034  switch (m_type)
    4035  {
    4036  case value_t::null:
    4037  {
    4038  // null values are empty
    4039  return 0;
    4040  }
    4041 
    4042  case value_t::array:
    4043  {
    4044  assert(m_value.array != nullptr);
    4045  return m_value.array->size();
    4046  }
    4047 
    4048  case value_t::object:
    4049  {
    4050  assert(m_value.object != nullptr);
    4051  return m_value.object->size();
    4052  }
    4053 
    4054  default:
    4055  {
    4056  // all other types have size 1
    4057  return 1;
    4058  }
    4059  }
    4060  }
    4061 
    4094  size_type max_size() const noexcept
    4095  {
    4096  switch (m_type)
    4097  {
    4098  case value_t::array:
    4099  {
    4100  assert(m_value.array != nullptr);
    4101  return m_value.array->max_size();
    4102  }
    4103 
    4104  case value_t::object:
    4105  {
    4106  assert(m_value.object != nullptr);
    4107  return m_value.object->max_size();
    4108  }
    4109 
    4110  default:
    4111  {
    4112  // all other types have max_size() == size()
    4113  return size();
    4114  }
    4115  }
    4116  }
    4117 
    4119 
    4120 
    4122  // modifiers //
    4124 
    4127 
    4153  void clear() noexcept
    4154  {
    4155  switch (m_type)
    4156  {
    4157  case value_t::number_integer:
    4158  {
    4159  m_value.number_integer = 0;
    4160  break;
    4161  }
    4162 
    4163  case value_t::number_float:
    4164  {
    4165  m_value.number_float = 0.0;
    4166  break;
    4167  }
    4168 
    4169  case value_t::boolean:
    4170  {
    4171  m_value.boolean = false;
    4172  break;
    4173  }
    4174 
    4175  case value_t::string:
    4176  {
    4177  assert(m_value.string != nullptr);
    4178  m_value.string->clear();
    4179  break;
    4180  }
    4181 
    4182  case value_t::array:
    4183  {
    4184  assert(m_value.array != nullptr);
    4185  m_value.array->clear();
    4186  break;
    4187  }
    4188 
    4189  case value_t::object:
    4190  {
    4191  assert(m_value.object != nullptr);
    4192  m_value.object->clear();
    4193  break;
    4194  }
    4195 
    4196  default:
    4197  {
    4198  break;
    4199  }
    4200  }
    4201  }
    4202 
    4223  void push_back(basic_json&& val)
    4224  {
    4225  // push_back only works for null objects or arrays
    4226  if (not(is_null() or is_array()))
    4227  {
    4228  throw std::domain_error("cannot use push_back() with " + type_name());
    4229  }
    4230 
    4231  // transform null object into an array
    4232  if (is_null())
    4233  {
    4234  m_type = value_t::array;
    4235  m_value = value_t::array;
    4236  }
    4237 
    4238  // add element to array (move semantics)
    4239  assert(m_value.array != nullptr);
    4240  m_value.array->push_back(std::move(val));
    4241  // invalidate object
    4242  val.m_type = value_t::null;
    4243  }
    4244 
    4249  reference operator+=(basic_json&& val)
    4250  {
    4251  push_back(std::move(val));
    4252  return *this;
    4253  }
    4254 
    4259  void push_back(const basic_json& val)
    4260  {
    4261  // push_back only works for null objects or arrays
    4262  if (not(is_null() or is_array()))
    4263  {
    4264  throw std::domain_error("cannot use push_back() with " + type_name());
    4265  }
    4266 
    4267  // transform null object into an array
    4268  if (is_null())
    4269  {
    4270  m_type = value_t::array;
    4271  m_value = value_t::array;
    4272  }
    4273 
    4274  // add element to array
    4275  assert(m_value.array != nullptr);
    4276  m_value.array->push_back(val);
    4277  }
    4278 
    4283  reference operator+=(const basic_json& val)
    4284  {
    4285  push_back(val);
    4286  return *this;
    4287  }
    4288 
    4309  void push_back(const typename object_t::value_type& val)
    4310  {
    4311  // push_back only works for null objects or objects
    4312  if (not(is_null() or is_object()))
    4313  {
    4314  throw std::domain_error("cannot use push_back() with " + type_name());
    4315  }
    4316 
    4317  // transform null object into an object
    4318  if (is_null())
    4319  {
    4320  m_type = value_t::object;
    4321  m_value = value_t::object;
    4322  }
    4323 
    4324  // add element to array
    4325  assert(m_value.object != nullptr);
    4326  m_value.object->insert(val);
    4327  }
    4328 
    4333  reference operator+=(const typename object_t::value_type& val)
    4334  {
    4335  push_back(val);
    4336  return operator[](val.first);
    4337  }
    4338 
    4361  iterator insert(const_iterator pos, const basic_json& val)
    4362  {
    4363  // insert only works for arrays
    4364  if (is_array())
    4365  {
    4366  // check if iterator pos fits to this JSON value
    4367  if (pos.m_object != this)
    4368  {
    4369  throw std::domain_error("iterator does not fit current value");
    4370  }
    4371 
    4372  // insert to array and return iterator
    4373  iterator result(this);
    4374  assert(m_value.array != nullptr);
    4375  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
    4376  return result;
    4377  }
    4378  else
    4379  {
    4380  throw std::domain_error("cannot use insert() with " + type_name());
    4381  }
    4382  }
    4383 
    4388  iterator insert(const_iterator pos, basic_json&& val)
    4389  {
    4390  return insert(pos, val);
    4391  }
    4392 
    4417  iterator insert(const_iterator pos, size_type cnt, const basic_json& val)
    4418  {
    4419  // insert only works for arrays
    4420  if (is_array())
    4421  {
    4422  // check if iterator pos fits to this JSON value
    4423  if (pos.m_object != this)
    4424  {
    4425  throw std::domain_error("iterator does not fit current value");
    4426  }
    4427 
    4428  // insert to array and return iterator
    4429  iterator result(this);
    4430  assert(m_value.array != nullptr);
    4431  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val);
    4432  return result;
    4433  }
    4434  else
    4435  {
    4436  throw std::domain_error("cannot use insert() with " + type_name());
    4437  }
    4438  }
    4439 
    4471  {
    4472  // insert only works for arrays
    4473  if (not is_array())
    4474  {
    4475  throw std::domain_error("cannot use insert() with " + type_name());
    4476  }
    4477 
    4478  // check if iterator pos fits to this JSON value
    4479  if (pos.m_object != this)
    4480  {
    4481  throw std::domain_error("iterator does not fit current value");
    4482  }
    4483 
    4484  if (first.m_object != last.m_object)
    4485  {
    4486  throw std::domain_error("iterators do not fit");
    4487  }
    4488 
    4489  if (first.m_object == this or last.m_object == this)
    4490  {
    4491  throw std::domain_error("passed iterators may not belong to container");
    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(
    4498  pos.m_it.array_iterator,
    4499  first.m_it.array_iterator,
    4500  last.m_it.array_iterator);
    4501  return result;
    4502  }
    4503 
    4528  iterator insert(const_iterator pos, std::initializer_list<basic_json> ilist)
    4529  {
    4530  // insert only works for arrays
    4531  if (not is_array())
    4532  {
    4533  throw std::domain_error("cannot use insert() with " + type_name());
    4534  }
    4535 
    4536  // check if iterator pos fits to this JSON value
    4537  if (pos.m_object != this)
    4538  {
    4539  throw std::domain_error("iterator does not fit current value");
    4540  }
    4541 
    4542  // insert to array and return iterator
    4543  iterator result(this);
    4544  assert(m_value.array != nullptr);
    4545  result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, ilist);
    4546  return result;
    4547  }
    4548 
    4566  void swap(reference other) noexcept (
    4567  std::is_nothrow_move_constructible<value_t>::value and
    4568  std::is_nothrow_move_assignable<value_t>::value and
    4569  std::is_nothrow_move_constructible<json_value>::value and
    4570  std::is_nothrow_move_assignable<json_value>::value
    4571  )
    4572  {
    4573  std::swap(m_type, other.m_type);
    4574  std::swap(m_value, other.m_value);
    4575  }
    4576 
    4597  void swap(array_t& other)
    4598  {
    4599  // swap only works for arrays
    4600  if (is_array())
    4601  {
    4602  assert(m_value.array != nullptr);
    4603  std::swap(*(m_value.array), other);
    4604  }
    4605  else
    4606  {
    4607  throw std::domain_error("cannot use swap() with " + type_name());
    4608  }
    4609  }
    4610 
    4631  void swap(object_t& other)
    4632  {
    4633  // swap only works for objects
    4634  if (is_object())
    4635  {
    4636  assert(m_value.object != nullptr);
    4637  std::swap(*(m_value.object), other);
    4638  }
    4639  else
    4640  {
    4641  throw std::domain_error("cannot use swap() with " + type_name());
    4642  }
    4643  }
    4644 
    4665  void swap(string_t& other)
    4666  {
    4667  // swap only works for strings
    4668  if (is_string())
    4669  {
    4670  assert(m_value.string != nullptr);
    4671  std::swap(*(m_value.string), other);
    4672  }
    4673  else
    4674  {
    4675  throw std::domain_error("cannot use swap() with " + type_name());
    4676  }
    4677  }
    4678 
    4680 
    4681 
    4683  // lexicographical comparison operators //
    4685 
    4688 
    4689  private:
    4699  friend bool operator<(const value_t lhs, const value_t rhs)
    4700  {
    4701  static constexpr std::array<uint8_t, 7> order = {{
    4702  0, // null
    4703  3, // object
    4704  4, // array
    4705  5, // string
    4706  1, // boolean
    4707  2, // integer
    4708  2 // float
    4709  }
    4710  };
    4711 
    4712  // discarded values are not comparable
    4713  if (lhs == value_t::discarded or rhs == value_t::discarded)
    4714  {
    4715  return false;
    4716  }
    4717 
    4718  return order[static_cast<std::size_t>(lhs)] < order[static_cast<std::size_t>(rhs)];
    4719  }
    4720 
    4721  public:
    4745  friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    4746  {
    4747  const auto lhs_type = lhs.type();
    4748  const auto rhs_type = rhs.type();
    4749 
    4750  if (lhs_type == rhs_type)
    4751  {
    4752  switch (lhs_type)
    4753  {
    4754  case value_t::array:
    4755  {
    4756  assert(lhs.m_value.array != nullptr);
    4757  assert(rhs.m_value.array != nullptr);
    4758  return *lhs.m_value.array == *rhs.m_value.array;
    4759  }
    4760  case value_t::object:
    4761  {
    4762  assert(lhs.m_value.object != nullptr);
    4763  assert(rhs.m_value.object != nullptr);
    4764  return *lhs.m_value.object == *rhs.m_value.object;
    4765  }
    4766  case value_t::null:
    4767  {
    4768  return true;
    4769  }
    4770  case value_t::string:
    4771  {
    4772  assert(lhs.m_value.string != nullptr);
    4773  assert(rhs.m_value.string != nullptr);
    4774  return *lhs.m_value.string == *rhs.m_value.string;
    4775  }
    4776  case value_t::boolean:
    4777  {
    4778  return lhs.m_value.boolean == rhs.m_value.boolean;
    4779  }
    4780  case value_t::number_integer:
    4781  {
    4782  return lhs.m_value.number_integer == rhs.m_value.number_integer;
    4783  }
    4784  case value_t::number_float:
    4785  {
    4786  return approx(lhs.m_value.number_float, rhs.m_value.number_float);
    4787  }
    4788  default:
    4789  {
    4790  return false;
    4791  }
    4792  }
    4793  }
    4794  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    4795  {
    4796  return approx(static_cast<number_float_t>(lhs.m_value.number_integer),
    4797  rhs.m_value.number_float);
    4798  }
    4799  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    4800  {
    4801  return approx(lhs.m_value.number_float,
    4802  static_cast<number_float_t>(rhs.m_value.number_integer));
    4803  }
    4804  return false;
    4805  }
    4806 
    4825  friend bool operator==(const_reference v, std::nullptr_t) noexcept
    4826  {
    4827  return v.is_null();
    4828  }
    4829 
    4834  friend bool operator==(std::nullptr_t, const_reference v) noexcept
    4835  {
    4836  return v.is_null();
    4837  }
    4838 
    4855  friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    4856  {
    4857  return not (lhs == rhs);
    4858  }
    4859 
    4878  friend bool operator!=(const_reference v, std::nullptr_t) noexcept
    4879  {
    4880  return not v.is_null();
    4881  }
    4882 
    4887  friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    4888  {
    4889  return not v.is_null();
    4890  }
    4891 
    4916  friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    4917  {
    4918  const auto lhs_type = lhs.type();
    4919  const auto rhs_type = rhs.type();
    4920 
    4921  if (lhs_type == rhs_type)
    4922  {
    4923  switch (lhs_type)
    4924  {
    4925  case value_t::array:
    4926  {
    4927  assert(lhs.m_value.array != nullptr);
    4928  assert(rhs.m_value.array != nullptr);
    4929  return *lhs.m_value.array < *rhs.m_value.array;
    4930  }
    4931  case value_t::object:
    4932  {
    4933  assert(lhs.m_value.object != nullptr);
    4934  assert(rhs.m_value.object != nullptr);
    4935  return *lhs.m_value.object < *rhs.m_value.object;
    4936  }
    4937  case value_t::null:
    4938  {
    4939  return false;
    4940  }
    4941  case value_t::string:
    4942  {
    4943  assert(lhs.m_value.string != nullptr);
    4944  assert(rhs.m_value.string != nullptr);
    4945  return *lhs.m_value.string < *rhs.m_value.string;
    4946  }
    4947  case value_t::boolean:
    4948  {
    4949  return lhs.m_value.boolean < rhs.m_value.boolean;
    4950  }
    4951  case value_t::number_integer:
    4952  {
    4953  return lhs.m_value.number_integer < rhs.m_value.number_integer;
    4954  }
    4955  case value_t::number_float:
    4956  {
    4957  return lhs.m_value.number_float < rhs.m_value.number_float;
    4958  }
    4959  default:
    4960  {
    4961  return false;
    4962  }
    4963  }
    4964  }
    4965  else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
    4966  {
    4967  return static_cast<number_float_t>(lhs.m_value.number_integer) <
    4968  rhs.m_value.number_float;
    4969  }
    4970  else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
    4971  {
    4972  return lhs.m_value.number_float <
    4973  static_cast<number_float_t>(rhs.m_value.number_integer);
    4974  }
    4975 
    4976  // We only reach this line if we cannot compare values. In that case,
    4977  // we compare types. Note we have to call the operator explicitly,
    4978  // because MSVC has problems otherwise.
    4979  return operator<(lhs_type, rhs_type);
    4980  }
    4981 
    4999  friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    5000  {
    5001  return not (rhs < lhs);
    5002  }
    5003 
    5021  friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    5022  {
    5023  return not (lhs <= rhs);
    5024  }
    5025 
    5043  friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
    5044  {
    5045  return not (lhs < rhs);
    5046  }
    5047 
    5049 
    5050 
    5052  // serialization //
    5054 
    5057 
    5080  friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
    5081  {
    5082  // read width member and use it as indentation parameter if nonzero
    5083  const bool pretty_print = (o.width() > 0);
    5084  const auto indentation = (pretty_print ? o.width() : 0);
    5085 
    5086  // reset width to 0 for subsequent calls to this stream
    5087  o.width(0);
    5088 
    5089  // do the actual serialization
    5090  j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
    5091  return o;
    5092  }
    5093 
    5098  friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
    5099  {
    5100  return o << j;
    5101  }
    5102 
    5104 
    5105 
    5107  // deserialization //
    5109 
    5112 
    5137  static basic_json parse(const string_t& s, parser_callback_t cb = nullptr)
    5138  {
    5139  return parser(s, cb).parse();
    5140  }
    5141 
    5166  static basic_json parse(std::istream& i, parser_callback_t cb = nullptr)
    5167  {
    5168  return parser(i, cb).parse();
    5169  }
    5170 
    5174  static basic_json parse(std::istream&& i, parser_callback_t cb = nullptr)
    5175  {
    5176  return parser(i, cb).parse();
    5177  }
    5178 
    5202  friend std::istream& operator<<(basic_json& j, std::istream& i)
    5203  {
    5204  j = parser(i).parse();
    5205  return i;
    5206  }
    5207 
    5212  friend std::istream& operator>>(std::istream& i, basic_json& j)
    5213  {
    5214  j = parser(i).parse();
    5215  return i;
    5216  }
    5217 
    5219 
    5220 
    5221  private:
    5223  // convenience functions //
    5225 
    5227  string_t type_name() const
    5228  {
    5229  switch (m_type)
    5230  {
    5231  case value_t::null:
    5232  return "null";
    5233  case value_t::object:
    5234  return "object";
    5235  case value_t::array:
    5236  return "array";
    5237  case value_t::string:
    5238  return "string";
    5239  case value_t::boolean:
    5240  return "boolean";
    5241  case value_t::discarded:
    5242  return "discarded";
    5243  default:
    5244  return "number";
    5245  }
    5246  }
    5247 
    5256  static std::size_t extra_space(const string_t& s) noexcept
    5257  {
    5258  std::size_t result = 0;
    5259 
    5260  for (const auto& c : s)
    5261  {
    5262  switch (c)
    5263  {
    5264  case '"':
    5265  case '\\':
    5266  case '\b':
    5267  case '\f':
    5268  case '\n':
    5269  case '\r':
    5270  case '\t':
    5271  {
    5272  // from c (1 byte) to \x (2 bytes)
    5273  result += 1;
    5274  break;
    5275  }
    5276 
    5277  default:
    5278  {
    5279  if (c >= 0x00 and c <= 0x1f)
    5280  {
    5281  // from c (1 byte) to \uxxxx (6 bytes)
    5282  result += 5;
    5283  }
    5284  break;
    5285  }
    5286  }
    5287  }
    5288 
    5289  return result;
    5290  }
    5291 
    5305  static string_t escape_string(const string_t& s) noexcept
    5306  {
    5307  const auto space = extra_space(s);
    5308  if (space == 0)
    5309  {
    5310  return s;
    5311  }
    5312 
    5313  // create a result string of necessary size
    5314  string_t result(s.size() + space, '\\');
    5315  std::size_t pos = 0;
    5316 
    5317  for (const auto& c : s)
    5318  {
    5319  switch (c)
    5320  {
    5321  // quotation mark (0x22)
    5322  case '"':
    5323  {
    5324  result[pos + 1] = '"';
    5325  pos += 2;
    5326  break;
    5327  }
    5328 
    5329  // reverse solidus (0x5c)
    5330  case '\\':
    5331  {
    5332  // nothing to change
    5333  pos += 2;
    5334  break;
    5335  }
    5336 
    5337  // backspace (0x08)
    5338  case '\b':
    5339  {
    5340  result[pos + 1] = 'b';
    5341  pos += 2;
    5342  break;
    5343  }
    5344 
    5345  // formfeed (0x0c)
    5346  case '\f':
    5347  {
    5348  result[pos + 1] = 'f';
    5349  pos += 2;
    5350  break;
    5351  }
    5352 
    5353  // newline (0x0a)
    5354  case '\n':
    5355  {
    5356  result[pos + 1] = 'n';
    5357  pos += 2;
    5358  break;
    5359  }
    5360 
    5361  // carriage return (0x0d)
    5362  case '\r':
    5363  {
    5364  result[pos + 1] = 'r';
    5365  pos += 2;
    5366  break;
    5367  }
    5368 
    5369  // horizontal tab (0x09)
    5370  case '\t':
    5371  {
    5372  result[pos + 1] = 't';
    5373  pos += 2;
    5374  break;
    5375  }
    5376 
    5377  default:
    5378  {
    5379  if (c >= 0x00 and c <= 0x1f)
    5380  {
    5381  // convert a number 0..15 to its hex representation (0..f)
    5382  auto hexify = [](const char v) -> char
    5383  {
    5384  return (v < 10) ? ('0' + v) : ('a' + v - 10);
    5385  };
    5386 
    5387  // print character c as \uxxxx
    5388  for (const char m :
    5389  { 'u', '0', '0', hexify(c >> 4), hexify(c & 0x0f)
    5390  })
    5391  {
    5392  result[++pos] = m;
    5393  }
    5394 
    5395  ++pos;
    5396  }
    5397  else
    5398  {
    5399  // all other characters are added as-is
    5400  result[pos++] = c;
    5401  }
    5402  break;
    5403  }
    5404  }
    5405  }
    5406 
    5407  return result;
    5408  }
    5409 
    5427  void dump(std::ostream& o,
    5428  const bool pretty_print,
    5429  const unsigned int indent_step,
    5430  const unsigned int current_indent = 0) const
    5431  {
    5432  // variable to hold indentation for recursive calls
    5433  unsigned int new_indent = current_indent;
    5434 
    5435  switch (m_type)
    5436  {
    5437  case value_t::object:
    5438  {
    5439  assert(m_value.object != nullptr);
    5440 
    5441  if (m_value.object->empty())
    5442  {
    5443  o << "{}";
    5444  return;
    5445  }
    5446 
    5447  o << "{";
    5448 
    5449  // increase indentation
    5450  if (pretty_print)
    5451  {
    5452  new_indent += indent_step;
    5453  o << "\n";
    5454  }
    5455 
    5456  for (auto i = m_value.object->cbegin(); i != m_value.object->cend(); ++i)
    5457  {
    5458  if (i != m_value.object->cbegin())
    5459  {
    5460  o << (pretty_print ? ",\n" : ",");
    5461  }
    5462  o << string_t(new_indent, ' ') << "\""
    5463  << escape_string(i->first) << "\":"
    5464  << (pretty_print ? " " : "");
    5465  i->second.dump(o, pretty_print, indent_step, new_indent);
    5466  }
    5467 
    5468  // decrease indentation
    5469  if (pretty_print)
    5470  {
    5471  new_indent -= indent_step;
    5472  o << "\n";
    5473  }
    5474 
    5475  o << string_t(new_indent, ' ') + "}";
    5476  return;
    5477  }
    5478 
    5479  case value_t::array:
    5480  {
    5481  assert(m_value.array != nullptr);
    5482 
    5483  if (m_value.array->empty())
    5484  {
    5485  o << "[]";
    5486  return;
    5487  }
    5488 
    5489  o << "[";
    5490 
    5491  // increase indentation
    5492  if (pretty_print)
    5493  {
    5494  new_indent += indent_step;
    5495  o << "\n";
    5496  }
    5497 
    5498  for (auto i = m_value.array->cbegin(); i != m_value.array->cend(); ++i)
    5499  {
    5500  if (i != m_value.array->cbegin())
    5501  {
    5502  o << (pretty_print ? ",\n" : ",");
    5503  }
    5504  o << string_t(new_indent, ' ');
    5505  i->dump(o, pretty_print, indent_step, new_indent);
    5506  }
    5507 
    5508  // decrease indentation
    5509  if (pretty_print)
    5510  {
    5511  new_indent -= indent_step;
    5512  o << "\n";
    5513  }
    5514 
    5515  o << string_t(new_indent, ' ') << "]";
    5516  return;
    5517  }
    5518 
    5519  case value_t::string:
    5520  {
    5521  assert(m_value.string != nullptr);
    5522  o << string_t("\"") << escape_string(*m_value.string) << "\"";
    5523  return;
    5524  }
    5525 
    5526  case value_t::boolean:
    5527  {
    5528  o << (m_value.boolean ? "true" : "false");
    5529  return;
    5530  }
    5531 
    5532  case value_t::number_integer:
    5533  {
    5534  o << m_value.number_integer;
    5535  return;
    5536  }
    5537 
    5538  case value_t::number_float:
    5539  {
    5540  // 15 digits of precision allows round-trip IEEE 754
    5541  // string->double->string; to be safe, we read this value from
    5542  // std::numeric_limits<number_float_t>::digits10
    5543  o << std::setprecision(std::numeric_limits<number_float_t>::digits10) << m_value.number_float;
    5544  return;
    5545  }
    5546 
    5547  case value_t::discarded:
    5548  {
    5549  o << "<discarded>";
    5550  return;
    5551  }
    5552 
    5553  case value_t::null:
    5554  {
    5555  o << "null";
    5556  return;
    5557  }
    5558  }
    5559  }
    5560 
    5561  private:
    5563  // member variables //
    5565 
    5567  value_t m_type = value_t::null;
    5568 
    5570  json_value m_value = {};
    5571 
    5572 
    5573  private:
    5575  // iterators //
    5577 
    5587  class primitive_iterator_t
    5588  {
    5589  public:
    5591  void set_begin()
    5592  {
    5593  m_it = begin_value;
    5594  }
    5595 
    5597  void set_end()
    5598  {
    5599  m_it = end_value;
    5600  }
    5601 
    5603  bool is_begin() const
    5604  {
    5605  return (m_it == begin_value);
    5606  }
    5607 
    5609  bool is_end() const
    5610  {
    5611  return (m_it == end_value);
    5612  }
    5613 
    5615  operator difference_type& ()
    5616  {
    5617  return m_it;
    5618  }
    5619 
    5621  operator difference_type () const
    5622  {
    5623  return m_it;
    5624  }
    5625 
    5626  private:
    5627  static constexpr difference_type begin_value = 0;
    5628  static constexpr difference_type end_value = begin_value + 1;
    5629 
    5631  difference_type m_it = std::numeric_limits<std::ptrdiff_t>::denorm_min();
    5632  };
    5633 
    5641  struct internal_iterator
    5642  {
    5644  typename object_t::iterator object_iterator;
    5646  typename array_t::iterator array_iterator;
    5648  primitive_iterator_t primitive_iterator;
    5649 
    5651  internal_iterator()
    5652  : object_iterator(), array_iterator(), primitive_iterator()
    5653  {}
    5654  };
    5655 
    5657  template<typename IteratorType>
    5658  class iteration_proxy
    5659  {
    5660  private:
    5662  class iteration_proxy_internal
    5663  {
    5664  private:
    5666  IteratorType anchor;
    5668  size_t array_index = 0;
    5669 
    5670  public:
    5671  iteration_proxy_internal(IteratorType it)
    5672  : anchor(it)
    5673  {}
    5674 
    5676  iteration_proxy_internal& operator*()
    5677  {
    5678  return *this;
    5679  }
    5680 
    5682  iteration_proxy_internal& operator++()
    5683  {
    5684  ++anchor;
    5685  ++array_index;
    5686 
    5687  return *this;
    5688  }
    5689 
    5691  bool operator!= (const iteration_proxy_internal& o) const
    5692  {
    5693  return anchor != o.anchor;
    5694  }
    5695 
    5697  typename basic_json::string_t key() const
    5698  {
    5699  assert(anchor.m_object != nullptr);
    5700 
    5701  switch (anchor.m_object->type())
    5702  {
    5703  // use integer array index as key
    5704  case value_t::array:
    5705  {
    5706  return std::to_string(array_index);
    5707  }
    5708 
    5709  // use key from the object
    5710  case value_t::object:
    5711  {
    5712  return anchor.key();
    5713  }
    5714 
    5715  // use an empty key for all primitive types
    5716  default:
    5717  {
    5718  return "";
    5719  }
    5720  }
    5721  }
    5722 
    5724  typename IteratorType::reference value() const
    5725  {
    5726  return anchor.value();
    5727  }
    5728  };
    5729 
    5731  typename IteratorType::reference container;
    5732 
    5733  public:
    5735  iteration_proxy(typename IteratorType::reference cont)
    5736  : container(cont)
    5737  {}
    5738 
    5740  iteration_proxy_internal begin()
    5741  {
    5742  return iteration_proxy_internal(container.begin());
    5743  }
    5744 
    5746  iteration_proxy_internal end()
    5747  {
    5748  return iteration_proxy_internal(container.end());
    5749  }
    5750  };
    5751 
    5752  public:
    5766  class const_iterator : public std::iterator<std::random_access_iterator_tag, const basic_json>
    5767  {
    5769  friend class basic_json;
    5770 
    5771  public:
    5781  using iterator_category = std::bidirectional_iterator_tag;
    5782 
    5784  const_iterator() = default;
    5785 
    5787  const_iterator(pointer object) : m_object(object)
    5788  {
    5789  assert(m_object != nullptr);
    5790 
    5791  switch (m_object->m_type)
    5792  {
    5794  {
    5795  m_it.object_iterator = typename object_t::iterator();
    5796  break;
    5797  }
    5798 
    5800  {
    5801  m_it.array_iterator = typename array_t::iterator();
    5802  break;
    5803  }
    5804 
    5805  default:
    5806  {
    5807  m_it.primitive_iterator = primitive_iterator_t();
    5808  break;
    5809  }
    5810  }
    5811  }
    5812 
    5814  const_iterator(const iterator& other) : m_object(other.m_object)
    5815  {
    5816  assert(m_object != nullptr);
    5817 
    5818  switch (m_object->m_type)
    5819  {
    5821  {
    5822  m_it.object_iterator = other.m_it.object_iterator;
    5823  break;
    5824  }
    5825 
    5827  {
    5828  m_it.array_iterator = other.m_it.array_iterator;
    5829  break;
    5830  }
    5831 
    5832  default:
    5833  {
    5834  m_it.primitive_iterator = other.m_it.primitive_iterator;
    5835  break;
    5836  }
    5837  }
    5838  }
    5839 
    5841  const_iterator(const const_iterator& other) noexcept
    5842  : m_object(other.m_object), m_it(other.m_it)
    5843  {}
    5844 
    5847  std::is_nothrow_move_constructible<pointer>::value and
    5848  std::is_nothrow_move_assignable<pointer>::value and
    5849  std::is_nothrow_move_constructible<internal_iterator>::value and
    5850  std::is_nothrow_move_assignable<internal_iterator>::value
    5851  )
    5852  {
    5853  std::swap(m_object, other.m_object);
    5854  std::swap(m_it, other.m_it);
    5855  return *this;
    5856  }
    5857 
    5858  private:
    5860  void set_begin()
    5861  {
    5862  assert(m_object != nullptr);
    5863 
    5864  switch (m_object->m_type)
    5865  {
    5867  {
    5868  assert(m_object->m_value.object != nullptr);
    5869  m_it.object_iterator = m_object->m_value.object->begin();
    5870  break;
    5871  }
    5872 
    5874  {
    5875  assert(m_object->m_value.array != nullptr);
    5876  m_it.array_iterator = m_object->m_value.array->begin();
    5877  break;
    5878  }
    5879 
    5881  {
    5882  // set to end so begin()==end() is true: null is empty
    5883  m_it.primitive_iterator.set_end();
    5884  break;
    5885  }
    5886 
    5887  default:
    5888  {
    5889  m_it.primitive_iterator.set_begin();
    5890  break;
    5891  }
    5892  }
    5893  }
    5894 
    5896  void set_end()
    5897  {
    5898  assert(m_object != nullptr);
    5899 
    5900  switch (m_object->m_type)
    5901  {
    5903  {
    5904  assert(m_object->m_value.object != nullptr);
    5905  m_it.object_iterator = m_object->m_value.object->end();
    5906  break;
    5907  }
    5908 
    5910  {
    5911  assert(m_object->m_value.array != nullptr);
    5912  m_it.array_iterator = m_object->m_value.array->end();
    5913  break;
    5914  }
    5915 
    5916  default:
    5917  {
    5918  m_it.primitive_iterator.set_end();
    5919  break;
    5920  }
    5921  }
    5922  }
    5923 
    5924  public:
    5927  {
    5928  assert(m_object != nullptr);
    5929 
    5930  switch (m_object->m_type)
    5931  {
    5933  {
    5934  assert(m_object->m_value.object);
    5935  assert(m_it.object_iterator != m_object->m_value.object->end());
    5936  return m_it.object_iterator->second;
    5937  }
    5938 
    5940  {
    5941  assert(m_object->m_value.array);
    5942  assert(m_it.array_iterator != m_object->m_value.array->end());
    5943  return *m_it.array_iterator;
    5944  }
    5945 
    5947  {
    5948  throw std::out_of_range("cannot get value");
    5949  }
    5950 
    5951  default:
    5952  {
    5953  if (m_it.primitive_iterator.is_begin())
    5954  {
    5955  return *m_object;
    5956  }
    5957  else
    5958  {
    5959  throw std::out_of_range("cannot get value");
    5960  }
    5961  }
    5962  }
    5963  }
    5964 
    5967  {
    5968  assert(m_object != nullptr);
    5969 
    5970  switch (m_object->m_type)
    5971  {
    5973  {
    5974  assert(m_object->m_value.object);
    5975  assert(m_it.object_iterator != m_object->m_value.object->end());
    5976  return &(m_it.object_iterator->second);
    5977  }
    5978 
    5980  {
    5981  assert(m_object->m_value.array);
    5982  assert(m_it.array_iterator != m_object->m_value.array->end());
    5983  return &*m_it.array_iterator;
    5984  }
    5985 
    5986  default:
    5987  {
    5988  if (m_it.primitive_iterator.is_begin())
    5989  {
    5990  return m_object;
    5991  }
    5992  else
    5993  {
    5994  throw std::out_of_range("cannot get value");
    5995  }
    5996  }
    5997  }
    5998  }
    5999 
    6002  {
    6003  auto result = *this;
    6004  ++(*this);
    6005  return result;
    6006  }
    6007 
    6010  {
    6011  assert(m_object != nullptr);
    6012 
    6013  switch (m_object->m_type)
    6014  {
    6016  {
    6017  ++m_it.object_iterator;
    6018  break;
    6019  }
    6020 
    6022  {
    6023  ++m_it.array_iterator;
    6024  break;
    6025  }
    6026 
    6027  default:
    6028  {
    6029  ++m_it.primitive_iterator;
    6030  break;
    6031  }
    6032  }
    6033 
    6034  return *this;
    6035  }
    6036 
    6039  {
    6040  auto result = *this;
    6041  --(*this);
    6042  return result;
    6043  }
    6044 
    6047  {
    6048  assert(m_object != nullptr);
    6049 
    6050  switch (m_object->m_type)
    6051  {
    6053  {
    6054  --m_it.object_iterator;
    6055  break;
    6056  }
    6057 
    6059  {
    6060  --m_it.array_iterator;
    6061  break;
    6062  }
    6063 
    6064  default:
    6065  {
    6066  --m_it.primitive_iterator;
    6067  break;
    6068  }
    6069  }
    6070 
    6071  return *this;
    6072  }
    6073 
    6075  bool operator==(const const_iterator& other) const
    6076  {
    6077  // if objects are not the same, the comparison is undefined
    6078  if (m_object != other.m_object)
    6079  {
    6080  throw std::domain_error("cannot compare iterators of different containers");
    6081  }
    6082 
    6083  assert(m_object != nullptr);
    6084 
    6085  switch (m_object->m_type)
    6086  {
    6088  {
    6089  return (m_it.object_iterator == other.m_it.object_iterator);
    6090  }
    6091 
    6093  {
    6094  return (m_it.array_iterator == other.m_it.array_iterator);
    6095  }
    6096 
    6097  default:
    6098  {
    6099  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
    6100  }
    6101  }
    6102  }
    6103 
    6105  bool operator!=(const const_iterator& other) const
    6106  {
    6107  return not operator==(other);
    6108  }
    6109 
    6111  bool operator<(const const_iterator& other) const
    6112  {
    6113  // if objects are not the same, the comparison is undefined
    6114  if (m_object != other.m_object)
    6115  {
    6116  throw std::domain_error("cannot compare iterators of different containers");
    6117  }
    6118 
    6119  assert(m_object != nullptr);
    6120 
    6121  switch (m_object->m_type)
    6122  {
    6124  {
    6125  throw std::domain_error("cannot compare order of object iterators");
    6126  }
    6127 
    6129  {
    6130  return (m_it.array_iterator < other.m_it.array_iterator);
    6131  }
    6132 
    6133  default:
    6134  {
    6135  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
    6136  }
    6137  }
    6138  }
    6139 
    6141  bool operator<=(const const_iterator& other) const
    6142  {
    6143  return not other.operator < (*this);
    6144  }
    6145 
    6147  bool operator>(const const_iterator& other) const
    6148  {
    6149  return not operator<=(other);
    6150  }
    6151 
    6153  bool operator>=(const const_iterator& other) const
    6154  {
    6155  return not operator<(other);
    6156  }
    6157 
    6160  {
    6161  assert(m_object != nullptr);
    6162 
    6163  switch (m_object->m_type)
    6164  {
    6166  {
    6167  throw std::domain_error("cannot use offsets with object iterators");
    6168  }
    6169 
    6171  {
    6172  m_it.array_iterator += i;
    6173  break;
    6174  }
    6175 
    6176  default:
    6177  {
    6178  m_it.primitive_iterator += i;
    6179  break;
    6180  }
    6181  }
    6182 
    6183  return *this;
    6184  }
    6185 
    6188  {
    6189  return operator+=(-i);
    6190  }
    6191 
    6194  {
    6195  auto result = *this;
    6196  result += i;
    6197  return result;
    6198  }
    6199 
    6202  {
    6203  auto result = *this;
    6204  result -= i;
    6205  return result;
    6206  }
    6207 
    6210  {
    6211  assert(m_object != nullptr);
    6212 
    6213  switch (m_object->m_type)
    6214  {
    6216  {
    6217  throw std::domain_error("cannot use offsets with object iterators");
    6218  }
    6219 
    6221  {
    6222  return m_it.array_iterator - other.m_it.array_iterator;
    6223  }
    6224 
    6225  default:
    6226  {
    6227  return m_it.primitive_iterator - other.m_it.primitive_iterator;
    6228  }
    6229  }
    6230  }
    6231 
    6234  {
    6235  assert(m_object != nullptr);
    6236 
    6237  switch (m_object->m_type)
    6238  {
    6240  {
    6241  throw std::domain_error("cannot use operator[] for object iterators");
    6242  }
    6243 
    6245  {
    6246  return *(m_it.array_iterator + n);
    6247  }
    6248 
    6250  {
    6251  throw std::out_of_range("cannot get value");
    6252  }
    6253 
    6254  default:
    6255  {
    6256  if (m_it.primitive_iterator == -n)
    6257  {
    6258  return *m_object;
    6259  }
    6260  else
    6261  {
    6262  throw std::out_of_range("cannot get value");
    6263  }
    6264  }
    6265  }
    6266  }
    6267 
    6269  typename object_t::key_type key() const
    6270  {
    6271  assert(m_object != nullptr);
    6272 
    6273  if (m_object->is_object())
    6274  {
    6275  return m_it.object_iterator->first;
    6276  }
    6277  else
    6278  {
    6279  throw std::domain_error("cannot use key() for non-object iterators");
    6280  }
    6281  }
    6282 
    6285  {
    6286  return operator*();
    6287  }
    6288 
    6289  private:
    6291  pointer m_object = nullptr;
    6293  internal_iterator m_it = internal_iterator();
    6294  };
    6295 
    6308  class iterator : public const_iterator
    6309  {
    6310  public:
    6312  using pointer = typename basic_json::pointer;
    6314 
    6316  iterator() = default;
    6317 
    6319  iterator(pointer object) noexcept
    6320  : base_iterator(object)
    6321  {}
    6322 
    6324  iterator(const iterator& other) noexcept
    6325  : base_iterator(other)
    6326  {}
    6327 
    6329  iterator& operator=(iterator other) noexcept(
    6330  std::is_nothrow_move_constructible<pointer>::value and
    6331  std::is_nothrow_move_assignable<pointer>::value and
    6332  std::is_nothrow_move_constructible<internal_iterator>::value and
    6333  std::is_nothrow_move_assignable<internal_iterator>::value
    6334  )
    6335  {
    6336  base_iterator::operator=(other);
    6337  return *this;
    6338  }
    6339 
    6342  {
    6343  return const_cast<reference>(base_iterator::operator*());
    6344  }
    6345 
    6348  {
    6349  return const_cast<pointer>(base_iterator::operator->());
    6350  }
    6351 
    6354  {
    6355  iterator result = *this;
    6356  base_iterator::operator++();
    6357  return result;
    6358  }
    6359 
    6362  {
    6363  base_iterator::operator++();
    6364  return *this;
    6365  }
    6366 
    6369  {
    6370  iterator result = *this;
    6371  base_iterator::operator--();
    6372  return result;
    6373  }
    6374 
    6377  {
    6378  base_iterator::operator--();
    6379  return *this;
    6380  }
    6381 
    6384  {
    6385  base_iterator::operator+=(i);
    6386  return *this;
    6387  }
    6388 
    6391  {
    6392  base_iterator::operator-=(i);
    6393  return *this;
    6394  }
    6395 
    6398  {
    6399  auto result = *this;
    6400  result += i;
    6401  return result;
    6402  }
    6403 
    6406  {
    6407  auto result = *this;
    6408  result -= i;
    6409  return result;
    6410  }
    6411 
    6412  difference_type operator-(const iterator& other) const
    6413  {
    6414  return base_iterator::operator-(other);
    6415  }
    6416 
    6419  {
    6420  return const_cast<reference>(base_iterator::operator[](n));
    6421  }
    6422 
    6425  {
    6426  return const_cast<reference>(base_iterator::value());
    6427  }
    6428  };
    6429 
    6447  template<typename Base>
    6448  class json_reverse_iterator : public std::reverse_iterator<Base>
    6449  {
    6450  public:
    6452  using base_iterator = std::reverse_iterator<Base>;
    6454  using reference = typename Base::reference;
    6455 
    6457  json_reverse_iterator(const typename base_iterator::iterator_type& it)
    6458  : base_iterator(it)
    6459  {}
    6460 
    6463  : base_iterator(it)
    6464  {}
    6465 
    6468  {
    6469  return base_iterator::operator++(1);
    6470  }
    6471 
    6474  {
    6475  base_iterator::operator++();
    6476  return *this;
    6477  }
    6478 
    6481  {
    6482  return base_iterator::operator--(1);
    6483  }
    6484 
    6487  {
    6488  base_iterator::operator--();
    6489  return *this;
    6490  }
    6491 
    6494  {
    6495  base_iterator::operator+=(i);
    6496  return *this;
    6497  }
    6498 
    6501  {
    6502  auto result = *this;
    6503  result += i;
    6504  return result;
    6505  }
    6506 
    6509  {
    6510  auto result = *this;
    6511  result -= i;
    6512  return result;
    6513  }
    6514 
    6517  {
    6518  return this->base() - other.base();
    6519  }
    6520 
    6523  {
    6524  return *(this->operator+(n));
    6525  }
    6526 
    6528  typename object_t::key_type key() const
    6529  {
    6530  auto it = --this->base();
    6531  return it.key();
    6532  }
    6533 
    6536  {
    6537  auto it = --this->base();
    6538  return it.operator * ();
    6539  }
    6540  };
    6541 
    6542 
    6543  private:
    6545  // lexer and parser //
    6547 
    6555  class lexer
    6556  {
    6557  public:
    6559  enum class token_type
    6560  {
    6561  uninitialized,
    6562  literal_true,
    6563  literal_false,
    6564  literal_null,
    6565  value_string,
    6566  value_number,
    6567  begin_array,
    6568  begin_object,
    6569  end_array,
    6570  end_object,
    6571  name_separator,
    6572  value_separator,
    6573  parse_error,
    6574  end_of_input
    6575  };
    6576 
    6578  using lexer_char_t = unsigned char;
    6579 
    6581  explicit lexer(const string_t& s) noexcept
    6582  : m_stream(nullptr), m_buffer(s)
    6583  {
    6584  m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
    6585  assert(m_content != nullptr);
    6586  m_start = m_cursor = m_content;
    6587  m_limit = m_content + s.size();
    6588  }
    6589 
    6591  explicit lexer(std::istream* s) noexcept
    6592  : m_stream(s), m_buffer()
    6593  {
    6594  assert(m_stream != nullptr);
    6595  getline(*m_stream, m_buffer);
    6596  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    6597  assert(m_content != nullptr);
    6598  m_start = m_cursor = m_content;
    6599  m_limit = m_content + m_buffer.size();
    6600  }
    6601 
    6603  lexer() = default;
    6604 
    6605  // switch off unwanted functions
    6606  lexer(const lexer&) = delete;
    6607  lexer operator=(const lexer&) = delete;
    6608 
    6624  static string_t to_unicode(const std::size_t codepoint1,
    6625  const std::size_t codepoint2 = 0)
    6626  {
    6627  string_t result;
    6628 
    6629  // calculate the codepoint from the given code points
    6630  std::size_t codepoint = codepoint1;
    6631 
    6632  // check if codepoint1 is a high surrogate
    6633  if (codepoint1 >= 0xD800 and codepoint1 <= 0xDBFF)
    6634  {
    6635  // check if codepoint2 is a low surrogate
    6636  if (codepoint2 >= 0xDC00 and codepoint2 <= 0xDFFF)
    6637  {
    6638  codepoint =
    6639  // high surrogate occupies the most significant 22 bits
    6640  (codepoint1 << 10)
    6641  // low surrogate occupies the least significant 15 bits
    6642  + codepoint2
    6643  // there is still the 0xD800, 0xDC00 and 0x10000 noise
    6644  // in the result so we have to subtract with:
    6645  // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
    6646  - 0x35FDC00;
    6647  }
    6648  else
    6649  {
    6650  throw std::invalid_argument("missing or wrong low surrogate");
    6651  }
    6652  }
    6653 
    6654  if (codepoint < 0x80)
    6655  {
    6656  // 1-byte characters: 0xxxxxxx (ASCII)
    6657  result.append(1, static_cast<typename string_t::value_type>(codepoint));
    6658  }
    6659  else if (codepoint <= 0x7ff)
    6660  {
    6661  // 2-byte characters: 110xxxxx 10xxxxxx
    6662  result.append(1, static_cast<typename string_t::value_type>(0xC0 | ((codepoint >> 6) & 0x1F)));
    6663  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6664  }
    6665  else if (codepoint <= 0xffff)
    6666  {
    6667  // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
    6668  result.append(1, static_cast<typename string_t::value_type>(0xE0 | ((codepoint >> 12) & 0x0F)));
    6669  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    6670  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6671  }
    6672  else if (codepoint <= 0x10ffff)
    6673  {
    6674  // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    6675  result.append(1, static_cast<typename string_t::value_type>(0xF0 | ((codepoint >> 18) & 0x07)));
    6676  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 12) & 0x3F)));
    6677  result.append(1, static_cast<typename string_t::value_type>(0x80 | ((codepoint >> 6) & 0x3F)));
    6678  result.append(1, static_cast<typename string_t::value_type>(0x80 | (codepoint & 0x3F)));
    6679  }
    6680  else
    6681  {
    6682  throw std::out_of_range("code points above 0x10FFFF are invalid");
    6683  }
    6684 
    6685  return result;
    6686  }
    6687 
    6689  static std::string token_type_name(token_type t)
    6690  {
    6691  switch (t)
    6692  {
    6693  case token_type::uninitialized:
    6694  return "<uninitialized>";
    6695  case token_type::literal_true:
    6696  return "true literal";
    6697  case token_type::literal_false:
    6698  return "false literal";
    6699  case token_type::literal_null:
    6700  return "null literal";
    6701  case token_type::value_string:
    6702  return "string literal";
    6703  case token_type::value_number:
    6704  return "number literal";
    6705  case token_type::begin_array:
    6706  return "'['";
    6707  case token_type::begin_object:
    6708  return "'{'";
    6709  case token_type::end_array:
    6710  return "']'";
    6711  case token_type::end_object:
    6712  return "'}'";
    6713  case token_type::name_separator:
    6714  return "':'";
    6715  case token_type::value_separator:
    6716  return "','";
    6717  case token_type::parse_error:
    6718  return "<parse error>";
    6719  case token_type::end_of_input:
    6720  return "end of input";
    6721  default:
    6722  {
    6723  // catch non-enum values
    6724  return "unknown token"; // LCOV_EXCL_LINE
    6725  }
    6726  }
    6727  }
    6728 
    6739  token_type scan() noexcept
    6740  {
    6741  // pointer for backtracking information
    6742  m_marker = nullptr;
    6743 
    6744  // remember the begin of the token
    6745  m_start = m_cursor;
    6746  assert(m_start != nullptr);
    6747 
    6748 
    6749  {
    6750  lexer_char_t yych;
    6751  unsigned int yyaccept = 0;
    6752  static const unsigned char yybm[] =
    6753  {
    6754  0, 0, 0, 0, 0, 0, 0, 0,
    6755  0, 32, 32, 0, 0, 32, 0, 0,
    6756  64, 64, 64, 64, 64, 64, 64, 64,
    6757  64, 64, 64, 64, 64, 64, 64, 64,
    6758  96, 64, 0, 64, 64, 64, 64, 64,
    6759  64, 64, 64, 64, 64, 64, 64, 64,
    6760  192, 192, 192, 192, 192, 192, 192, 192,
    6761  192, 192, 64, 64, 64, 64, 64, 64,
    6762  64, 64, 64, 64, 64, 64, 64, 64,
    6763  64, 64, 64, 64, 64, 64, 64, 64,
    6764  64, 64, 64, 64, 64, 64, 64, 64,
    6765  64, 64, 64, 64, 0, 64, 64, 64,
    6766  64, 64, 64, 64, 64, 64, 64, 64,
    6767  64, 64, 64, 64, 64, 64, 64, 64,
    6768  64, 64, 64, 64, 64, 64, 64, 64,
    6769  64, 64, 64, 64, 64, 64, 64, 64,
    6770  64, 64, 64, 64, 64, 64, 64, 64,
    6771  64, 64, 64, 64, 64, 64, 64, 64,
    6772  64, 64, 64, 64, 64, 64, 64, 64,
    6773  64, 64, 64, 64, 64, 64, 64, 64,
    6774  64, 64, 64, 64, 64, 64, 64, 64,
    6775  64, 64, 64, 64, 64, 64, 64, 64,
    6776  64, 64, 64, 64, 64, 64, 64, 64,
    6777  64, 64, 64, 64, 64, 64, 64, 64,
    6778  64, 64, 64, 64, 64, 64, 64, 64,
    6779  64, 64, 64, 64, 64, 64, 64, 64,
    6780  64, 64, 64, 64, 64, 64, 64, 64,
    6781  64, 64, 64, 64, 64, 64, 64, 64,
    6782  64, 64, 64, 64, 64, 64, 64, 64,
    6783  64, 64, 64, 64, 64, 64, 64, 64,
    6784  64, 64, 64, 64, 64, 64, 64, 64,
    6785  64, 64, 64, 64, 64, 64, 64, 64,
    6786  };
    6787  if ((m_limit - m_cursor) < 5)
    6788  {
    6789  yyfill(); // LCOV_EXCL_LINE;
    6790  }
    6791  yych = *m_cursor;
    6792  if (yych <= ':')
    6793  {
    6794  if (yych <= ' ')
    6795  {
    6796  if (yych <= '\n')
    6797  {
    6798  if (yych <= 0x00)
    6799  {
    6800  goto basic_json_parser_28;
    6801  }
    6802  if (yych <= 0x08)
    6803  {
    6804  goto basic_json_parser_30;
    6805  }
    6806  if (yych >= '\n')
    6807  {
    6808  goto basic_json_parser_4;
    6809  }
    6810  }
    6811  else
    6812  {
    6813  if (yych == '\r')
    6814  {
    6815  goto basic_json_parser_2;
    6816  }
    6817  if (yych <= 0x1F)
    6818  {
    6819  goto basic_json_parser_30;
    6820  }
    6821  }
    6822  }
    6823  else
    6824  {
    6825  if (yych <= ',')
    6826  {
    6827  if (yych == '"')
    6828  {
    6829  goto basic_json_parser_27;
    6830  }
    6831  if (yych <= '+')
    6832  {
    6833  goto basic_json_parser_30;
    6834  }
    6835  goto basic_json_parser_16;
    6836  }
    6837  else
    6838  {
    6839  if (yych <= '/')
    6840  {
    6841  if (yych <= '-')
    6842  {
    6843  goto basic_json_parser_23;
    6844  }
    6845  goto basic_json_parser_30;
    6846  }
    6847  else
    6848  {
    6849  if (yych <= '0')
    6850  {
    6851  goto basic_json_parser_24;
    6852  }
    6853  if (yych <= '9')
    6854  {
    6855  goto basic_json_parser_26;
    6856  }
    6857  goto basic_json_parser_18;
    6858  }
    6859  }
    6860  }
    6861  }
    6862  else
    6863  {
    6864  if (yych <= 'n')
    6865  {
    6866  if (yych <= ']')
    6867  {
    6868  if (yych == '[')
    6869  {
    6870  goto basic_json_parser_8;
    6871  }
    6872  if (yych <= '\\')
    6873  {
    6874  goto basic_json_parser_30;
    6875  }
    6876  goto basic_json_parser_10;
    6877  }
    6878  else
    6879  {
    6880  if (yych == 'f')
    6881  {
    6882  goto basic_json_parser_22;
    6883  }
    6884  if (yych <= 'm')
    6885  {
    6886  goto basic_json_parser_30;
    6887  }
    6888  goto basic_json_parser_20;
    6889  }
    6890  }
    6891  else
    6892  {
    6893  if (yych <= '{')
    6894  {
    6895  if (yych == 't')
    6896  {
    6897  goto basic_json_parser_21;
    6898  }
    6899  if (yych <= 'z')
    6900  {
    6901  goto basic_json_parser_30;
    6902  }
    6903  goto basic_json_parser_12;
    6904  }
    6905  else
    6906  {
    6907  if (yych <= '}')
    6908  {
    6909  if (yych <= '|')
    6910  {
    6911  goto basic_json_parser_30;
    6912  }
    6913  goto basic_json_parser_14;
    6914  }
    6915  else
    6916  {
    6917  if (yych == 0xEF)
    6918  {
    6919  goto basic_json_parser_6;
    6920  }
    6921  goto basic_json_parser_30;
    6922  }
    6923  }
    6924  }
    6925  }
    6926 basic_json_parser_2:
    6927  ++m_cursor;
    6928  yych = *m_cursor;
    6929  goto basic_json_parser_5;
    6930 basic_json_parser_3:
    6931  {
    6932  return scan();
    6933  }
    6934 basic_json_parser_4:
    6935  ++m_cursor;
    6936  if (m_limit <= m_cursor)
    6937  {
    6938  yyfill(); // LCOV_EXCL_LINE;
    6939  }
    6940  yych = *m_cursor;
    6941 basic_json_parser_5:
    6942  if (yybm[0 + yych] & 32)
    6943  {
    6944  goto basic_json_parser_4;
    6945  }
    6946  goto basic_json_parser_3;
    6947 basic_json_parser_6:
    6948  yyaccept = 0;
    6949  yych = *(m_marker = ++m_cursor);
    6950  if (yych == 0xBB)
    6951  {
    6952  goto basic_json_parser_64;
    6953  }
    6954 basic_json_parser_7:
    6955  {
    6956  return token_type::parse_error;
    6957  }
    6958 basic_json_parser_8:
    6959  ++m_cursor;
    6960  {
    6961  return token_type::begin_array;
    6962  }
    6963 basic_json_parser_10:
    6964  ++m_cursor;
    6965  {
    6966  return token_type::end_array;
    6967  }
    6968 basic_json_parser_12:
    6969  ++m_cursor;
    6970  {
    6971  return token_type::begin_object;
    6972  }
    6973 basic_json_parser_14:
    6974  ++m_cursor;
    6975  {
    6976  return token_type::end_object;
    6977  }
    6978 basic_json_parser_16:
    6979  ++m_cursor;
    6980  {
    6981  return token_type::value_separator;
    6982  }
    6983 basic_json_parser_18:
    6984  ++m_cursor;
    6985  {
    6986  return token_type::name_separator;
    6987  }
    6988 basic_json_parser_20:
    6989  yyaccept = 0;
    6990  yych = *(m_marker = ++m_cursor);
    6991  if (yych == 'u')
    6992  {
    6993  goto basic_json_parser_60;
    6994  }
    6995  goto basic_json_parser_7;
    6996 basic_json_parser_21:
    6997  yyaccept = 0;
    6998  yych = *(m_marker = ++m_cursor);
    6999  if (yych == 'r')
    7000  {
    7001  goto basic_json_parser_56;
    7002  }
    7003  goto basic_json_parser_7;
    7004 basic_json_parser_22:
    7005  yyaccept = 0;
    7006  yych = *(m_marker = ++m_cursor);
    7007  if (yych == 'a')
    7008  {
    7009  goto basic_json_parser_51;
    7010  }
    7011  goto basic_json_parser_7;
    7012 basic_json_parser_23:
    7013  yych = *++m_cursor;
    7014  if (yych <= '/')
    7015  {
    7016  goto basic_json_parser_7;
    7017  }
    7018  if (yych <= '0')
    7019  {
    7020  goto basic_json_parser_50;
    7021  }
    7022  if (yych <= '9')
    7023  {
    7024  goto basic_json_parser_41;
    7025  }
    7026  goto basic_json_parser_7;
    7027 basic_json_parser_24:
    7028  yyaccept = 1;
    7029  yych = *(m_marker = ++m_cursor);
    7030  if (yych <= 'D')
    7031  {
    7032  if (yych == '.')
    7033  {
    7034  goto basic_json_parser_43;
    7035  }
    7036  }
    7037  else
    7038  {
    7039  if (yych <= 'E')
    7040  {
    7041  goto basic_json_parser_44;
    7042  }
    7043  if (yych == 'e')
    7044  {
    7045  goto basic_json_parser_44;
    7046  }
    7047  }
    7048 basic_json_parser_25:
    7049  {
    7050  return token_type::value_number;
    7051  }
    7052 basic_json_parser_26:
    7053  yyaccept = 1;
    7054  yych = *(m_marker = ++m_cursor);
    7055  goto basic_json_parser_42;
    7056 basic_json_parser_27:
    7057  yyaccept = 0;
    7058  yych = *(m_marker = ++m_cursor);
    7059  if (yych <= 0x0F)
    7060  {
    7061  goto basic_json_parser_7;
    7062  }
    7063  goto basic_json_parser_32;
    7064 basic_json_parser_28:
    7065  ++m_cursor;
    7066  {
    7067  return token_type::end_of_input;
    7068  }
    7069 basic_json_parser_30:
    7070  yych = *++m_cursor;
    7071  goto basic_json_parser_7;
    7072 basic_json_parser_31:
    7073  ++m_cursor;
    7074  if (m_limit <= m_cursor)
    7075  {
    7076  yyfill(); // LCOV_EXCL_LINE;
    7077  }
    7078  yych = *m_cursor;
    7079 basic_json_parser_32:
    7080  if (yybm[0 + yych] & 64)
    7081  {
    7082  goto basic_json_parser_31;
    7083  }
    7084  if (yych <= 0x0F)
    7085  {
    7086  goto basic_json_parser_33;
    7087  }
    7088  if (yych <= '"')
    7089  {
    7090  goto basic_json_parser_35;
    7091  }
    7092  goto basic_json_parser_34;
    7093 basic_json_parser_33:
    7094  m_cursor = m_marker;
    7095  if (yyaccept == 0)
    7096  {
    7097  goto basic_json_parser_7;
    7098  }
    7099  else
    7100  {
    7101  goto basic_json_parser_25;
    7102  }
    7103 basic_json_parser_34:
    7104  ++m_cursor;
    7105  if (m_limit <= m_cursor)
    7106  {
    7107  yyfill(); // LCOV_EXCL_LINE;
    7108  }
    7109  yych = *m_cursor;
    7110  if (yych <= 'e')
    7111  {
    7112  if (yych <= '/')
    7113  {
    7114  if (yych == '"')
    7115  {
    7116  goto basic_json_parser_31;
    7117  }
    7118  if (yych <= '.')
    7119  {
    7120  goto basic_json_parser_33;
    7121  }
    7122  goto basic_json_parser_31;
    7123  }
    7124  else
    7125  {
    7126  if (yych <= '\\')
    7127  {
    7128  if (yych <= '[')
    7129  {
    7130  goto basic_json_parser_33;
    7131  }
    7132  goto basic_json_parser_31;
    7133  }
    7134  else
    7135  {
    7136  if (yych == 'b')
    7137  {
    7138  goto basic_json_parser_31;
    7139  }
    7140  goto basic_json_parser_33;
    7141  }
    7142  }
    7143  }
    7144  else
    7145  {
    7146  if (yych <= 'q')
    7147  {
    7148  if (yych <= 'f')
    7149  {
    7150  goto basic_json_parser_31;
    7151  }
    7152  if (yych == 'n')
    7153  {
    7154  goto basic_json_parser_31;
    7155  }
    7156  goto basic_json_parser_33;
    7157  }
    7158  else
    7159  {
    7160  if (yych <= 's')
    7161  {
    7162  if (yych <= 'r')
    7163  {
    7164  goto basic_json_parser_31;
    7165  }
    7166  goto basic_json_parser_33;
    7167  }
    7168  else
    7169  {
    7170  if (yych <= 't')
    7171  {
    7172  goto basic_json_parser_31;
    7173  }
    7174  if (yych <= 'u')
    7175  {
    7176  goto basic_json_parser_37;
    7177  }
    7178  goto basic_json_parser_33;
    7179  }
    7180  }
    7181  }
    7182 basic_json_parser_35:
    7183  ++m_cursor;
    7184  {
    7185  return token_type::value_string;
    7186  }
    7187 basic_json_parser_37:
    7188  ++m_cursor;
    7189  if (m_limit <= m_cursor)
    7190  {
    7191  yyfill(); // LCOV_EXCL_LINE;
    7192  }
    7193  yych = *m_cursor;
    7194  if (yych <= '@')
    7195  {
    7196  if (yych <= '/')
    7197  {
    7198  goto basic_json_parser_33;
    7199  }
    7200  if (yych >= ':')
    7201  {
    7202  goto basic_json_parser_33;
    7203  }
    7204  }
    7205  else
    7206  {
    7207  if (yych <= 'F')
    7208  {
    7209  goto basic_json_parser_38;
    7210  }
    7211  if (yych <= '`')
    7212  {
    7213  goto basic_json_parser_33;
    7214  }
    7215  if (yych >= 'g')
    7216  {
    7217  goto basic_json_parser_33;
    7218  }
    7219  }
    7220 basic_json_parser_38:
    7221  ++m_cursor;
    7222  if (m_limit <= m_cursor)
    7223  {
    7224  yyfill(); // LCOV_EXCL_LINE;
    7225  }
    7226  yych = *m_cursor;
    7227  if (yych <= '@')
    7228  {
    7229  if (yych <= '/')
    7230  {
    7231  goto basic_json_parser_33;
    7232  }
    7233  if (yych >= ':')
    7234  {
    7235  goto basic_json_parser_33;
    7236  }
    7237  }
    7238  else
    7239  {
    7240  if (yych <= 'F')
    7241  {
    7242  goto basic_json_parser_39;
    7243  }
    7244  if (yych <= '`')
    7245  {
    7246  goto basic_json_parser_33;
    7247  }
    7248  if (yych >= 'g')
    7249  {
    7250  goto basic_json_parser_33;
    7251  }
    7252  }
    7253 basic_json_parser_39:
    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_40;
    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_40:
    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 <= '9')
    7300  {
    7301  goto basic_json_parser_31;
    7302  }
    7303  goto basic_json_parser_33;
    7304  }
    7305  else
    7306  {
    7307  if (yych <= 'F')
    7308  {
    7309  goto basic_json_parser_31;
    7310  }
    7311  if (yych <= '`')
    7312  {
    7313  goto basic_json_parser_33;
    7314  }
    7315  if (yych <= 'f')
    7316  {
    7317  goto basic_json_parser_31;
    7318  }
    7319  goto basic_json_parser_33;
    7320  }
    7321 basic_json_parser_41:
    7322  yyaccept = 1;
    7323  m_marker = ++m_cursor;
    7324  if ((m_limit - m_cursor) < 3)
    7325  {
    7326  yyfill(); // LCOV_EXCL_LINE;
    7327  }
    7328  yych = *m_cursor;
    7329 basic_json_parser_42:
    7330  if (yybm[0 + yych] & 128)
    7331  {
    7332  goto basic_json_parser_41;
    7333  }
    7334  if (yych <= 'D')
    7335  {
    7336  if (yych != '.')
    7337  {
    7338  goto basic_json_parser_25;
    7339  }
    7340  }
    7341  else
    7342  {
    7343  if (yych <= 'E')
    7344  {
    7345  goto basic_json_parser_44;
    7346  }
    7347  if (yych == 'e')
    7348  {
    7349  goto basic_json_parser_44;
    7350  }
    7351  goto basic_json_parser_25;
    7352  }
    7353 basic_json_parser_43:
    7354  yych = *++m_cursor;
    7355  if (yych <= '/')
    7356  {
    7357  goto basic_json_parser_33;
    7358  }
    7359  if (yych <= '9')
    7360  {
    7361  goto basic_json_parser_48;
    7362  }
    7363  goto basic_json_parser_33;
    7364 basic_json_parser_44:
    7365  yych = *++m_cursor;
    7366  if (yych <= ',')
    7367  {
    7368  if (yych != '+')
    7369  {
    7370  goto basic_json_parser_33;
    7371  }
    7372  }
    7373  else
    7374  {
    7375  if (yych <= '-')
    7376  {
    7377  goto basic_json_parser_45;
    7378  }
    7379  if (yych <= '/')
    7380  {
    7381  goto basic_json_parser_33;
    7382  }
    7383  if (yych <= '9')
    7384  {
    7385  goto basic_json_parser_46;
    7386  }
    7387  goto basic_json_parser_33;
    7388  }
    7389 basic_json_parser_45:
    7390  yych = *++m_cursor;
    7391  if (yych <= '/')
    7392  {
    7393  goto basic_json_parser_33;
    7394  }
    7395  if (yych >= ':')
    7396  {
    7397  goto basic_json_parser_33;
    7398  }
    7399 basic_json_parser_46:
    7400  ++m_cursor;
    7401  if (m_limit <= m_cursor)
    7402  {
    7403  yyfill(); // LCOV_EXCL_LINE;
    7404  }
    7405  yych = *m_cursor;
    7406  if (yych <= '/')
    7407  {
    7408  goto basic_json_parser_25;
    7409  }
    7410  if (yych <= '9')
    7411  {
    7412  goto basic_json_parser_46;
    7413  }
    7414  goto basic_json_parser_25;
    7415 basic_json_parser_48:
    7416  yyaccept = 1;
    7417  m_marker = ++m_cursor;
    7418  if ((m_limit - m_cursor) < 3)
    7419  {
    7420  yyfill(); // LCOV_EXCL_LINE;
    7421  }
    7422  yych = *m_cursor;
    7423  if (yych <= 'D')
    7424  {
    7425  if (yych <= '/')
    7426  {
    7427  goto basic_json_parser_25;
    7428  }
    7429  if (yych <= '9')
    7430  {
    7431  goto basic_json_parser_48;
    7432  }
    7433  goto basic_json_parser_25;
    7434  }
    7435  else
    7436  {
    7437  if (yych <= 'E')
    7438  {
    7439  goto basic_json_parser_44;
    7440  }
    7441  if (yych == 'e')
    7442  {
    7443  goto basic_json_parser_44;
    7444  }
    7445  goto basic_json_parser_25;
    7446  }
    7447 basic_json_parser_50:
    7448  yyaccept = 1;
    7449  yych = *(m_marker = ++m_cursor);
    7450  if (yych <= 'D')
    7451  {
    7452  if (yych == '.')
    7453  {
    7454  goto basic_json_parser_43;
    7455  }
    7456  goto basic_json_parser_25;
    7457  }
    7458  else
    7459  {
    7460  if (yych <= 'E')
    7461  {
    7462  goto basic_json_parser_44;
    7463  }
    7464  if (yych == 'e')
    7465  {
    7466  goto basic_json_parser_44;
    7467  }
    7468  goto basic_json_parser_25;
    7469  }
    7470 basic_json_parser_51:
    7471  yych = *++m_cursor;
    7472  if (yych != 'l')
    7473  {
    7474  goto basic_json_parser_33;
    7475  }
    7476  yych = *++m_cursor;
    7477  if (yych != 's')
    7478  {
    7479  goto basic_json_parser_33;
    7480  }
    7481  yych = *++m_cursor;
    7482  if (yych != 'e')
    7483  {
    7484  goto basic_json_parser_33;
    7485  }
    7486  ++m_cursor;
    7487  {
    7488  return token_type::literal_false;
    7489  }
    7490 basic_json_parser_56:
    7491  yych = *++m_cursor;
    7492  if (yych != 'u')
    7493  {
    7494  goto basic_json_parser_33;
    7495  }
    7496  yych = *++m_cursor;
    7497  if (yych != 'e')
    7498  {
    7499  goto basic_json_parser_33;
    7500  }
    7501  ++m_cursor;
    7502  {
    7503  return token_type::literal_true;
    7504  }
    7505 basic_json_parser_60:
    7506  yych = *++m_cursor;
    7507  if (yych != 'l')
    7508  {
    7509  goto basic_json_parser_33;
    7510  }
    7511  yych = *++m_cursor;
    7512  if (yych != 'l')
    7513  {
    7514  goto basic_json_parser_33;
    7515  }
    7516  ++m_cursor;
    7517  {
    7518  return token_type::literal_null;
    7519  }
    7520 basic_json_parser_64:
    7521  yych = *++m_cursor;
    7522  if (yych != 0xBF)
    7523  {
    7524  goto basic_json_parser_33;
    7525  }
    7526  ++m_cursor;
    7527  {
    7528  return scan();
    7529  }
    7530  }
    7531 
    7532 
    7533  }
    7534 
    7536  void yyfill() noexcept
    7537  {
    7538  if (m_stream == nullptr or not * m_stream)
    7539  {
    7540  return;
    7541  }
    7542 
    7543  const ssize_t offset_start = m_start - m_content;
    7544  const ssize_t offset_marker = m_marker - m_start;
    7545  const ssize_t offset_cursor = m_cursor - m_start;
    7546 
    7547  m_buffer.erase(0, static_cast<size_t>(offset_start));
    7548  std::string line;
    7549  assert(m_stream != nullptr);
    7550  std::getline(*m_stream, line);
    7551  m_buffer += "\n" + line; // add line with newline symbol
    7552 
    7553  m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
    7554  assert(m_content != nullptr);
    7555  m_start = m_content;
    7556  m_marker = m_start + offset_marker;
    7557  m_cursor = m_start + offset_cursor;
    7558  m_limit = m_start + m_buffer.size() - 1;
    7559  }
    7560 
    7562  string_t get_token() const noexcept
    7563  {
    7564  assert(m_start != nullptr);
    7565  return string_t(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7566  static_cast<size_t>(m_cursor - m_start));
    7567  }
    7568 
    7590  string_t get_string() const
    7591  {
    7592  string_t result;
    7593  result.reserve(static_cast<size_t>(m_cursor - m_start - 2));
    7594 
    7595  // iterate the result between the quotes
    7596  for (const lexer_char_t* i = m_start + 1; i < m_cursor - 1; ++i)
    7597  {
    7598  // process escaped characters
    7599  if (*i == '\\')
    7600  {
    7601  // read next character
    7602  ++i;
    7603 
    7604  switch (*i)
    7605  {
    7606  // the default escapes
    7607  case 't':
    7608  {
    7609  result += "\t";
    7610  break;
    7611  }
    7612  case 'b':
    7613  {
    7614  result += "\b";
    7615  break;
    7616  }
    7617  case 'f':
    7618  {
    7619  result += "\f";
    7620  break;
    7621  }
    7622  case 'n':
    7623  {
    7624  result += "\n";
    7625  break;
    7626  }
    7627  case 'r':
    7628  {
    7629  result += "\r";
    7630  break;
    7631  }
    7632  case '\\':
    7633  {
    7634  result += "\\";
    7635  break;
    7636  }
    7637  case '/':
    7638  {
    7639  result += "/";
    7640  break;
    7641  }
    7642  case '"':
    7643  {
    7644  result += "\"";
    7645  break;
    7646  }
    7647 
    7648  // unicode
    7649  case 'u':
    7650  {
    7651  // get code xxxx from uxxxx
    7652  auto codepoint = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>(i + 1),
    7653  4).c_str(), nullptr, 16);
    7654 
    7655  // check if codepoint is a high surrogate
    7656  if (codepoint >= 0xD800 and codepoint <= 0xDBFF)
    7657  {
    7658  // make sure there is a subsequent unicode
    7659  if ((i + 6 >= m_limit) or * (i + 5) != '\\' or * (i + 6) != 'u')
    7660  {
    7661  throw std::invalid_argument("missing low surrogate");
    7662  }
    7663 
    7664  // get code yyyy from uxxxx\uyyyy
    7665  auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
    7666  (i + 7), 4).c_str(), nullptr, 16);
    7667  result += to_unicode(codepoint, codepoint2);
    7668  // skip the next 10 characters (xxxx\uyyyy)
    7669  i += 10;
    7670  }
    7671  else
    7672  {
    7673  // add unicode character(s)
    7674  result += to_unicode(codepoint);
    7675  // skip the next four characters (xxxx)
    7676  i += 4;
    7677  }
    7678  break;
    7679  }
    7680  }
    7681  }
    7682  else
    7683  {
    7684  // all other characters are just copied to the end of the
    7685  // string
    7686  result.append(1, static_cast<typename string_t::value_type>(*i));
    7687  }
    7688  }
    7689 
    7690  return result;
    7691  }
    7692 
    7710  long double get_number() const
    7711  {
    7712  // conversion
    7713  typename string_t::value_type* endptr;
    7714  assert(m_start != nullptr);
    7715  const auto float_val = std::strtold(reinterpret_cast<typename string_t::const_pointer>(m_start),
    7716  &endptr);
    7717 
    7718  // return float_val if the whole number was translated and NAN
    7719  // otherwise
    7720  return (reinterpret_cast<lexer_char_t*>(endptr) == m_cursor) ? float_val : NAN;
    7721  }
    7722 
    7723  private:
    7725  std::istream* m_stream = nullptr;
    7727  string_t m_buffer;
    7729  const lexer_char_t* m_content = nullptr;
    7731  const lexer_char_t* m_start = nullptr;
    7733  const lexer_char_t* m_marker = nullptr;
    7735  const lexer_char_t* m_cursor = nullptr;
    7737  const lexer_char_t* m_limit = nullptr;
    7738  };
    7739 
    7745  class parser
    7746  {
    7747  public:
    7749  parser(const string_t& s, parser_callback_t cb = nullptr)
    7750  : callback(cb), m_lexer(s)
    7751  {
    7752  // read first token
    7753  get_token();
    7754  }
    7755 
    7757  parser(std::istream& _is, parser_callback_t cb = nullptr)
    7758  : callback(cb), m_lexer(&_is)
    7759  {
    7760  // read first token
    7761  get_token();
    7762  }
    7763 
    7765  basic_json parse()
    7766  {
    7767  basic_json result = parse_internal(true);
    7768 
    7769  expect(lexer::token_type::end_of_input);
    7770 
    7771  // return parser result and replace it with null in case the
    7772  // top-level value was discarded by the callback function
    7773  return result.is_discarded() ? basic_json() : result;
    7774  }
    7775 
    7776  private:
    7778  basic_json parse_internal(bool keep)
    7779  {
    7780  auto result = basic_json(value_t::discarded);
    7781 
    7782  switch (last_token)
    7783  {
    7784  case lexer::token_type::begin_object:
    7785  {
    7786  if (keep and (not callback or (keep = callback(depth++, parse_event_t::object_start, result))))
    7787  {
    7788  // explicitly set result to object to cope with {}
    7789  result.m_type = value_t::object;
    7790  result.m_value = json_value(value_t::object);
    7791  }
    7792 
    7793  // read next token
    7794  get_token();
    7795 
    7796  // closing } -> we are done
    7797  if (last_token == lexer::token_type::end_object)
    7798  {
    7799  get_token();
    7800  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    7801  {
    7802  result = basic_json(value_t::discarded);
    7803  }
    7804  return result;
    7805  }
    7806 
    7807  // no comma is expected here
    7808  unexpect(lexer::token_type::value_separator);
    7809 
    7810  // otherwise: parse key-value pairs
    7811  do
    7812  {
    7813  // ugly, but could be fixed with loop reorganization
    7814  if (last_token == lexer::token_type::value_separator)
    7815  {
    7816  get_token();
    7817  }
    7818 
    7819  // store key
    7820  expect(lexer::token_type::value_string);
    7821  const auto key = m_lexer.get_string();
    7822 
    7823  bool keep_tag = false;
    7824  if (keep)
    7825  {
    7826  if (callback)
    7827  {
    7828  basic_json k(key);
    7829  keep_tag = callback(depth, parse_event_t::key, k);
    7830  }
    7831  else
    7832  {
    7833  keep_tag = true;
    7834  }
    7835  }
    7836 
    7837  // parse separator (:)
    7838  get_token();
    7839  expect(lexer::token_type::name_separator);
    7840 
    7841  // parse and add value
    7842  get_token();
    7843  auto value = parse_internal(keep);
    7844  if (keep and keep_tag and not value.is_discarded())
    7845  {
    7846  result[key] = std::move(value);
    7847  }
    7848  }
    7849  while (last_token == lexer::token_type::value_separator);
    7850 
    7851  // closing }
    7852  expect(lexer::token_type::end_object);
    7853  get_token();
    7854  if (keep and callback and not callback(--depth, parse_event_t::object_end, result))
    7855  {
    7856  result = basic_json(value_t::discarded);
    7857  }
    7858 
    7859  return result;
    7860  }
    7861 
    7862  case lexer::token_type::begin_array:
    7863  {
    7864  if (keep and (not callback or (keep = callback(depth++, parse_event_t::array_start, result))))
    7865  {
    7866  // explicitly set result to object to cope with []
    7867  result.m_type = value_t::array;
    7868  result.m_value = json_value(value_t::array);
    7869  }
    7870 
    7871  // read next token
    7872  get_token();
    7873 
    7874  // closing ] -> we are done
    7875  if (last_token == lexer::token_type::end_array)
    7876  {
    7877  get_token();
    7878  if (callback and not callback(--depth, parse_event_t::array_end, result))
    7879  {
    7880  result = basic_json(value_t::discarded);
    7881  }
    7882  return result;
    7883  }
    7884 
    7885  // no comma is expected here
    7886  unexpect(lexer::token_type::value_separator);
    7887 
    7888  // otherwise: parse values
    7889  do
    7890  {
    7891  // ugly, but could be fixed with loop reorganization
    7892  if (last_token == lexer::token_type::value_separator)
    7893  {
    7894  get_token();
    7895  }
    7896 
    7897  // parse value
    7898  auto value = parse_internal(keep);
    7899  if (keep and not value.is_discarded())
    7900  {
    7901  result.push_back(std::move(value));
    7902  }
    7903  }
    7904  while (last_token == lexer::token_type::value_separator);
    7905 
    7906  // closing ]
    7907  expect(lexer::token_type::end_array);
    7908  get_token();
    7909  if (keep and callback and not callback(--depth, parse_event_t::array_end, result))
    7910  {
    7911  result = basic_json(value_t::discarded);
    7912  }
    7913 
    7914  return result;
    7915  }
    7916 
    7917  case lexer::token_type::literal_null:
    7918  {
    7919  get_token();
    7920  result.m_type = value_t::null;
    7921  break;
    7922  }
    7923 
    7924  case lexer::token_type::value_string:
    7925  {
    7926  const auto s = m_lexer.get_string();
    7927  get_token();
    7928  result = basic_json(s);
    7929  break;
    7930  }
    7931 
    7932  case lexer::token_type::literal_true:
    7933  {
    7934  get_token();
    7935  result.m_type = value_t::boolean;
    7936  result.m_value = true;
    7937  break;
    7938  }
    7939 
    7940  case lexer::token_type::literal_false:
    7941  {
    7942  get_token();
    7943  result.m_type = value_t::boolean;
    7944  result.m_value = false;
    7945  break;
    7946  }
    7947 
    7948  case lexer::token_type::value_number:
    7949  {
    7950  auto float_val = m_lexer.get_number();
    7951 
    7952  // NAN is returned if token could not be translated
    7953  // completely
    7954  if (std::isnan(float_val))
    7955  {
    7956  throw std::invalid_argument(std::string("parse error - ") +
    7957  m_lexer.get_token() + " is not a number");
    7958  }
    7959 
    7960  get_token();
    7961 
    7962  // check if conversion loses precision
    7963  const auto int_val = static_cast<number_integer_t>(float_val);
    7964  if (approx(float_val, static_cast<long double>(int_val)))
    7965  {
    7966  // we would not lose precision -> return int
    7967  result.m_type = value_t::number_integer;
    7968  result.m_value = int_val;
    7969  }
    7970  else
    7971  {
    7972  // we would lose precision -> return float
    7973  result.m_type = value_t::number_float;
    7974  result.m_value = static_cast<number_float_t>(float_val);
    7975  }
    7976  break;
    7977  }
    7978 
    7979  default:
    7980  {
    7981  // the last token was unexpected
    7982  unexpect(last_token);
    7983  }
    7984  }
    7985 
    7986  if (keep and callback and not callback(depth, parse_event_t::value, result))
    7987  {
    7988  result = basic_json(value_t::discarded);
    7989  }
    7990  return result;
    7991  }
    7992 
    7994  typename lexer::token_type get_token()
    7995  {
    7996  last_token = m_lexer.scan();
    7997  return last_token;
    7998  }
    7999 
    8000  void expect(typename lexer::token_type t) const
    8001  {
    8002  if (t != last_token)
    8003  {
    8004  std::string error_msg = "parse error - unexpected ";
    8005  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8006  lexer::token_type_name(last_token));
    8007  error_msg += "; expected " + lexer::token_type_name(t);
    8008  throw std::invalid_argument(error_msg);
    8009  }
    8010  }
    8011 
    8012  void unexpect(typename lexer::token_type t) const
    8013  {
    8014  if (t == last_token)
    8015  {
    8016  std::string error_msg = "parse error - unexpected ";
    8017  error_msg += (last_token == lexer::token_type::parse_error ? ("'" + m_lexer.get_token() + "'") :
    8018  lexer::token_type_name(last_token));
    8019  throw std::invalid_argument(error_msg);
    8020  }
    8021  }
    8022 
    8023  private:
    8025  int depth = 0;
    8027  parser_callback_t callback;
    8029  typename lexer::token_type last_token = lexer::token_type::uninitialized;
    8031  lexer m_lexer;
    8032  };
    8033 };
    8034 
    8035 
    8037 // presets //
    8039 
    8049 }
    8050 
    8051 
    8053 // nonmember functions //
    8055 
    8056 // specialization of std::swap, and std::hash
    8057 namespace std
    8058 {
    8064 template <>
    8065 inline void swap(nlohmann::json& j1,
    8066  nlohmann::json& j2) noexcept(
    8067  is_nothrow_move_constructible<nlohmann::json>::value and
    8068  is_nothrow_move_assignable<nlohmann::json>::value
    8069  )
    8070 {
    8071  j1.swap(j2);
    8072 }
    8073 
    8075 template <>
    8076 struct hash<nlohmann::json>
    8077 {
    8083  std::size_t operator()(const nlohmann::json& j) const
    8084  {
    8085  // a naive hashing via the string representation
    8086  const auto& h = hash<nlohmann::json::string_t>();
    8087  return h(j.dump());
    8088  }
    8089 };
    8090 }
    8091 
    8104 inline nlohmann::json operator "" _json(const char* s, std::size_t)
    8105 {
    8106  return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
    8107 }
    8108 
    8109 #endif
    bool operator!=(const const_iterator &other) const
    comparison: not equal
    Definition: json.hpp:6105
    -
    iterator insert(const_iterator pos, basic_json &&val)
    inserts element
    Definition: json.hpp:4388
    -
    iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6353
    -
    friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
    comparison: less than or equal
    Definition: json.hpp:4999
    +
    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:6508
    +
    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:2950
    -
    reference operator[](const T(&key)[n])
    access specified object element
    Definition: json.hpp:3084
    -
    typename basic_json::const_pointer pointer
    defines a pointer to the type iterated over (value_type)
    Definition: json.hpp:5777
    -
    static iteration_proxy< iterator > iterator_wrapper(reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:3922
    -
    const_iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6046
    -
    friend std::istream & operator>>(std::istream &i, basic_json &j)
    deserialize from stream
    Definition: json.hpp:5212
    -
    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:5846
    -
    typename basic_json::value_type value_type
    the type of the values when the iterator is dereferenced
    Definition: json.hpp:5773
    +
    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
    -
    iterator insert(const_iterator pos, const_iterator first, const_iterator last)
    inserts elements
    Definition: json.hpp:4470
    -
    iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
    inserts elements
    Definition: json.hpp:4417
    -
    json_reverse_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6480
    +
    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:4309
    +
    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:6361
    -
    friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
    comparison: not equal
    Definition: json.hpp:4855
    +
    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:6009
    -
    difference_type operator-(const json_reverse_iterator &other) const
    return difference
    Definition: json.hpp:6516
    -
    basic_json<> json
    default JSON class
    Definition: json.hpp:8048
    -
    reference front()
    access the first element
    Definition: json.hpp:3253
    +
    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:3633
    -
    std::reverse_iterator< Base > base_iterator
    shortcut to the reverse iterator adaptor
    Definition: json.hpp:6452
    -
    json_reverse_iterator(const typename base_iterator::iterator_type &it)
    create reverse iterator from iterator
    Definition: json.hpp:6457
    +
    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:6486
    +
    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:4834
    -
    void push_back(basic_json &&val)
    add an object to an array
    Definition: json.hpp:4223
    -
    const_iterator cbegin() const
    returns a const iterator to the first element
    Definition: json.hpp:3733
    +
    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:6383
    +
    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:4249
    +
    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:6308
    -
    iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6390
    -
    static basic_json parse(std::istream &&i, parser_callback_t cb=nullptr)
    deserialize from stream
    Definition: json.hpp:5174
    -
    reference operator[](const typename object_t::key_type &key)
    access specified object element
    Definition: json.hpp:2991
    +
    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
    STL namespace.
    -
    difference_type operator-(const iterator &other) const
    Definition: json.hpp:6412
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6284
    -
    static iteration_proxy< const_iterator > iterator_wrapper(const_reference cont)
    wrapper to access iterator member functions in range-based for
    Definition: json.hpp:3930
    -
    const_iterator end() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3768
    -
    const_iterator(const const_iterator &other) noexcept
    copy constructor
    Definition: json.hpp:5841
    -
    reference at(const typename object_t::key_type &key)
    access specified object element with bounds checking
    Definition: json.hpp:2810
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6269
    -
    iterator end()
    returns an iterator to one past the last element
    Definition: json.hpp:3758
    +
    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:6341
    -
    reverse_iterator rend()
    returns an iterator to the reverse-end
    Definition: json.hpp:3847
    +
    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:6201
    +
    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:5779
    -
    const_reverse_iterator rend() const
    returns a const reverse iterator to one before the first
    Definition: json.hpp:3855
    -
    size_type erase(const typename object_t::key_type &key)
    remove element from a JSON object given a key
    Definition: json.hpp:3542
    +
    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:3699
    -
    const_reference at(const typename object_t::key_type &key) const
    access specified object element with bounds checking
    Definition: json.hpp:2858
    -
    reference operator+=(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4283
    +
    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:6397
    +
    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:3616
    +
    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:5043
    -
    iterator & operator--()
    pre-decrement (–it)
    Definition: json.hpp:6376
    -
    friend bool operator<(const_reference lhs, const_reference rhs) noexcept
    comparison: less than
    Definition: json.hpp:4916
    -
    pointer operator->() const
    dereference the iterator
    Definition: json.hpp:5966
    -
    const_reference operator[](const typename object_t::key_type &key) const
    read-only access specified object element
    Definition: json.hpp:3039
    -
    const_iterator cend() const
    returns a const iterator to one past the last element
    Definition: json.hpp:3792
    -
    typename Base::reference reference
    the reference type for the pointed-to element
    Definition: json.hpp:6454
    -
    size_type size() const noexcept
    returns the number of elements
    Definition: json.hpp:4032
    +
    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
    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:2718
    -
    json_reverse_iterator(const base_iterator &it)
    create reverse iterator from base class
    Definition: json.hpp:6462
    +
    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:5098
    -
    ValueType value(const typename object_t::key_type &key, ValueType default_value) const
    access specified object element with default value
    Definition: json.hpp:3202
    -
    object_t::key_type key() const
    return the key of an object iterator
    Definition: json.hpp:6528
    +
    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:5775
    -
    void swap(array_t &other)
    exchanges the values
    Definition: json.hpp:4597
    -
    reverse_iterator rbegin()
    returns an iterator to the reverse-beginning
    Definition: json.hpp:3816
    -
    reference operator+=(const typename object_t::value_type &val)
    add an object to an object
    Definition: json.hpp:4333
    +
    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:6418
    +
    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:3824
    +
    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:6193
    +
    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:4665
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6424
    -
    const_iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6038
    +
    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:3580
    -
    void clear() noexcept
    clears the contents
    Definition: json.hpp:4153
    -
    pointer operator->()
    dereference the iterator
    Definition: json.hpp:6347
    +
    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
    array (ordered collection of values)
    -
    const_reference front() const
    access the first element
    Definition: json.hpp:3261
    -
    bool operator>=(const const_iterator &other) const
    comparison: greater than or equal
    Definition: json.hpp:6153
    -
    iterator insert(const_iterator pos, std::initializer_list< basic_json > ilist)
    inserts elements
    Definition: json.hpp:4528
    +
    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:6159
    +
    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:6209
    -
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
    comparison: equal
    Definition: json.hpp:4745
    +
    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:3901
    -
    bool empty() const noexcept
    checks whether the container is empty
    Definition: json.hpp:3974
    -
    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:3228
    -
    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:4566
    -
    const_reverse_iterator crbegin() const
    returns a const reverse iterator to the last element
    Definition: json.hpp:3878
    -
    reference value() const
    return the value of an iterator
    Definition: json.hpp:6535
    +
    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_iterator(pointer object)
    constructor for a given JSON instance
    Definition: json.hpp:5787
    -
    friend bool operator<(const value_t lhs, const value_t rhs)
    comparison operator for JSON types
    Definition: json.hpp:4699
    -
    iterator(pointer object) noexcept
    constructor for a given JSON instance
    Definition: json.hpp:6319
    -
    bool operator<(const const_iterator &other) const
    comparison: smaller
    Definition: json.hpp:6111
    +
    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:4878
    -
    const_iterator & operator-=(difference_type i)
    subtract from iterator
    Definition: json.hpp:6187
    +
    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:5137
    -
    InteratorType erase(InteratorType first, InteratorType last)
    remove elements given an iterator range
    Definition: json.hpp:3459
    -
    json_reverse_iterator operator++(int)
    post-increment (it++)
    Definition: json.hpp:6467
    +
    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:5814
    -
    friend bool operator!=(std::nullptr_t, const_reference v) noexcept
    comparison: not equal
    Definition: json.hpp:4887
    -
    InteratorType erase(InteratorType pos)
    remove element given an iterator
    Definition: json.hpp:3354
    -
    bool operator<=(const const_iterator &other) const
    comparison: less than or equal
    Definition: json.hpp:6141
    +
    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:3287
    +
    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:6001
    +
    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:6324
    -
    const_reference back() const
    access the last element
    Definition: json.hpp:3297
    +
    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:5166
    -
    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:3664
    -
    size_type max_size() const noexcept
    returns the maximum possible number of elements
    Definition: json.hpp:4094
    -
    void push_back(const basic_json &val)
    add an object to an array
    Definition: json.hpp:4259
    -
    bool operator==(const const_iterator &other) const
    comparison: equal
    Definition: json.hpp:6075
    -
    json_reverse_iterator & operator++()
    pre-increment (++it)
    Definition: json.hpp:6473
    +
    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:6147
    -
    friend bool operator>(const_reference lhs, const_reference rhs) noexcept
    comparison: greater than
    Definition: json.hpp:5021
    +
    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_reference operator[](const T(&key)[n]) const
    read-only access specified object element
    Definition: json.hpp:3135
    -
    const_iterator begin() const
    returns a const iterator to the first element
    Definition: json.hpp:3709
    -
    const_reference at(size_type idx) const
    access specified array element with bounds checking
    Definition: json.hpp:2762
    -
    json_reverse_iterator & operator+=(difference_type i)
    add to iterator
    Definition: json.hpp:6493
    -
    a const random access iterator for the basic_json class
    Definition: json.hpp:5766
    +
    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:4631
    -
    std::bidirectional_iterator_tag iterator_category
    the category of the iterator
    Definition: json.hpp:5781
    +
    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:4361
    -
    friend bool operator==(const_reference v, std::nullptr_t) noexcept
    comparison: equal
    Definition: json.hpp:4825
    -
    reference operator[](difference_type n) const
    access to successor
    Definition: json.hpp:6522
    +
    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:6233
    -
    reference operator*() const
    return a reference to the value pointed to by the iterator
    Definition: json.hpp:5926
    +
    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:5202
    +
    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:8083
    -
    friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
    serialize to stream
    Definition: json.hpp:5080
    -
    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:6329
    +
    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:2905
    -
    iterator operator--(int)
    post-decrement (it–)
    Definition: json.hpp:6368
    -
    json_reverse_iterator operator+(difference_type i) const
    add to iterator
    Definition: json.hpp:6500
    +
    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:6405
    +
    iterator operator-(difference_type i)
    subtract from iterator
    Definition: json.hpp:6471
    diff --git a/namespacemembers.html b/namespacemembers.html index 79c2f7bf1..5e3ce211a 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 158b14b2b..8b6d886cf 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 7a782ffb6..5b8f03901 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 39e60ce22..b844dd8ee 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 68ceb3258..ff4e26c55 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 8048 of file json.hpp.

    +

    Definition at line 8114 of file json.hpp.

    @@ -111,7 +111,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/search/all_d.js b/search/all_d.js index efac5216b..a5827274b 100644 --- a/search/all_d.js +++ b/search/all_d.js @@ -24,5 +24,5 @@ var searchData= ['operator_3e',['operator>',['../classnlohmann_1_1basic__json_a87db51b6b936fb2ea293cdbc8702dcb8.html#a87db51b6b936fb2ea293cdbc8702dcb8',1,'nlohmann::basic_json::operator>()'],['../classnlohmann_1_1basic__json_1_1const__iterator_a17e5f5d3598e6901f3c1c1f7dc60589f.html#a17e5f5d3598e6901f3c1c1f7dc60589f',1,'nlohmann::basic_json::const_iterator::operator>()']]], ['operator_3e_3d',['operator>=',['../classnlohmann_1_1basic__json_a74a943800c7f103d0990d7eef82c6453.html#a74a943800c7f103d0990d7eef82c6453',1,'nlohmann::basic_json::operator>=()'],['../classnlohmann_1_1basic__json_1_1const__iterator_a6b3e43d2f45fa611825dbdf4e88fffe2.html#a6b3e43d2f45fa611825dbdf4e88fffe2',1,'nlohmann::basic_json::const_iterator::operator>=()']]], ['operator_3e_3e',['operator>>',['../classnlohmann_1_1basic__json_a34d6a60dd99e9f33b8273a1c8db5669b.html#a34d6a60dd99e9f33b8273a1c8db5669b',1,'nlohmann::basic_json::operator>>()'],['../classnlohmann_1_1basic__json_aaf363408931d76472ded14017e59c9e8.html#aaf363408931d76472ded14017e59c9e8',1,'nlohmann::basic_json::operator>>()']]], - ['operator_5b_5d',['operator[]',['../classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html#a57703688bee6b9736ab3a430d8d246f2',1,'nlohmann::basic_json::operator[](size_type idx)'],['../classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html#ae960d2d6bc7b94fe39cc5e9f106edfa9',1,'nlohmann::basic_json::operator[](size_type idx) const '],['../classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html#af74581d177dafc38df5a126ccd358999',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key)'],['../classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html#a8e34088252a3ee6b2377f3a1f26dd1ba',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key) const '],['../classnlohmann_1_1basic__json_a266c4dd24d11a86e4831523af5d9df4d.html#a266c4dd24d11a86e4831523af5d9df4d',1,'nlohmann::basic_json::operator[](const T(&key)[n])'],['../classnlohmann_1_1basic__json_a9daafb4c15ed5a008cb825bbd8c29d87.html#a9daafb4c15ed5a008cb825bbd8c29d87',1,'nlohmann::basic_json::operator[](const T(&key)[n]) const '],['../classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html#a1cba94e5a67ee52bc66b898a4e08359d',1,'nlohmann::basic_json::const_iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html#a0eb7ac9b746fb6f931ae728f70f92a8e',1,'nlohmann::basic_json::iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html#ae988bd36b7d098b1157871f83b2d6265',1,'nlohmann::basic_json::json_reverse_iterator::operator[]()']]] + ['operator_5b_5d',['operator[]',['../classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html#a57703688bee6b9736ab3a430d8d246f2',1,'nlohmann::basic_json::operator[](size_type idx)'],['../classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html#ae960d2d6bc7b94fe39cc5e9f106edfa9',1,'nlohmann::basic_json::operator[](size_type idx) const '],['../classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html#af74581d177dafc38df5a126ccd358999',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key)'],['../classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html#a8e34088252a3ee6b2377f3a1f26dd1ba',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key) const '],['../classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html#adc5605cf6f8ff0cc6c3bb04a5d7c2f2d',1,'nlohmann::basic_json::operator[](T *(&key)[n])'],['../classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html#aad7eff162b0b991ef233503c592c1e2a',1,'nlohmann::basic_json::operator[](T *(&key)[n]) const '],['../classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html#a0ff73601e88f8ace62ff0b453ebb9043',1,'nlohmann::basic_json::operator[](T *key)'],['../classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html#ae7e36437700ef7353ad9961c8dd16a95',1,'nlohmann::basic_json::operator[](T *key) const '],['../classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html#a1cba94e5a67ee52bc66b898a4e08359d',1,'nlohmann::basic_json::const_iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html#a0eb7ac9b746fb6f931ae728f70f92a8e',1,'nlohmann::basic_json::iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html#ae988bd36b7d098b1157871f83b2d6265',1,'nlohmann::basic_json::json_reverse_iterator::operator[]()']]] ]; diff --git a/search/functions_b.js b/search/functions_b.js index b1ac189e0..5742865ca 100644 --- a/search/functions_b.js +++ b/search/functions_b.js @@ -19,5 +19,5 @@ var searchData= ['operator_3d_3d',['operator==',['../classnlohmann_1_1basic__json_1_1const__iterator_a36086a699b95e06976c11367b7d6ba53.html#a36086a699b95e06976c11367b7d6ba53',1,'nlohmann::basic_json::const_iterator']]], ['operator_3e',['operator>',['../classnlohmann_1_1basic__json_1_1const__iterator_a17e5f5d3598e6901f3c1c1f7dc60589f.html#a17e5f5d3598e6901f3c1c1f7dc60589f',1,'nlohmann::basic_json::const_iterator']]], ['operator_3e_3d',['operator>=',['../classnlohmann_1_1basic__json_1_1const__iterator_a6b3e43d2f45fa611825dbdf4e88fffe2.html#a6b3e43d2f45fa611825dbdf4e88fffe2',1,'nlohmann::basic_json::const_iterator']]], - ['operator_5b_5d',['operator[]',['../classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html#a57703688bee6b9736ab3a430d8d246f2',1,'nlohmann::basic_json::operator[](size_type idx)'],['../classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html#ae960d2d6bc7b94fe39cc5e9f106edfa9',1,'nlohmann::basic_json::operator[](size_type idx) const '],['../classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html#af74581d177dafc38df5a126ccd358999',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key)'],['../classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html#a8e34088252a3ee6b2377f3a1f26dd1ba',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key) const '],['../classnlohmann_1_1basic__json_a266c4dd24d11a86e4831523af5d9df4d.html#a266c4dd24d11a86e4831523af5d9df4d',1,'nlohmann::basic_json::operator[](const T(&key)[n])'],['../classnlohmann_1_1basic__json_a9daafb4c15ed5a008cb825bbd8c29d87.html#a9daafb4c15ed5a008cb825bbd8c29d87',1,'nlohmann::basic_json::operator[](const T(&key)[n]) const '],['../classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html#a1cba94e5a67ee52bc66b898a4e08359d',1,'nlohmann::basic_json::const_iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html#a0eb7ac9b746fb6f931ae728f70f92a8e',1,'nlohmann::basic_json::iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html#ae988bd36b7d098b1157871f83b2d6265',1,'nlohmann::basic_json::json_reverse_iterator::operator[]()']]] + ['operator_5b_5d',['operator[]',['../classnlohmann_1_1basic__json_a57703688bee6b9736ab3a430d8d246f2.html#a57703688bee6b9736ab3a430d8d246f2',1,'nlohmann::basic_json::operator[](size_type idx)'],['../classnlohmann_1_1basic__json_ae960d2d6bc7b94fe39cc5e9f106edfa9.html#ae960d2d6bc7b94fe39cc5e9f106edfa9',1,'nlohmann::basic_json::operator[](size_type idx) const '],['../classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html#af74581d177dafc38df5a126ccd358999',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key)'],['../classnlohmann_1_1basic__json_a8e34088252a3ee6b2377f3a1f26dd1ba.html#a8e34088252a3ee6b2377f3a1f26dd1ba',1,'nlohmann::basic_json::operator[](const typename object_t::key_type &key) const '],['../classnlohmann_1_1basic__json_adc5605cf6f8ff0cc6c3bb04a5d7c2f2d.html#adc5605cf6f8ff0cc6c3bb04a5d7c2f2d',1,'nlohmann::basic_json::operator[](T *(&key)[n])'],['../classnlohmann_1_1basic__json_aad7eff162b0b991ef233503c592c1e2a.html#aad7eff162b0b991ef233503c592c1e2a',1,'nlohmann::basic_json::operator[](T *(&key)[n]) const '],['../classnlohmann_1_1basic__json_a0ff73601e88f8ace62ff0b453ebb9043.html#a0ff73601e88f8ace62ff0b453ebb9043',1,'nlohmann::basic_json::operator[](T *key)'],['../classnlohmann_1_1basic__json_ae7e36437700ef7353ad9961c8dd16a95.html#ae7e36437700ef7353ad9961c8dd16a95',1,'nlohmann::basic_json::operator[](T *key) const '],['../classnlohmann_1_1basic__json_1_1const__iterator_a1cba94e5a67ee52bc66b898a4e08359d.html#a1cba94e5a67ee52bc66b898a4e08359d',1,'nlohmann::basic_json::const_iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1iterator_a0eb7ac9b746fb6f931ae728f70f92a8e.html#a0eb7ac9b746fb6f931ae728f70f92a8e',1,'nlohmann::basic_json::iterator::operator[]()'],['../classnlohmann_1_1basic__json_1_1json__reverse__iterator_ae988bd36b7d098b1157871f83b2d6265.html#ae988bd36b7d098b1157871f83b2d6265',1,'nlohmann::basic_json::json_reverse_iterator::operator[]()']]] ]; 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 274d79462..c320a3bd3 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');
    @@ -284,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 2680 of file json.hpp.

    +

    Definition at line 2682 of file json.hpp.

    @@ -294,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 9a431cb6c..648544b7c 100644 --- a/classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html +++ b/classnlohmann_1_1basic__json_af74581d177dafc38df5a126ccd358999.html @@ -195,8 +195,10 @@ 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 0fabc26e8..a65dca5db 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 8076 of file json.hpp.

    +

    Definition at line 8142 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 5c11315a8..c9b64c691 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 8083 of file json.hpp.

    +

    Definition at line 8149 of file json.hpp.

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