text
stringlengths
24
1.04M
metadata
stringlengths
233
497
### File: docs/examples/contains__keytype.c++17.cpp #include <iostream> #include <string_view> #include <nlohmann/json.hpp> using namespace std::string_view_literals; using json = nlohmann::json; using namespace nlohmann::literals; int main() { // create some JSON values json j_object = R"( {"key": "value"} )...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/contains__keytype.c++17.cpp", "license": "mit", "size": 635}
### File: docs/examples/contains__object_t_key_type.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; int main() { // create some JSON values json j_object = R"( {"key": "value"} )"_json; json j_array = R"( [1, 2, 3] )"_json; // call...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/contains__object_t_key_type.cpp", "license": "mit", "size": 563}
### File: docs/examples/count__keytype.c++17.cpp #include <iostream> #include <string_view> #include <nlohmann/json.hpp> using namespace std::string_view_literals; using json = nlohmann::json; int main() { // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; // call count() auto count_tw...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/count__keytype.c++17.cpp", "license": "mit", "size": 535}
### File: docs/examples/count__object_t_key_type.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; // call count() auto count_two = j_object.count("two"); auto count_three = j_object.cou...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/count__object_t_key_type.cpp", "license": "mit", "size": 465}
### File: docs/examples/crbegin.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create an array value json array = {1, 2, 3, 4, 5}; // get an iterator to the reverse-beginning json::const_reverse_iterator it = array.crbegin(); // serialize the el...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/crbegin.cpp", "license": "mit", "size": 350}
### File: docs/examples/crend.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create an array value json array = {1, 2, 3, 4, 5}; // get an iterator to the reverse-end json::const_reverse_iterator it = array.crend(); // increment the iterator to ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/crend.cpp", "license": "mit", "size": 413}
### File: docs/examples/default_object_comparator_t.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { std::cout << std::boolalpha << "one < two : " << json::default_object_comparator_t{}("one", "two") << "\n" << "three < four : " << json::de...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/default_object_comparator_t.cpp", "license": "mit", "size": 325}
### File: docs/examples/diagnostics_extended.cpp #include <iostream> # define JSON_DIAGNOSTICS 1 #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { json j; j["address"]["street"] = "Fake Street"; j["address"]["housenumber"] = "12"; try { int housenumber = j["address"]...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/diagnostics_extended.cpp", "license": "mit", "size": 384}
### File: docs/examples/diagnostics_standard.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { json j; j["address"]["street"] = "Fake Street"; j["address"]["housenumber"] = "12"; try { int housenumber = j["address"]["housenumber"]; } ca...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/diagnostics_standard.cpp", "license": "mit", "size": 355}
### File: docs/examples/diff.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; int main() { // the source document json source = R"( { "baz": "qux", "foo": "bar" } )"_json; /...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/diff.cpp", "license": "mit", "size": 741}
### File: docs/examples/dump.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; json j_string = "Hellö 😀!"; // call dump() std::cout << "objects:" << '...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/dump.cpp", "license": "mit", "size": 1478}
### File: docs/examples/emplace.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json object = {{"one", 1}, {"two", 2}}; json null; // print values std::cout << object << '\n'; std::cout << null << '\n'; // add values ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/emplace.cpp", "license": "mit", "size": 775}
### File: docs/examples/emplace_back.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json array = {1, 2, 3, 4, 5}; json null; // print values std::cout << array << '\n'; std::cout << null << '\n'; // add values arra...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/emplace_back.cpp", "license": "mit", "size": 452}
### File: docs/examples/empty.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_object = {{"one", 1}, {"two", 2}}; json j_o...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/empty.cpp", "license": "mit", "size": 907}
### File: docs/examples/end.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create an array value json array = {1, 2, 3, 4, 5}; // get an iterator to one past the last element json::iterator it = array.end(); // decrement the iterator to point to...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/end.cpp", "license": "mit", "size": 406}
### File: docs/examples/erase__IteratorType.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_object = {{"one", 1}, {"two", 2}}; json j_arra...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/erase__IteratorType.cpp", "license": "mit", "size": 862}
### File: docs/examples/erase__IteratorType_IteratorType.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_object = {{"one", 1}, {"two", 2}}; ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/erase__IteratorType_IteratorType.cpp", "license": "mit", "size": 978}
### File: docs/examples/erase__keytype.c++17.cpp #include <iostream> #include <string_view> #include <nlohmann/json.hpp> using namespace std::string_view_literals; using json = nlohmann::json; int main() { // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; // call erase() auto count_on...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/erase__keytype.c++17.cpp", "license": "mit", "size": 466}
### File: docs/examples/erase__object_t_key_type.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; // call erase() auto count_one = j_object.erase("one"); auto count_three = j_object.era...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/erase__object_t_key_type.cpp", "license": "mit", "size": 396}
### File: docs/examples/erase__size_type.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON array json j_array = {0, 1, 2, 3, 4, 5}; // call erase() j_array.erase(2); // print values std::cout << j_array << '\n'; }
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/erase__size_type.cpp", "license": "mit", "size": 259}
### File: docs/examples/error_handler_t.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON value with invalid UTF-8 byte sequence json j_invalid = "ä\xA9ü"; try { std::cout << j_invalid.dump() << std::endl; } catch (const json:...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/error_handler_t.cpp", "license": "mit", "size": 658}
### File: docs/examples/exception.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { try { // calling at() for a non-existing key json j = {{"foo", "bar"}}; json k = j.at("non-existing"); } catch (const json::exception& e) { ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/exception.cpp", "license": "mit", "size": 438}
### File: docs/examples/find__keytype.c++17.cpp #include <iostream> #include <string_view> #include <nlohmann/json.hpp> using namespace std::string_view_literals; using json = nlohmann::json; int main() { // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; // call find auto it_two = j_o...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/find__keytype.c++17.cpp", "license": "mit", "size": 617}
### File: docs/examples/find__object_t_key_type.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON object json j_object = {{"one", 1}, {"two", 2}}; // call find auto it_two = j_object.find("two"); auto it_three = j_object.find("three");...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/find__object_t_key_type.cpp", "license": "mit", "size": 547}
### File: docs/examples/flatten.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON value json j = { {"pi", 3.141}, {"happy", true}, {"name", "Niels"}, {"nothing", nullptr}, { "...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/flatten.cpp", "license": "mit", "size": 598}
### File: docs/examples/from_bjdata.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create byte vector std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0x54, 0x69, ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_bjdata.cpp", "license": "mit", "size": 574}
### File: docs/examples/from_bson.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create byte vector std::vector<std::uint8_t> v = {0x1b, 0x00, 0x00, 0x00, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_bson.cpp", "license": "mit", "size": 635}
### File: docs/examples/from_cbor.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create byte vector std::vector<std::uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xf5, 0x66, 0x73, 0x...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_cbor.cpp", "license": "mit", "size": 546}
### File: docs/examples/from_json__default_constructible.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; namespace ns { // a simple struct to model a person struct person { std::string name; std::string address; int age; }; } // namespace ns namespace ns { void from_json...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_json__default_constructible.cpp", "license": "mit", "size": 664}
### File: docs/examples/from_json__non_default_constructible.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; namespace ns { // a simple struct to model a person (not default constructible) struct person { person(std::string n, std::string a, int aa) : name(std::move(n)), ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_json__non_default_constructible.cpp", "license": "mit", "size": 1182}
### File: docs/examples/from_msgpack.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create byte vector std::vector<std::uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73,...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_msgpack.cpp", "license": "mit", "size": 556}
### File: docs/examples/from_ubjson.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create byte vector std::vector<std::uint8_t> v = {0x7B, 0x69, 0x07, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x63, 0x74, 0x54, 0x69, ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/from_ubjson.cpp", "license": "mit", "size": 574}
### File: docs/examples/front.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_object = {{"one", 1}, {"two", 2}}; json j_o...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/front.cpp", "license": "mit", "size": 951}
### File: docs/examples/get__PointerType.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON number json value = 17; // explicitly getting pointers auto p1 = value.template get<const json::number_integer_t*>(); auto p2 = value.template g...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get__PointerType.cpp", "license": "mit", "size": 666}
### File: docs/examples/get__ValueType_const.cpp #include <iostream> #include <unordered_map> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON value with different types json json_types = { {"boolean", true}, { "number", { ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get__ValueType_const.cpp", "license": "mit", "size": 1417}
### File: docs/examples/get_allocator.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { auto alloc = json::get_allocator(); using traits_t = std::allocator_traits<decltype(alloc)>; json* j = traits_t::allocate(alloc, 1); traits_t::construct(alloc, j, "Hell...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get_allocator.cpp", "license": "mit", "size": 401}
### File: docs/examples/get_binary.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a binary vector std::vector<std::uint8_t> vec = {0xCA, 0xFE, 0xBA, 0xBE}; // create a binary JSON value with subtype 42 json j = json::binary(vec, 42); // o...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get_binary.cpp", "license": "mit", "size": 408}
### File: docs/examples/get_ptr.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON number json value = 17; // explicitly getting pointers auto p1 = value.get_ptr<const json::number_integer_t*>(); auto p2 = value.get_ptr<json::number_int...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get_ptr.cpp", "license": "mit", "size": 641}
### File: docs/examples/get_ref.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON number json value = 17; // explicitly getting references auto r1 = value.get_ref<const json::number_integer_t&>(); auto r2 = value.get_ref<json::number_i...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get_ref.cpp", "license": "mit", "size": 579}
### File: docs/examples/get_to.cpp #include <iostream> #include <unordered_map> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON value with different types json json_types = { {"boolean", true}, { "number", { {"integer", 42...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/get_to.cpp", "license": "mit", "size": 1362}
### File: docs/examples/insert.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON array json v = {1, 2, 3, 4}; // insert number 10 before number 3 auto new_pos = v.insert(v.begin() + 2, 10); // output new array and result of insert cal...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/insert.cpp", "license": "mit", "size": 352}
### File: docs/examples/insert__count.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON array json v = {1, 2, 3, 4}; // insert number 7 copies of number 7 before number 3 auto new_pos = v.insert(v.begin() + 2, 7, 7); // output new arr...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/insert__count.cpp", "license": "mit", "size": 372}
### File: docs/examples/insert__ilist.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON array json v = {1, 2, 3, 4}; // insert range from v2 before the end of array v auto new_pos = v.insert(v.end(), {7, 8, 9}); // output new array an...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/insert__ilist.cpp", "license": "mit", "size": 367}
### File: docs/examples/insert__range.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON array json v = {1, 2, 3, 4}; // create a JSON array to copy values from json v2 = {"one", "two", "three", "four"}; // insert range from v2 before ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/insert__range.cpp", "license": "mit", "size": 473}
### File: docs/examples/insert__range_object.cpp #include <iostream> #include <nlohmann/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::cou...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/insert__range_object.cpp", "license": "mit", "size": 457}
### File: docs/examples/invalid_iterator.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { try { // calling iterator::key() on non-object iterator json j = "string"; json::iterator it = j.begin(); auto k = it.key(); } catch (...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/invalid_iterator.cpp", "license": "mit", "size": 475}
### File: docs/examples/is_array.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float = 23.42...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_array.cpp", "license": "mit", "size": 951}
### File: docs/examples/is_binary.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float = 23.4...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_binary.cpp", "license": "mit", "size": 961}
### File: docs/examples/is_boolean.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float = 23....
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_boolean.cpp", "license": "mit", "size": 971}
### File: docs/examples/is_discarded.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float = 2...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_discarded.cpp", "license": "mit", "size": 991}
### File: docs/examples/is_null.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float = 23.42;...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_null.cpp", "license": "mit", "size": 941}
### File: docs/examples/is_number.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float = 23.4...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_number.cpp", "license": "mit", "size": 961}
### File: docs/examples/is_number_float.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_float ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_number_float.cpp", "license": "mit", "size": 1021}
### File: docs/examples/is_number_integer.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_floa...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_number_integer.cpp", "license": "mit", "size": 1041}
### File: docs/examples/is_number_unsigned.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_unsigned_integer = 12345678987654321u; json j_number_flo...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_number_unsigned.cpp", "license": "mit", "size": 1051}
### File: docs/examples/is_object.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_number_unsigned_integer = 12345678987654321...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_object.cpp", "license": "mit", "size": 961}
### File: docs/examples/is_primitive.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_number_unsigned_integer = 12345678987654...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_primitive.cpp", "license": "mit", "size": 991}
### File: docs/examples/is_string.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_number_unsigned_integer = 12345678987654321...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_string.cpp", "license": "mit", "size": 961}
### File: docs/examples/is_structured.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_number_unsigned_integer = 1234567898765...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/is_structured.cpp", "license": "mit", "size": 1001}
### File: docs/examples/items.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; // example for an object for (auto& x : j_object.items()) { std...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/items.cpp", "license": "mit", "size": 514}
### File: docs/examples/json_base_class_t.cpp #include <iostream> #include <nlohmann/json.hpp> class visitor_adaptor_with_metadata { public: template <class Fnc> void visit(const Fnc& fnc) const; int metadata = 42; private: template <class Ptr, class Fnc> void do_visit(const Ptr& ptr, const Fn...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_base_class_t.cpp", "license": "mit", "size": 2235}
### File: docs/examples/json_lines.cpp #include <sstream> #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // JSON Lines (see https://jsonlines.org) std::stringstream input; input << R"({"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]} {"name"...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_lines.cpp", "license": "mit", "size": 569}
### File: docs/examples/json_pointer.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // correct JSON pointers json::json_pointer p1; json::json_pointer p2(""); json::json_pointer p3("/"); json::json_pointer p4("//"); json::json_pointer p5("/foo/ba...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer.cpp", "license": "mit", "size": 1056}
### File: docs/examples/json_pointer__back.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON Pointers json::json_pointer ptr1("/foo"); json::json_pointer ptr2("/foo/0"); // call empty() std::cout << "last reference token of \"" << ptr...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__back.cpp", "license": "mit", "size": 421}
### File: docs/examples/json_pointer__empty.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON Pointers json::json_pointer ptr0; json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); json::json_pointer ptr3("/foo/0"); // ca...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__empty.cpp", "license": "mit", "size": 579}
### File: docs/examples/json_pointer__operator__equal.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON pointers json::json_pointer ptr0; json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); // compare JSON pointers std::...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator__equal.cpp", "license": "mit", "size": 645}
### File: docs/examples/json_pointer__operator__equal_stringtype.cpp #include <exception> #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON pointers json::json_pointer ptr0; json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); //...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator__equal_stringtype.cpp", "license": "mit", "size": 917}
### File: docs/examples/json_pointer__operator__notequal.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON pointers json::json_pointer ptr0; json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); // compare JSON pointers st...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator__notequal.cpp", "license": "mit", "size": 645}
### File: docs/examples/json_pointer__operator__notequal_stringtype.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON pointers json::json_pointer ptr0; json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); // different strings...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator__notequal_stringtype.cpp", "license": "mit", "size": 896}
### File: docs/examples/json_pointer__operator_add.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON pointer json::json_pointer ptr("/foo"); std::cout << "\"" << ptr << "\"\n"; // append a JSON Pointer ptr /= json::json_pointer("/bar/b...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator_add.cpp", "license": "mit", "size": 491}
### File: docs/examples/json_pointer__operator_add_binary.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON pointer json::json_pointer ptr("/foo"); // append a JSON Pointer std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator_add_binary.cpp", "license": "mit", "size": 421}
### File: docs/examples/json_pointer__operator_string_t.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON Pointers json::json_pointer ptr1("/foo/0"); json::json_pointer ptr2("/a~1b"); // implicit conversion to string std::string s; ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__operator_string_t.cpp", "license": "mit", "size": 339}
### File: docs/examples/json_pointer__parent_pointer.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON Pointers json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); json::json_pointer ptr3("/foo/0"); // call parent_pointer() ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__parent_pointer.cpp", "license": "mit", "size": 576}
### File: docs/examples/json_pointer__pop_back.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create empty JSON Pointer json::json_pointer ptr("/foo/bar/baz"); std::cout << "\"" << ptr << "\"\n"; // call pop_back() ptr.pop_back(); std::cout <...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__pop_back.cpp", "license": "mit", "size": 418}
### File: docs/examples/json_pointer__push_back.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create empty JSON Pointer json::json_pointer ptr; std::cout << "\"" << ptr << "\"\n"; // call push_back() ptr.push_back("foo"); std::cout << "\"" <...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__push_back.cpp", "license": "mit", "size": 419}
### File: docs/examples/json_pointer__string_t.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { json::json_pointer::string_t s = "This is a string."; std::cout << s << std::endl; std::cout << std::boolalpha << std::is_same<json::json_pointer::string_t, json:...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__string_t.cpp", "license": "mit", "size": 303}
### File: docs/examples/json_pointer__to_string.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // different JSON Pointers json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); json::json_pointer ptr3("/foo/0"); json::json_pointer ptr4("/"); ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/json_pointer__to_string.cpp", "license": "mit", "size": 1210}
### File: docs/examples/max_size.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = 17; json j_number_float = 23.42; json j_object = {{"one", 1}, {"two", 2}}; json ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/max_size.cpp", "license": "mit", "size": 707}
### File: docs/examples/merge_patch.cpp #include <iostream> #include <nlohmann/json.hpp> #include <iomanip> // for std::setw using json = nlohmann::json; using namespace nlohmann::literals; int main() { // the original document json document = R"({ "title": "Goodbye!", "author"...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/merge_patch.cpp", "license": "mit", "size": 1031}
### File: docs/examples/meta.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // call meta() std::cout << std::setw(4) << json::meta() << '\n'; }
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/meta.cpp", "license": "mit", "size": 188}
### File: docs/examples/nlohmann_define_type_intrusive_explicit.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { class person { private: std::string name = "John Doe"; std::string address = "123 Fake St"; int age = -1; ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_intrusive_explicit.cpp", "license": "mit", "size": 1696}
### File: docs/examples/nlohmann_define_type_intrusive_macro.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { class person { private: std::string name = "John Doe"; std::string address = "123 Fake St"; int age = -1; p...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_intrusive_macro.cpp", "license": "mit", "size": 1203}
### File: docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { class person { private: std::string name = "John Doe"; std::string address = "123 Fake St"; ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_intrusive_only_serialize_explicit.cpp", "license": "mit", "size": 919}
### File: docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { class person { private: std::string name = "John Doe"; std::string address = "123 Fake St"; int...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_intrusive_only_serialize_macro.cpp", "license": "mit", "size": 710}
### File: docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { class person { private: std::string name = "John Doe"; std::string address = "123 Fake St"; in...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_intrusive_with_default_explicit.cpp", "license": "mit", "size": 1755}
### File: docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { class person { private: std::string name = "John Doe"; std::string address = "123 Fake St"; int a...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_intrusive_with_default_macro.cpp", "license": "mit", "size": 1126}
### File: docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { struct person { std::string name; std::string address; int age; }; void to_json(nlohmann::json& nlohmann...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp", "license": "mit", "size": 1412}
### File: docs/examples/nlohmann_define_type_non_intrusive_macro.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { struct person { std::string name; std::string address; int age; }; NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(perso...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_non_intrusive_macro.cpp", "license": "mit", "size": 981}
### File: docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { struct person { std::string name; std::string address; int age; }; void to_json(nlohmann:...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_non_intrusive_only_serialize_explicit.cpp", "license": "mit", "size": 660}
### File: docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { struct person { std::string name; std::string address; int age; }; NLOHMANN_DEFINE_TYPE_NON_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_non_intrusive_only_serialize_macro.cpp", "license": "mit", "size": 497}
### File: docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { struct person { std::string name = "John Doe"; std::string address = "123 Fake St"; int age ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp", "license": "mit", "size": 1669}
### File: docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; using namespace nlohmann::literals; namespace ns { struct person { std::string name = "John Doe"; std::string address = "123 Fake St"; int age = -...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp", "license": "mit", "size": 1106}
### File: docs/examples/nlohmann_json_namespace.cpp #include <iostream> #include <nlohmann/json.hpp> // possible use case: use NLOHMANN_JSON_NAMESPACE instead of nlohmann using json = NLOHMANN_JSON_NAMESPACE::json; // macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal #define Q(x) #x #define QUOTE(x...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_json_namespace.cpp", "license": "mit", "size": 353}
### File: docs/examples/nlohmann_json_namespace_begin.c++17.cpp #include <iostream> #include <optional> #include <nlohmann/json.hpp> // partial specialization (see https://json.nlohmann.me/features/arbitrary_types/) NLOHMANN_JSON_NAMESPACE_BEGIN template <typename T> struct adl_serializer<std::optional<T>> { stati...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_json_namespace_begin.c++17.cpp", "license": "mit", "size": 687}
### File: docs/examples/nlohmann_json_namespace_no_version.cpp #include <iostream> #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 1 #include <nlohmann/json.hpp> // macro needed to output the NLOHMANN_JSON_NAMESPACE as string literal #define Q(x) #x #define QUOTE(x) Q(x) int main() { std::cout << QUOTE(NLOHMANN_JSON_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_json_namespace_no_version.cpp", "license": "mit", "size": 284}
### File: docs/examples/nlohmann_json_serialize_enum.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; namespace ns { enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED, TS_INVALID = -1 }; NLOHMANN_JSON_SERIALIZE_ENUM(TaskState, { { TS_INVALID, nullptr }, { ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_json_serialize_enum.cpp", "license": "mit", "size": 1486}
### File: docs/examples/nlohmann_json_serialize_enum_2.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; namespace ns { enum class Color { red, green, blue, unknown }; NLOHMANN_JSON_SERIALIZE_ENUM(Color, { { Color::unknown, "unknown" }, { Color::red, "red" }, { Color::gree...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_json_serialize_enum_2.cpp", "license": "mit", "size": 810}
### File: docs/examples/nlohmann_json_version.cpp #include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { std::cout << "JSON for Modern C++ version " << NLOHMANN_JSON_VERSION_MAJOR << "." << NLOHMANN_JSON_VERSION_MINOR << "." << NLOHMANN...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/nlohmann_json_version.cpp", "license": "mit", "size": 306}
### File: docs/examples/number_float_t.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { std::cout << std::boolalpha << std::is_same<double, json::number_float_t>::value << std::endl; }
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/number_float_t.cpp", "license": "mit", "size": 213}
### File: docs/examples/number_integer_t.cpp #include <iostream> #include <iomanip> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { std::cout << std::boolalpha << std::is_same<std::int64_t, json::number_integer_t>::value << std::endl; }
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/nlohmann_json", "path": "docs/examples/number_integer_t.cpp", "license": "mit", "size": 221}