keyword stringclasses 7
values | repo_name stringlengths 8 98 | file_path stringlengths 4 244 | file_extension stringclasses 29
values | file_size int64 0 84.1M | line_count int64 0 1.6M | content stringlengths 1 84.1M ⌀ | language stringclasses 14
values |
|---|---|---|---|---|---|---|---|
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/erase__IteratorType.cpp | .cpp | 862 | 32 | #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_array = {1, 2, 4, 8, 16};
json j_string = "Hello... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/from_json__non_default_constructible.cpp | .cpp | 1,182 | 54 | #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)), address(std::move(a)), age(aa)
{}
std::string name;
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/is_string.cpp | .cpp | 961 | 31 | #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 = 12345678987654321u;
json j_object = {{"one", 1}, {"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/basic_json__nullptr_t.cpp | .cpp | 298 | 17 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// implicitly create a JSON null value
json j1;
// explicitly create a JSON null value
json j2(nullptr);
// serialize the JSON null value
std::cout << j1 << '\n' << j2 << '\n';
}
| C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_json_namespace_begin.c++17.cpp | .cpp | 687 | 34 | #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>>
{
static void to_json(json& j, const std::optional<T>& opt)
{
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/value__json_ptr.cpp | .cpp | 907 | 32 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON object with different entry types
json j =
{
{"integer", 1},
{"floating", 42.23},
{"string", "hello world"},
{"boolean", true},
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/meta.cpp | .cpp | 188 | 12 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// call meta()
std::cout << std::setw(4) << json::meta() << '\n';
}
| C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/binary.cpp | .cpp | 408 | 17 | #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);
// output type and subtype
std::cout <<... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/diagnostics_standard.cpp | .cpp | 349 | 21 | #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"];
}
catch (json::exception& e)
{
std::cout ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp | .cpp | 363 | 16 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text given as std::vector
std::vector<std::uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'};
// parse and serialize JSON
json j_complete = json::parse(text);
std::cout ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/ordered_json.cpp | .cpp | 224 | 15 | #include <iostream>
#include <nlohmann/json.hpp>
using ordered_json = nlohmann::ordered_json;
int main()
{
ordered_json j;
j["one"] = 1;
j["two"] = 2;
j["three"] = 3;
std::cout << j.dump(2) << '\n';
}
| C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/basic_json__InputIt_InputIt.cpp | .cpp | 848 | 33 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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_... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__operator_add_binary.cpp | .cpp | 421 | 20 | #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";
// append a string
std::cout << "\"" << ptr / "fob... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator_array__object_t_key_type_const.cpp | .cpp | 285 | 17 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON object
const json object =
{
{"one", 1}, {"two", 2}, {"three", 2.9}
};
// output element with key "two"
std::cout << object["two"] << '\n';
}
| C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_define_type_non_intrusive_with_default_explicit.cpp | .cpp | 1,669 | 54 | #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 = -1;
person() = default;
person(std::string name_, std::string address_, in... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_json_serialize_enum.cpp | .cpp | 1,486 | 60 | #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 },
{ TS_STOPPED, "stopped" },
{ TS_RUNNING, "running" },
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_lines.cpp | .cpp | 569 | 23 | #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": "Alexa", "wins": [["two pair", "4♠"],... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/at__object_t_key_type.cpp | .cpp | 982 | 49 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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.... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/cend.cpp | .cpp | 413 | 20 | #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::const_iterator it = array.cend();
// decrement the iterator to point to the last element
--i... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/contains__keytype.c++17.cpp | .cpp | 635 | 21 | #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"} )"_json;
json j_array = R"( [1, 2, 3] )"_json;
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator_array__json_pointer.cpp | .cpp | 1,366 | 50 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
// read-only access
// output element with JSON pointer "/number"
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/crbegin.cpp | .cpp | 350 | 17 | #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 element that the iterator points to
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/emplace.cpp | .cpp | 775 | 32 | #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
auto res1 = object.emplace("three"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/get__ValueType_const.cpp | .cpp | 1,417 | 51 | #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},
{"floating-point... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/is_null.cpp | .cpp | 941 | 31 | #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;
json j_object = {{"one", 1}, {"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/size.cpp | .cpp | 864 | 30 | #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_object_empty(json::value_t::object)... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__operator__notequal.cpp | .cpp | 645 | 20 | #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::cout << std::boolalpha
<< "\"" << ptr0 << "\... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/erase__keytype.c++17.cpp | .cpp | 466 | 21 | #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_one = j_object.erase("one"sv);
auto count_three... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/to_bson.cpp | .cpp | 507 | 23 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j = R"({"compact": true, "schema": 0})"_json;
// serialize it to BSON
std::vector<std::uint8_t> v = json::to_bson(j);
// p... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/object.cpp | .cpp | 701 | 29 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON objects
json j_no_init_list = json::object();
json j_empty_init_list = json::object({});
json j_list_of_pairs = json::object({ {"one", 1}, {"two", 2} });
// serialize the JSON objects
std... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/dump.cpp | .cpp | 1,472 | 49 | #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:" << '\n'
<< j_object.dum... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/diagnostics_extended.cpp | .cpp | 378 | 23 | #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"]["housenumber"];
}
catch (json::exception... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__parent_pointer.cpp | .cpp | 576 | 19 | #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()
std::cout << std::boolalpha
<< "parent ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator_array__json_pointer_const.cpp | .cpp | 684 | 26 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
const json j =
{
{"number", 1}, {"string", "foo"}, {"array", {1, 2}}
};
// read-only access
// output element with JSON pointer "/numb... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/from_json__default_constructible.cpp | .cpp | 664 | 38 | #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(const json& j, person& p)
{
j.at("name").get_to(p.name);... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__operator__equal_stringtype.cpp | .cpp | 917 | 34 | #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");
// different strings
std::string str0("");
std::string str1("/f... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/diff.cpp | .cpp | 741 | 38 | #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;
// the target document
json ta... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/swap__object_t.cpp | .cpp | 494 | 21 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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 th... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/parse__string__parser_callback_t.cpp | .cpp | 1,193 | 50 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text
auto text = R"(
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": {
"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__to_string.cpp | .cpp | 1,210 | 35 | #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("/");
json::json_pointer ptr5("/a~1b");
json::json_... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/at__size_type.cpp | .cpp | 883 | 44 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON array
json array = {"first", "2nd", "third", "fourth"};
// output element at index 2 (third element)
std::cout << array.at(2) << '\n';
// change element at index 1 (second element) to "secon... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/erase__object_t_key_type.cpp | .cpp | 396 | 19 | #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.erase("three");
// print values
std::cout << j_... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator_array__keytype.c++17.cpp | .cpp | 734 | 35 | #include <iostream>
#include <iomanip>
#include <string_view>
#include <nlohmann/json.hpp>
using namespace std::string_view_literals;
using json = nlohmann::json;
int main()
{
// create a JSON object
json object =
{
{"one", 1}, {"two", 2}, {"three", 2.9}
};
// output element with key "two... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/get__PointerType.cpp | .cpp | 666 | 22 | #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 get<json::number_integer_t*>();
auto p3 = ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/type.cpp | .cpp | 1,031 | 29 | #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 = 42u;
json j_number_float = 23.42;
json j_object = {{"one", 1}, {"two", 2}};
json j_... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/empty.cpp | .cpp | 907 | 31 | #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_object_empty(json::value_t::object)... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/default_object_comparator_t.cpp | .cpp | 325 | 12 | #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::default_object_comparator_t{}("three", "four") << std::end... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/swap__binary_t.cpp | .cpp | 432 | 21 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a binary value
json value = json::binary({1, 2, 3});
// create a binary_t
json::binary_t binary = {{4, 5, 6}};
// swap the object stored in the JSON value
value.swap(binary);
// output t... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/from_bjdata.cpp | .cpp | 574 | 21 | #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, 0x06, 0x73, 0x63, 0x68,
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/to_bjdata.cpp | .cpp | 1,481 | 65 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
// function to print BJData's diagnostic format
void print_byte(uint8_t byte)
{
if (32 < byte and byte < 128)
{
std::cout << (char)byte;
}
else
{
std... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/parse__array__parser_callback_t.cpp | .cpp | 678 | 31 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text
char text[] = R"(
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": {
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer.cpp | .cpp | 1,038 | 48 | #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/bar");
json::json_pointer p6("/foo/bar/... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_define_type_intrusive_macro.cpp | .cpp | 1,197 | 49 | #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;
public:
person() = default;
person(std::string name_, std:... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_json_serialize_enum_2.cpp | .cpp | 810 | 34 | #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::green, "green" }, { Color::blue, "blue" },
{ Color::red, "r... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator__value_t.cpp | .cpp | 1,361 | 39 | #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 = 42u;
json j_number_float = 23.42;
json j_object = {{"one", 1}, {"two", 2}};
json j_... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/std_hash.cpp | .cpp | 803 | 20 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
std::cout << "hash(null) = " << std::hash<json> {}(json(nullptr)) << '\n'
<< "hash(false) = " << std::hash<json> {}(json(false)) << '\n'
<< ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/get_allocator.cpp | .cpp | 401 | 19 | #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, "Hello, world!");
std::cout << *j << std::... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/push_back.cpp | .cpp | 440 | 26 | #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
array.push_back(6);
array += 7;
null ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/to_json.cpp | .cpp | 513 | 33 | #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 to_json(json& j, const person& p)
{
j = json{ {"name", p.name}, {"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator__less.cpp | .cpp | 821 | 25 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator__greater.cpp | .cpp | 817 | 25 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/exception.cpp | .cpp | 432 | 21 | #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 (json::exception& e)
{
// output exception information
s... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/items.cpp | .cpp | 514 | 24 | #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::cout << "key: " << x.key() << ",... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/is_boolean.cpp | .cpp | 971 | 31 | #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;
json j_object = {{"one", 1}, {"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__pop_back.cpp | .cpp | 418 | 22 | #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 << "\"" << ptr << "\"\n";
ptr.pop_back();
s... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_define_type_non_intrusive_explicit.cpp | .cpp | 1,406 | 54 | #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_json_j, const person& nlohmann_json_t)
{
nlohmann_json_j["name"] = ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/erase__IteratorType_IteratorType.cpp | .cpp | 978 | 32 | #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_array = {1, 2, 4, 8, 16};
json j_string = "Hello... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/to_msgpack.cpp | .cpp | 517 | 23 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create a JSON value
json j = R"({"compact": true, "schema": 0})"_json;
// serialize it to MessagePack
std::vector<std::uint8_t> v = json::to_msgpack(j);... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/object_comparator_t.cpp | .cpp | 377 | 12 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
std::cout << std::boolalpha
<< "json::object_comparator_t(\"one\", \"two\") = " << json::object_comparator_t{}("one", "two") << "\n"
<< "json::object_comparator_t(\"three\", \"four\") = " << json... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/insert__count.cpp | .cpp | 372 | 18 | #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 array and result of insert call
std::cout... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/byte_container_with_subtype__set_subtype.cpp | .cpp | 594 | 23 | #include <iostream>
#include <nlohmann/json.hpp>
// define a byte container based on std::vector
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
using json = nlohmann::json;
int main()
{
std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
// cr... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/from_cbor.cpp | .cpp | 546 | 21 | #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, 0x63, 0x68, 0x65, 0x6d,
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/out_of_range.cpp | .cpp | 412 | 21 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
try
{
// calling at() for an invalid index
json j = {1, 2, 3, 4};
j.at(4) = 10;
}
catch (json::out_of_range& e)
{
// output exception information
std::cout << "message... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator_array__size_type_const.cpp | .cpp | 268 | 14 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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';
}
| C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__back.cpp | .cpp | 421 | 16 | #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 \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n"
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/error_handler_t.cpp | .cpp | 652 | 25 | #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 (json::type_error& e)
{
std::cout << e.what(... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/std_swap.cpp | .cpp | 382 | 20 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create JSON values
json j1 = {{"one", 1}, {"two", 2}};
json j2 = {1, 2, 4, 8, 16};
std::cout << "j1 = " << j1 << " | j2 = " << j2 << '\n';
// swap values
std::swap(j1, j2);
s... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_define_type_intrusive_explicit.cpp | .cpp | 1,690 | 61 | #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;
public:
person() = default;
person(std::string name_, std:... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator__equal__specializations.cpp | .cpp | 474 | 17 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
nlohmann::json uj1 = {{"version", 1}, {"type", "integer"}};
nlohmann::json uj2 = {{"type", "integer"}, {"version", 1}};
nlohmann::ordered_json oj1 = {{"version", 1}, {"type", "integer"}};
nlo... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/is_array.cpp | .cpp | 951 | 31 | #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;
json j_object = {{"one", 1}, {"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__operator__notequal_stringtype.cpp | .cpp | 896 | 33 | #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
std::string str0("");
std::string str1("/foo");
std::string... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/emplace_back.cpp | .cpp | 452 | 25 | #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
array.emplace_back(6);
null.emplace_back(... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/number_float_t.cpp | .cpp | 213 | 11 | #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;
}
| C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/nlohmann_define_type_non_intrusive_with_default_macro.cpp | .cpp | 1,106 | 41 | #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 = -1;
person() = default;
person(std::string name_, std::string address_, in... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/byte_container_with_subtype__clear_subtype.cpp | .cpp | 576 | 22 | #include <iostream>
#include <nlohmann/json.hpp>
// define a byte container based on std::vector
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
using json = nlohmann::json;
int main()
{
std::vector<std::uint8_t> bytes = {{0xca, 0xfe, 0xba, 0xbe}};
// cr... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/insert.cpp | .cpp | 352 | 18 | #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 call
std::cout << *new_pos << '\n'... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/is_number_float.cpp | .cpp | 1,021 | 31 | #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;
json j_object = {{"one", 1}, {"... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/update__range.cpp | .cpp | 727 | 25 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
int main()
{
// create two JSON objects
json o1 = R"( {"color": "red", "price": 17.99, "names": {"de": "Flugzeug"}} )"_json;
json o2 = R"( {"color": "blue", "speed": 100, "n... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/basic_json__basic_json.cpp | .cpp | 338 | 18 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON array
json j1 = {"one", "two", 3, 4.5, false};
// create a copy
json j2(j1);
// serialize the JSON array
std::cout << j1 << " = " << j2 << '\n';
std::cout << std::boolalpha << (j1 ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/from_msgpack.cpp | .cpp | 556 | 21 | #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, 0x63, 0x68, 0x65, 0x6d,
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/operator_deserialize.cpp | .cpp | 524 | 27 | #include <iostream>
#include <iomanip>
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create stream with serialized JSON
std::stringstream ss;
ss << R"({
"number": 23,
"string": "Hello, world!",
"array": [1, 2, 3, 4, 5],
"boolea... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/rend.cpp | .cpp | 406 | 20 | #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::reverse_iterator it = array.rend();
// increment the iterator to point to the first element
--it;
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/to_ubjson.cpp | .cpp | 1,481 | 65 | #include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace nlohmann::literals;
// function to print UBJSON's diagnostic format
void print_byte(uint8_t byte)
{
if (32 < byte and byte < 128)
{
std::cout << (char)byte;
}
else
{
std... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/get_ref.cpp | .cpp | 573 | 28 | #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_integer_t&>();
// print the valu... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/parse__istream__parser_callback_t.cpp | .cpp | 1,355 | 58 | #include <iostream>
#include <iomanip>
#include <sstream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// a JSON text
auto text = R"(
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/basic_json__CompatibleType.cpp | .cpp | 6,452 | 219 | #include <iostream>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// ============
// object types
// ============
// create an object ... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/basic_json__size_type_basic_json.cpp | .cpp | 420 | 19 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create an array by creating copies of a JSON value
json value = "Hello";
json array_0 = json(0, value);
json array_1 = json(1, value);
json array_5 = json(5, value);
// serialize the JSON arrays
... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/parse_error.cpp | .cpp | 457 | 21 | #include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
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() << '\... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/json_pointer__operator_string_t.cpp | .cpp | 339 | 20 | #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;
s += ptr1;
s += "\n";
s += ptr2;
std::cout <<... | C++ |
3D | OpenMS/OpenMS | src/openms/extern/nlohmann_json/docs/examples/is_primitive.cpp | .cpp | 991 | 31 | #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 = 12345678987654321u;
json j_object = {{"one", 1}, {"... | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.