Unverified Commit 4b316ec5 authored by Niels Lohmann's avatar Niels Lohmann

Merge branch 'feature/insert' into develop

parents 42b4cdd4 9b32f725
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......@@ -29,7 +30,8 @@ int main()
j["new"]["key"]["value"] = {"another", "list"};
// count elements
j["size"] = j.size();
auto s = j.size();
j["size"] = s;
// pretty print with indent of 4 spaces
std::cout << std::setw(4) << j << '\n';
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/nv9fOg0XVVhWmFFy"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Mi7u49cYwMR0cgTH"><b>online</b></a>
\ No newline at end of file
......@@ -23,5 +23,5 @@
"value": 42.99
},
"pi": 3.141,
"size": 9
"size": 8
}
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/1fsm4gI55p83DOwU"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/dREyaxnVNgG1CAUx"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/8ldtT0NOhidn0fOA"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/rCEcfTCRY40LDvoR"><b>online</b></a>
\ No newline at end of file
"il brutto"
{"the bad":"il cattivo","the good":"il buono","the ugly":"il brutto"}
[json.exception.out_of_range.403] key 'the fast' not found
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/nfmFWMaJJHFJ7eVK"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/SIuocSXktJ2lxj0q"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/8UnQY256zGX2Lx6d"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/wB9tQWAyqeajJTVn"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/U1fv6LY7xZOAuSBs"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/s5MsN3WV6zsGcWY4"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Fy2xBfZMols2DUQC"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/SXcTwaW8DVzDT34z"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/WxhV3mL9YX8FJonk"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/zOTLPM0c5dNFZhk3"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/CAv4NNr4D1FJhhUv"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Sco4kIFMzpkYo37h"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <deque>
#include <list>
#include <forward_list>
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/VM7W2kpE7sIYJ5DW"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/n2KT4Yk3mzZXKnS5"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/oUU2X0pbZq7gawRB"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/gsHOHaLe3MfVhI2s"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/6Qfn12BDzb3vqO5p"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/zUmWzPFVFx6sEojX"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/iWYvmlA4qQmtvACX"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/1BjO38rdSmNGxpyn"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/iZzzxEpB7tbhz0cx"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/H0DDK6yuoCGZuoFw"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/CaDlatv1uXhQiu7o"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/nXd0SKQaR6tHukvy"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/9Tvfs2dJBW8m8ihA"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/AbLqRqEEN5N9W1Fj"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/IFZT4VL0oRotJBxl"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/ecx4xZQX7VXuhlAz"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/qdV5W2Lrljmjv4LG"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/bP03yg3IIbhARy2F"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/K4L4D6nibuGXbjfd"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/OY0l4CpfWuDJudyo"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/RMpEI2o935KgD2o2"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/zRdz49DwtK0gIJuc"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/0lW1WJ1ZP8g92Jp9"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Q0QcnX1LAQT5k7IU"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/yarD6DyxYlIf8Ymg"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/ukuefRRIclE7D7IX"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/9oPbpnFNgKtKjB0O"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/nHLMXLRwA3QWSnsQ"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/wwsjMZP8U6bWhUil"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/WQS4WbZC6pX4qZE4"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/yv5TMrq9qREivvHf"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/mrJDlTQD3orHnAdF"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/GQz9A5y7HduQHVMw"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/XsC14rus4L6meQTg"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Qom888gs2RM4wR4H"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/jr4aG41Zr1pWUlAw"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/hicmeOK39tBxaluM"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/KKfCy1yctyq7PBI1"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/rjYfsEq7v1RCHprk"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/jC8OLyTjE6EOcMZt"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/B6ILaoysGMliouEO"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/mvy0nMn3uStrP9tS"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/jdch45YEMX94DvlH"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/wvLvTvPt0dovixFE"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/rP64u8KqUJqB9lFd"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/g1mZBQAdSJE3cNCH"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/4Fbmy4IG012HmGKs"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/vp0L5nlCJewdlolt"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/W83LsQNBy5qCoABq"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/N0oo892iXEqaUzej"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/zGMngigiwwhsXEhB"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/SO3kgH5glqC18wJy"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/0eXbiM5KTPPXFkyP"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/wyOm5ERfxlXcwcSV"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/WXGKRKjzP22ggTEr"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/lxSvv5XGZ8Hmhnwl"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Kk6nOpsa6KetydpZ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/yqzasB01C3NGORaT"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/cdQa6jE0N2LyqFJe"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/qGLscdPoE6QH87oD"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/TDPaxmQ7PsvfWxrs"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/DUNMc8fjsGi5C7Ea"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/7vRGmLdVcYM7POhE"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/wSkYD6Q5RqJWmt3s"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/CUpMCzt6D9v3cYGM"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/fbTQdF5PwEeaC2lq"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/TRkhQoCdScWQqi3x"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/YwRJe95xb68JVjuI"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <unordered_map>
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ksZAkIKQnYhJKLpN"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/FeK53w3zimBjOhtB"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/xYbUV0BmOfNtQcED"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/6DBW0AukFiY85CMq"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/lsl8Ex3d3SOYnKHu"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/868NoVK7iU0BZHKz"><b>online</b></a>
\ No newline at end of file
17 17
[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ePN9gb4P3WTAiT6H"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Af1lyC9TuTbIaNHy"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/wnxritIWxpGS2SSt"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/J7tEcc5RiRckp3aH"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/kem0JnkdOVLNHii5"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/qgQADJFErGWzwFS3"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/rub1CDmN5dKK1LJW"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/n97dklxei6VGm4nn"><b>online</b></a>
\ No newline at end of file
#include "json.hpp"
using json = nlohmann::json;
int main()
{
// create two JSON objects
json j1 = {{"one", "eins"}, {"two", "zwei"}};
json j2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
// output objects
std::cout << j1 << '\n';
std::cout << j2 << '\n';
// insert range from j2 to j1
j1.insert(j2.begin(), j2.end());
// output result of insert call
std::cout << j1 << '\n';
}
<a target="_blank" href="https://wandbox.org/permlink/lj1jKDLtLmx2v1G0"><b>online</b></a>
\ No newline at end of file
{"one":"eins","two":"zwei"}
{"eleven":"elf","seventeen":"siebzehn"}
{"eleven":"elf","one":"eins","seventeen":"siebzehn","two":"zwei"}
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/hGGh0jnNmRo7bYAZ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/DvtGvyx9zygjT0kS"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/tWBJHygekWKqZIqe"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Io4dYYukmsvBsBhZ"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/USx0486t9Qxi5LS3"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/sznqCvDTQxq642QL"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/d75Hu1c8QVdDtabd"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/imhZMfDkB8bFRp7q"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/97mIrpY9h1rodAfI"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/PMSuHln29jOu8ySo"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/AHeVLaVJlG3cIehg"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/jf7HjebGYWYKNMJQ"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/WRiD854M5bTtQTnw"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/1HGdpuy7JGkt6IZd"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/BYzDklHPHDZA2CXX"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/nlZ9nbm8xJjTAsMe"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/TW8VagDAhVeaItcp"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/5nZW4U1bUA5lem25"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/A0B17yXywuT7Z1gx"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/V4emskHeUktlVOxh"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ePqrJBez1pH5dC7V"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/lb59ps8hvZkRQtly"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/46XRsxj3NvcwTpAZ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/oe0ULeAlBAiaqUxh"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Wlvqfd3JpEXTv2iH"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/JdZq6bQWjrHew4Dy"><b>online</b></a>
\ No newline at end of file
[json.exception.parse_error.107] parse error at 1: JSON pointer must be empty or begin with '/' - was: 'foo'
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/O4FbKx0TbZioFhfU"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/t6BQ8xMgkSUIcy1m"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/NBFk3TxTo32pKt36"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/9j9TwfNlZ88Hvwdi"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/3hERJociqLo3vdod"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/GTMgDs6Q8uLToRvb"><b>online</b></a>
\ No newline at end of file
......@@ -2,7 +2,7 @@
"compiler": {
"c++": "201103",
"family": "clang",
"version": "8.0.0 (clang-800.0.42.1)"
"version": "8.1.0 (clang-802.0.42)"
},
"copyright": "(C) 2013-2017 Niels Lohmann",
"name": "JSON for Modern C++",
......
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Ub9U5AMbng3oZiao"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/UeOjT4BeGKdE345o"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <unordered_map>
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/drFSKFXJd8IMzMK3"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/3bM7J4Qlj1Cl9EUK"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/sBTv52u9kI2gjeFJ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/D7ff222CtzQaAXUK"><b>online</b></a>
\ No newline at end of file
[1,2,3] == [1,2,4] false
{"A":"a","B":"b"} == {"A":"a","B":"b"} true
17 == 17 true
17 == 17.0 true
"foo" == "bar" false
[1,2,3] == [1,2,4] false
{"A":"a","B":"b"} == {"A":"a","B":"b"} true
17 == 17 true
"foo" == "bar" false
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/GGWi3cRmA5A3n1N2"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/2PPEeLTQTrbE8cVN"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/xJlXYtWnxO1NUh7x"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/whYWnKZxQV8vyrUV"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/92RTw1dWSVue58j6"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/vIBUY6LRmKBQOgiR"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/JrAvlrYH03a2yfRX"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/ZvESrmjGKoagilJr"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/m4lNMI48FqF96QWd"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/igiFsYkK3wJxbUBe"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/m4adEpqac1fmOwNn"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/fYRwW2ctRMeM0Lof"><b>online</b></a>
\ No newline at end of file
[1,2,3] == [1,2,4] true
{"A":"a","B":"b"} == {"A":"a","B":"b"} false
17 == 17 false
17 == 17.0 false
"foo" == "bar" true
[1,2,3] == [1,2,4] true
{"A":"a","B":"b"} == {"A":"a","B":"b"} false
17 == 17 false
"foo" == "bar" true
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Lo7eftLny4Io5rgV"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/ejLtGKtacU0xiZV4"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/n1XysfgD6muGNQdE"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/hVycygNLPkyFqvN5"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/yAAGR07u3IQbIgUa"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/yeEdM1SY7CloqFt3"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/NOtGXsCLXYHRG6ML"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/N3DbIOGGiGvGfSQ3"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ujLOsxCRQE3T8cYO"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/4y25Szh3rTn8pQJg"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/x6rzLLCk96NM36Tl"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/KYhKymZiVPxCBzVc"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/nRWrbGoBCORCHJI5"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/L1c3a41KITuzSwVS"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/4g1Gn5htCIExLBgW"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/O42CoAYuvKv9qsjI"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/AYgVTzCodPApT4hT"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/5BiKWmmo8E6cZ5ya"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/IKpbJkMdcocVdlRd"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/t2CPGGr35iE5Ccsd"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/CwZnqGqte14SYJ5s"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/chPjGeanDIb5ce5Y"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/F8VaVFyys87qQRt5"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/6N1uGjyG56Cgp856"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ir2u6Qbw18O89IWk"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/hRc62HHoix373ban"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ojh4Eeol4G9RgeRV"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Tt8SS2LJXvi0fuUc"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/n888UNQlMFduURhE"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Wvsf6dhxhscpNbx8"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/lbczW3AzcUbH1Nbo"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/UoObrzN9bFBGX8ph"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/zz3xkIXJYVhmYAla"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/Y6RwbyukIqP7axhL"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/wZF4dRHjfCyjb3rx"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/EGWCBZOQQ4WbZl6V"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/lmXOd27kgJ2wQGMZ"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/OJH4Aq6qDiGRqXNo"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/KiWAz9ZSK8L3k2kg"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/F9EE9JBnMu2KgCC3"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/2QoIzXRq9ODTMxRf"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/uv1nLqTKpZOwvofB"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ykuhQopCVvOXcvs9"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/uBVNNjgvYuX7rcIO"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/Hb0oakHEKJ2cuMTE"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/2aZmrP2xuWIiZOfd"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/flPVbr8widwRmnad"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/cZGcQj8OrkPrXX9d"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/gYuvmciucjS8NYY0"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/BYPsq3iXyU04hqpi"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/747DNDuWilHBrac3"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/jtBO4VQr09xU8hfX"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/UaDbrgZ8OPWaShY8"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/tMjlClOSnAhY0BDg"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/jvaU8GEfAusb5dKf"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/CeF2b7iKuvSnNZaV"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/ZqSWHApgHNYddvEU"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/om8MTJzY1FlDzxxS"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/V6imubWo6Lkp8gk1"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/t8yj12vJog4NagqL"><b>online</b></a>
\ No newline at end of file
#include <json.hpp>
#include "json.hpp"
#include <iomanip> // for std::setw
using json = nlohmann::json;
......
<a target="_blank" href="http://melpon.org/wandbox/permlink/PFBoQVT7RG0e0Wua"><b>online</b></a>
\ No newline at end of file
<a target="_blank" href="https://wandbox.org/permlink/aOxMXevnLZteNqkg"><b>online</b></a>
\ No newline at end of file
......@@ -5981,6 +5981,52 @@ class basic_json
return result;
}
/*!
@brief inserts elements
Inserts elements from range `[first, last)`.
@param[in] first begin of the range of elements to insert
@param[in] last end of the range of elements to insert
@throw type_error.309 if called on JSON values other than objects; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if iterator @a first or @a last does does not
point to an object; example: `"iterators first and last must point to
objects"`
@throw invalid_iterator.210 if @a first and @a last do not belong to the
same JSON value; example: `"iterators do not fit"`
@complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number
of elements to insert.
@liveexample{The example shows how `insert()` is used.,insert__range_object}
@since version 3.0.0
*/
void insert(const_iterator first, const_iterator last)
{
// insert only works for objects
if (not is_object())
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + type_name()));
}
// check if range iterators belong to the same JSON object
if (first.m_object != last.m_object)
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
}
// passed iterators must belong to objects
if (not first.m_object->is_object() or not first.m_object->is_object())
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
}
m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
}
/*!
@brief exchanges the values
......
......@@ -5981,6 +5981,52 @@ class basic_json
return result;
}
/*!
@brief inserts elements
Inserts elements from range `[first, last)`.
@param[in] first begin of the range of elements to insert
@param[in] last end of the range of elements to insert
@throw type_error.309 if called on JSON values other than objects; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if iterator @a first or @a last does does not
point to an object; example: `"iterators first and last must point to
objects"`
@throw invalid_iterator.210 if @a first and @a last do not belong to the
same JSON value; example: `"iterators do not fit"`
@complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number
of elements to insert.
@liveexample{The example shows how `insert()` is used.,insert__range_object}
@since version 3.0.0
*/
void insert(const_iterator first, const_iterator last)
{
// insert only works for objects
if (not is_object())
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + type_name()));
}
// check if range iterators belong to the same JSON object
if (first.m_object != last.m_object)
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
}
// passed iterators must belong to objects
if (not first.m_object->is_object() or not first.m_object->is_object())
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
}
m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
}
/*!
@brief exchanges the values
......
......@@ -594,7 +594,7 @@ TEST_CASE("modifiers")
}
}
SECTION("range")
SECTION("range for array")
{
json j_other_array = {"first", "second"};
......@@ -631,6 +631,40 @@ TEST_CASE("modifiers")
}
}
SECTION("range for object")
{
json j_object1 = {{"one", "eins"}, {"two", "zwei"}};
json j_object2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
SECTION("proper usage")
{
j_object1.insert(j_object2.begin(), j_object2.end());
CHECK(j_object1.size() == 4);
}
SECTION("empty range")
{
j_object1.insert(j_object2.begin(), j_object2.begin());
CHECK(j_object1.size() == 2);
}
SECTION("invalid iterators")
{
json j_other_array2 = {"first", "second"};
CHECK_THROWS_AS(j_array.insert(j_object2.begin(), j_object2.end()), json::type_error);
CHECK_THROWS_AS(j_object1.insert(j_object1.begin(), j_object2.end()), json::invalid_iterator);
CHECK_THROWS_AS(j_object1.insert(j_array.begin(), j_array.end()), json::invalid_iterator);
CHECK_THROWS_WITH(j_array.insert(j_object2.begin(), j_object2.end()),
"[json.exception.type_error.309] cannot use insert() with array");
CHECK_THROWS_WITH(j_object1.insert(j_object1.begin(), j_object2.end()),
"[json.exception.invalid_iterator.210] iterators do not fit");
CHECK_THROWS_WITH(j_object1.insert(j_array.begin(), j_array.end()),
"[json.exception.invalid_iterator.202] iterators first and last must point to objects");
}
}
SECTION("initializer list at position")
{
SECTION("insert before begin()")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment