title
stringclasses
1 value
text
stringlengths
30
1.11M
id
stringlengths
27
31
include/nlohmann/detail/output/output_adapters.hpp/output_stream_adapter/output_stream_adapter class output_stream_adapter: explicit output_stream_adapter(std::basic_ostream<CharType>& s) noexcept : stream(s) {}
negative_train_query0_00098
include/nlohmann/detail/output/output_adapters.hpp/output_string_adapter/output_string_adapter class output_string_adapter: explicit output_string_adapter(StringType& s) noexcept : str(s) {}
negative_train_query0_00099
include/nlohmann/detail/output/output_adapters.hpp/output_adapter/output_adapter class output_adapter: output_adapter(StringType& s) : oa(std::make_shared<output_string_adapter<CharType, StringType>>(s)) {}
negative_train_query0_00100
include/nlohmann/detail/meta/detected.hpp/nonesuch/nonesuch class nonesuch: nonesuch(nonesuch const&&) = delete;
negative_train_query0_00101
include/nlohmann/detail/iterators/iteration_proxy.hpp/int_to_string void int_to_string( string_type& target, std::size_t value ) { target = std::to_string(value); }
negative_train_query0_00102
include/nlohmann/detail/iterators/iteration_proxy.hpp/get auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key()) { return i.key(); }
negative_train_query0_00103
include/nlohmann/detail/iterators/iteration_proxy.hpp/iteration_proxy_value/iteration_proxy_value class iteration_proxy_value: explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {}
negative_train_query0_00104
include/nlohmann/detail/iterators/iteration_proxy.hpp/iteration_proxy/iteration_proxy class iteration_proxy: explicit iteration_proxy(typename IteratorType::reference cont) noexcept : container(cont) {}
negative_train_query0_00105
include/nlohmann/detail/iterators/iter_impl.hpp/iter_impl/iter_impl class iter_impl: explicit iter_impl(pointer object) noexcept : m_object(object) { assert(m_object != nullptr); switch (m_object->m_type) { case value_t::object: { m_it.object_itera...
negative_train_query0_00106
include/nlohmann/detail/iterators/json_reverse_iterator.hpp/json_reverse_iterator/json_reverse_iterator class json_reverse_iterator: explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {}
negative_train_query0_00107
include/nlohmann/detail/conversions/to_chars.hpp/get_cached_power_for_binary_exponent inline cached_power get_cached_power_for_binary_exponent(int e) { // Now // // alpha <= e_c + e + q <= gamma (1) // ==> f_c * 2^alpha <= c * 2^e * 2^q // // and sinc...
negative_train_query0_00108
include/nlohmann/detail/conversions/to_chars.hpp/grisu2_round inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k) { assert(len >= 1); assert(dist <= delta); assert(rest <= delta); assert(ten_k > 0); ...
negative_train_query0_00109
include/nlohmann/detail/conversions/to_chars.hpp/grisu2 inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { assert(m_plus.e == m_minus.e); assert(m_plus.e == v.e); // --------(-----------------------+-----------------------)-------- ...
negative_train_query0_00110
include/nlohmann/detail/conversions/to_chars.hpp/reinterpret_bits Target reinterpret_bits(const Source source) { static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); Target target; std::memcpy(&target, &source, sizeof(Source)); return target; }
negative_train_query0_00111
include/nlohmann/detail/conversions/to_chars.hpp/find_largest_pow10 inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) { // LCOV_EXCL_START if (n >= 1000000000) { pow10 = 1000000000; return 10; } // LCOV_EXCL_STOP else if (n >= 100000000) { pow...
negative_train_query0_00112
include/nlohmann/detail/conversions/to_chars.hpp/compute_boundaries boundaries compute_boundaries(FloatType value) { assert(std::isfinite(value)); assert(value > 0); // Convert the IEEE representation into a diyfp. // // If v is denormal: // value = 0.F * 2^(1 - bias) = ( F) * 2^(...
negative_train_query0_00113
include/nlohmann/detail/conversions/to_chars.hpp/grisu2_digit_gen inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus) { static_assert(kAlpha >= -60, "internal error"); static_assert(kGamma <= -32, "internal error"); ...
negative_train_query0_00114
include/nlohmann/detail/conversions/to_chars.hpp/diyfp/diyfp class diyfp: constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
negative_train_query0_00115
include/nlohmann/detail/conversions/to_json.hpp/construct static void construct(BasicJsonType& j, const CompatibleArrayType& arr) { using std::begin; using std::end; j.m_type = value_t::array; j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(ar...
negative_train_query0_00116
include/nlohmann/detail/conversions/to_json.hpp/to_json void to_json(BasicJsonType& j, const T& b) { j = { {b.key(), b.value()} }; }
negative_train_query0_00117
include/nlohmann/detail/conversions/to_json.hpp/to_json_tuple_impl void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...> /*unused*/) { j = { std::get<Idx>(t)... }; }
negative_train_query0_00118
include/nlohmann/detail/conversions/from_json.hpp/from_json auto from_json(const BasicJsonType& j, T (&arr)[N]) -> decltype(j.template get<T>(), void()) { for (std::size_t i = 0; i < N; ++i) { arr[i] = j.at(i).template get<T>(); } }
negative_train_query0_00119
include/nlohmann/detail/conversions/from_json.hpp/get_arithmetic_value void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) { switch (static_cast<value_t>(j)) { case value_t::number_unsigned: { val = static_cast<ArithmeticType>(*j.template get_ptr<const typename Bas...
negative_train_query0_00120
include/nlohmann/detail/conversions/from_json.hpp/from_json_array_impl auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr, priority_tag<2> /*unused*/) -> decltype(j.template get<T>(), void()) { for (std::size_t i = 0; i < N; ++i) { arr[i] = j.at(i).template...
negative_train_query0_00121
include/nlohmann/detail/conversions/from_json.hpp/from_json_tuple_impl void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence<Idx...> /*unused*/) { t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...); }
negative_train_query0_00122
doc/examples/insert__range.cpp/main 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 the end of array v auto new_pos = v.insert(v.end(), v2.begin(), v2.end()); //...
negative_train_query0_00123
doc/examples/is_array.cpp/main 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; json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; ...
negative_train_query0_00124
doc/examples/max_size.cpp/main 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_array = {1, 2, 4, 8, 16}; json j_string = "Hello, world"; // call max_size(...
negative_train_query0_00125
doc/examples/unflatten.cpp/main int main() { // create JSON value json j_flattened = { {"/answer/everything", 42}, {"/happy", true}, {"/list/0", 1}, {"/list/1", 0}, {"/list/2", 2}, {"/name", "Niels"}, {"/nothing", nullptr}, {"/object/currency",...
negative_train_query0_00126
doc/examples/front.cpp/main 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_object_empty(json::value_t::object); json j_array = {1, 2, 4, 8, 16}; json j_ar...
negative_train_query0_00127
doc/examples/get__ValueType_const.cpp/main int main() { // create a JSON value with different types json json_types = { {"boolean", true}, { "number", { {"integer", 42}, {"floating-point", 17.23} } }, {"string", "Hello, ...
negative_train_query0_00128
doc/examples/parse__istream__parser_callback_t.cpp/main int main() { // a JSON text auto text = R"( { "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "http://www.example.com/image/4819...
negative_train_query0_00129
doc/examples/parse__contiguouscontainer__parser_callback_t.cpp/main int main() { // a JSON text given as std::vector std::vector<uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; // parse and serialize JSON json j_complete = json::parse(text); std::cout << std::setw(4) << j_complete << "\n...
negative_train_query0_00130
doc/examples/get__PointerType.cpp/main int main() { // create a JSON number json value = 17; // explicitly getting pointers auto p1 = value.get<const json::number_integer_t*>(); auto p2 = value.get<json::number_integer_t*>(); auto p3 = value.get<json::number_integer_t* const>(); auto p4 = v...
negative_train_query0_00131
doc/examples/size.cpp/main 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_object_empty(json::value_t::object); json j_array = {1, 2, 4, 8, 16}; json j_arr...
negative_train_query0_00132
doc/examples/json_pointer__operator_add.cpp/main int main() { // create a JSON pointer json::json_pointer ptr("/foo"); std::cout << ptr << '\n'; // append a JSON Pointer ptr /= json::json_pointer("/bar/baz"); std::cout << ptr << '\n'; // append a string ptr /= "fob"; std::cout << p...
negative_train_query0_00133
doc/examples/erase__IteratorType.cpp/main 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_array = {1, 2, 4, 8, 16}; json j_string = "Hello, world"; // call erase() j_b...
negative_train_query0_00134
doc/examples/operator__equal.cpp/main int main() { // create several JSON values json array_1 = {1, 2, 3}; json array_2 = {1, 2, 4}; json object_1 = {{"A", "a"}, {"B", "b"}}; json object_2 = {{"B", "b"}, {"A", "a"}}; json number_1 = 17; json number_2 = 17.000000000000001L; json string_1 ...
negative_train_query0_00135
doc/examples/basic_json__value_t.cpp/main int main() { // create the different JSON values with default values json j_null(json::value_t::null); json j_boolean(json::value_t::boolean); json j_number_integer(json::value_t::number_integer); json j_number_float(json::value_t::number_float); json j_...
negative_train_query0_00136
doc/examples/get_ref.cpp/main 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_integer_t&>(); // print the values std::cout << r1 << ' ' << r2 << '\n'; ...
negative_train_query0_00137
doc/examples/erase__size_type.cpp/main 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'; }
negative_train_query0_00138
doc/examples/erase__key_type.cpp/main 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.erase("three"); // print values std::cout << j_object << '\n'; std::cout << count_one...
negative_train_query0_00139
doc/examples/json_pointer__operator_add_binary.cpp/main int main() { // create a JSON pointer json::json_pointer ptr("/foo"); // append a JSON Pointer std::cout << ptr / json::json_pointer("/bar/baz") << '\n'; // append a string std::cout << ptr / "fob" << '\n'; // append an array index ...
negative_train_query0_00140
doc/examples/sax_parse.cpp/main int main() { // a JSON text auto text = R"( { "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "http://www.example.com/image/481989943", ...
negative_train_query0_00141
doc/examples/swap__object_t.cpp/main int main() { // create a JSON value json value = { {"translation", {{"one", "eins"}, {"two", "zwei"}}} }; // create an object_t json::object_t object = {{"cow", "Kuh"}, {"dog", "Hund"}}; // swap the object stored in the JSON value value["translation"].swap(...
negative_train_query0_00142
doc/examples/end.cpp/main 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 the last element --it; // serialize the element that the iterator points to ...
negative_train_query0_00143
doc/examples/operatorarray__size_type.cpp/main int main() { // create a JSON array json array = {1, 2, 3, 4, 5}; // output element at index 3 (fourth element) std::cout << array[3] << '\n'; // change last element to 6 array[array.size() - 1] = 6; // output changed array std::cout << a...
negative_train_query0_00144
doc/examples/json_pointer__empty.cpp/main int main() { // different JSON Pointers json::json_pointer ptr0; json::json_pointer ptr1(""); json::json_pointer ptr2("/foo"); json::json_pointer ptr3("/foo/0"); // call empty() std::cout << std::boolalpha << ptr0 << ": " << ptr0.empty...
negative_train_query0_00145
doc/examples/operatorarray__key_type.cpp/main int main() { // create a JSON object json object = { {"one", 1}, {"two", 2}, {"three", 2.9} }; // output element with key "two" std::cout << object["two"] << "\n\n"; // change element with key "three" object["three"] = 3; // ou...
negative_train_query0_00146
doc/examples/to_bson.cpp/main int main() { // create a JSON value json j = R"({"compact": true, "schema": 0})"_json; // serialize it to BSON std::vector<uint8_t> v = json::to_bson(j); // print the vector content for (auto& byte : v) { std::cout << "0x" << std::hex << std::setw(2) <...
negative_train_query0_00147
doc/examples/insert__ilist.cpp/main 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 and result of insert call std::cout << *new_pos << '\n'; std::cout << v << '\n';...
negative_train_query0_00148
doc/examples/begin.cpp/main int main() { // create an array value json array = {1, 2, 3, 4, 5}; // get an iterator to the first element json::iterator it = array.begin(); // serialize the element that the iterator points to std::cout << *it << '\n'; }
negative_train_query0_00149
doc/examples/to_msgpack.cpp/main int main() { // create a JSON value json j = R"({"compact": true, "schema": 0})"_json; // serialize it to MessagePack std::vector<uint8_t> v = json::to_msgpack(j); // print the vector content for (auto& byte : v) { std::cout << "0x" << std::hex << s...
negative_train_query0_00150
doc/examples/exception.cpp/main int main() { try { // calling at() for a non-existing key json j = {{"foo", "bar"}}; json k = j.at("non-existing"); } catch (json::exception& e) { // output exception information std::cout << "message: " << e.what() << '\n' ...
negative_train_query0_00151
doc/examples/type_error.cpp/main int main() { try { // calling push_back() on a string value json j = "string"; j.push_back("another string"); } catch (json::type_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' ...
negative_train_query0_00152
doc/examples/type_name.cpp/main int main() { // create JSON values json j_null; json j_boolean = true; json j_number_integer = -17; json j_number_unsigned = 42u; json j_number_float = 23.42; json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; json j_string = "H...
negative_train_query0_00153
doc/examples/parse__iteratortype__parser_callback_t.cpp/main int main() { // a JSON text given as std::vector std::vector<uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; // parse and serialize JSON json j_complete = json::parse(text.begin(), text.end()); std::cout << std::setw(4) << j_co...
negative_train_query0_00154
doc/examples/rbegin.cpp/main int main() { // create an array value json array = {1, 2, 3, 4, 5}; // get an iterator to the reverse-beginning json::reverse_iterator it = array.rbegin(); // serialize the element that the iterator points to std::cout << *it << '\n'; }
negative_train_query0_00155
doc/examples/at__object_t_key_type.cpp/main int main() { // create JSON object json object = { {"the good", "il buono"}, {"the bad", "il cattivo"}, {"the ugly", "il brutto"} }; // output element with key "the ugly" std::cout << object.at("the ugly") << '\n'; // chan...
negative_train_query0_00156
doc/examples/other_error.cpp/main int main() { try { // executing a failing JSON Patch operation json value = R"({ "best_biscuit": { "name": "Oreo" } })"_json; json patch = R"([{ "op": "test", "path": "/best_biscuit/...
negative_train_query0_00157
doc/examples/flatten.cpp/main int main() { // create JSON value json j = { {"pi", 3.141}, {"happy", true}, {"name", "Niels"}, {"nothing", nullptr}, { "answer", { {"everything", 42} } }, {"list", {1, 0, 2}}, ...
negative_train_query0_00158
doc/examples/operator__greater.cpp/main int main() { // create several JSON values json array_1 = {1, 2, 3}; json array_2 = {1, 2, 4}; json object_1 = {{"A", "a"}, {"B", "b"}}; json object_2 = {{"B", "b"}, {"A", "a"}}; json number_1 = 17; json number_2 = 17.0000000000001L; json string_1 ...
negative_train_query0_00159
doc/examples/swap__array_t.cpp/main int main() { // create a JSON value json value = {{"array", {1, 2, 3, 4}}}; // create an array_t json::array_t array = {"Snap", "Crackle", "Pop"}; // swap the array stored in the JSON value value["array"].swap(array); // output the values std::cout ...
negative_train_query0_00160
doc/examples/to_cbor.cpp/main int main() { // create a JSON value json j = R"({"compact": true, "schema": 0})"_json; // serialize it to CBOR std::vector<uint8_t> v = json::to_cbor(j); // print the vector content for (auto& byte : v) { std::cout << "0x" << std::hex << std::setw(2) <...
negative_train_query0_00161
doc/examples/rend.cpp/main int main() { // create an array value json array = {1, 2, 3, 4, 5}; // get an iterator to the reverse-end json::reverse_iterator it = array.rend(); // increment the iterator to point to the first element --it; // serialize the element that the iterator points to...
negative_train_query0_00162
doc/examples/operatorjson_pointer_const.cpp/main int main() { // create a JSON value const json j = { {"number", 1}, {"string", "foo"}, {"array", {1, 2}} }; // read-only access // output element with JSON pointer "/number" std::cout << j["/number"_json_pointer] << '\n'; // outp...
negative_train_query0_00163
doc/examples/clear.cpp/main 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_array = {1, 2, 4, 8, 16}; json j_string = "Hello, world"; // call clear() ...
negative_train_query0_00164
doc/examples/is_number.cpp/main 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; json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; ...
negative_train_query0_00165
doc/examples/update.cpp/main int main() { // create two JSON objects json o1 = R"( {"color": "red", "price": 17.99} )"_json; json o2 = R"( {"color": "blue", "speed": 100} )"_json; // add all keys from o2 to o1 (updating "color") o1.update(o2); // output updated object o1 std::cout << std::...
negative_train_query0_00166
doc/examples/json_pointer__push_back.cpp/main int main() { // create empty JSON Pointer json::json_pointer ptr; std::cout << ptr << '\n'; // call push_back() ptr.push_back("foo"); std::cout << ptr << '\n'; ptr.push_back("0"); std::cout << ptr << '\n'; ptr.push_back("bar"); std...
negative_train_query0_00167
doc/examples/emplace.cpp/main 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 auto res1 = object.emplace("three", 3); null.emplace("A", "a"); null.emplace...
negative_train_query0_00168
doc/examples/meta.cpp/main int main() { // call meta() std::cout << std::setw(4) << json::meta() << '\n'; }
negative_train_query0_00169
doc/examples/merge_patch.cpp/main int main() { // the original document json document = R"({ "title": "Goodbye!", "author": { "givenName": "John", "familyName": "Doe" }, "tags": [ "example...
negative_train_query0_00170
doc/examples/basic_json__value.cpp/main int main() { // create a JSON object with different entry types json j = { {"integer", 1}, {"floating", 42.23}, {"string", "hello world"}, {"boolean", true}, {"object", {{"key1", 1}, {"key2", 2}}}, {"array", {1, 2, 3}} ...
negative_train_query0_00171
doc/examples/basic_json__moveconstructor.cpp/main int main() { // create a JSON value json a = 23; // move contents of a to b json b(std::move(a)); // serialize the JSON arrays std::cout << a << '\n'; std::cout << b << '\n'; }
negative_train_query0_00172
doc/examples/operator__greaterequal.cpp/main int main() { // create several JSON values json array_1 = {1, 2, 3}; json array_2 = {1, 2, 4}; json object_1 = {{"A", "a"}, {"B", "b"}}; json object_2 = {{"B", "b"}, {"A", "a"}}; json number_1 = 17; json number_2 = 17.0000000000001L; json stri...
negative_train_query0_00173
doc/examples/diff.cpp/main int main() { // the source document json source = R"( { "baz": "qux", "foo": "bar" } )"_json; // the target document json target = R"( { "baz": "boo", "hello": [ "world" ] ...
negative_train_query0_00174
doc/examples/patch.cpp/main int main() { // the original document json doc = R"( { "baz": "qux", "foo": "bar" } )"_json; // the patch json patch = R"( [ { "op": "replace", "path": "/baz", "value": "boo" }, { "op": "add", "path": "/hell...
negative_train_query0_00175
doc/examples/items.cpp/main 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::cout << "key: " << x.key() << ", value: " << x.value() << '\n'; } // exampl...
negative_train_query0_00176
doc/examples/contains_json_pointer.cpp/main int main() { // create a JSON value json j = { {"number", 1}, {"string", "foo"}, {"array", {1, 2}} }; std::cout << std::boolalpha << j.contains("/number"_json_pointer) << '\n' << j.contains("/string"_json_pointer) << '\...
negative_train_query0_00177
doc/examples/iterator_wrapper.cpp/main 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 : json::iterator_wrapper(j_object)) { std::cout << "key: " << x.key() << ", value: " << x.value() <<...
negative_train_query0_00178
doc/examples/dump.cpp/main 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:" << '\n' << j_object.dump() << "\n\n" << j_object.dump(-1) << "...
negative_train_query0_00179
doc/examples/is_object.cpp/main 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 = 12345678987654321u; json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; ...
negative_train_query0_00180
doc/examples/at_json_pointer_const.cpp/main int main() { // create a JSON value const json j = { {"number", 1}, {"string", "foo"}, {"array", {1, 2}} }; // read-only access // output element with JSON pointer "/number" std::cout << j.at("/number"_json_pointer) << '\n'; // output...
negative_train_query0_00181
doc/examples/contains.cpp/main int main() { // create some JSON values json j_object = R"( {"key": "value"} )"_json; json j_array = R"( [1, 2, 3] )"_json; // call contains std::cout << std::boolalpha << "j_object contains 'key': " << j_object.contains("key") << '\n' << "...
negative_train_query0_00182
doc/examples/is_boolean.cpp/main 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; json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16};...
negative_train_query0_00183
doc/examples/parse__string__parser_callback_t.cpp/main int main() { // a JSON text auto text = R"( { "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "http://www.example.com/image/48198...
negative_train_query0_00184
doc/examples/operator__notequal__nullptr_t.cpp/main int main() { // create several JSON values json array = {1, 2, 3}; json object = {{"A", "a"}, {"B", "b"}}; json number = 17; json string = "foo"; json null; // output values and comparisons std::cout << std::boolalpha; std::cout <<...
negative_train_query0_00185
doc/examples/insert__count.cpp/main 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 array and result of insert call std::cout << *new_pos << '\n'; std::cout << v << ...
negative_train_query0_00186
doc/examples/basic_json__InputIt_InputIt.cpp/main int main() { // create JSON values json j_array = {"alpha", "bravo", "charly", "delta", "easy"}; json j_number = 42; json j_object = {{"one", "eins"}, {"two", "zwei"}}; // create copies using iterators json j_array_range(j_array.begin() + 1, j_a...
negative_train_query0_00187
doc/examples/operator__lessequal.cpp/main int main() { // create several JSON values json array_1 = {1, 2, 3}; json array_2 = {1, 2, 4}; json object_1 = {{"A", "a"}, {"B", "b"}}; json object_2 = {{"B", "b"}, {"A", "a"}}; json number_1 = 17; json number_2 = 17.0000000000001L; json string_...
negative_train_query0_00188
doc/examples/operatorarray__size_type_const.cpp/main int main() { // create JSON array const json array = {"first", "2nd", "third", "fourth"}; // output element at index 2 (third element) std::cout << array.at(2) << '\n'; }
negative_train_query0_00189
doc/examples/parse_error.cpp/main int main() { try { // parsing input with a syntax error json::parse("[1,2,3,]"); } catch (json::parse_error& e) { // output exception information std::cout << "message: " << e.what() << '\n' << "exception id: " << e....
negative_train_query0_00190
doc/examples/json_pointer__pop_back.cpp/main 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 << ptr << '\n'; ptr.pop_back(); std::cout << ptr << '\n'; ptr.pop_back(); std::...
negative_train_query0_00191
doc/examples/operator__equal__nullptr_t.cpp/main int main() { // create several JSON values json array = {1, 2, 3}; json object = {{"A", "a"}, {"B", "b"}}; json number = 17; json string = "foo"; json null; // output values and comparisons std::cout << std::boolalpha; std::cout << ar...
negative_train_query0_00192
doc/examples/operator_serialize.cpp/main int main() { // create JSON values json j_object = {{"one", 1}, {"two", 2}}; json j_array = {1, 2, 4, 8, 16}; // serialize without indentation std::cout << j_object << "\n\n"; std::cout << j_array << "\n\n"; // serialize with indentation std::co...
negative_train_query0_00193
doc/examples/basic_json__list_init_t.cpp/main int main() { // create JSON values json j_empty_init_list = json({}); json j_object = { {"one", 1}, {"two", 2} }; json j_array = {1, 2, 3, 4}; json j_nested_object = { {"one", {1}}, {"two", {1, 2}} }; json j_nested_array = { {{1}, "one"}, {{1, 2}, "t...
negative_train_query0_00194
doc/examples/insert__range_object.cpp/main 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 j...
negative_train_query0_00195
doc/examples/push_back__object_t__value.cpp/main 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 object.push_back(json::object_t::value_type("three", 3)); obj...
negative_train_query0_00196
doc/examples/empty.cpp/main 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_object_empty(json::value_t::object); json j_array = {1, 2, 4, 8, 16}; json j_ar...
negative_train_query0_00197