From 2c380177086b9c6ab8daca1de213a447990f8355 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 25 Apr 2015 01:18:44 +0200 Subject: [PATCH] Created nlohmann::basic_json::basic_json (markdown) --- nlohmann::basic_json::basic_json.md | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 nlohmann::basic_json::basic_json.md diff --git a/nlohmann::basic_json::basic_json.md b/nlohmann::basic_json::basic_json.md new file mode 100644 index 0000000..05be6fc --- /dev/null +++ b/nlohmann::basic_json::basic_json.md @@ -0,0 +1,44 @@ +```cpp +basic_json(); +basic_json(std::nullptr_t); // 1 +``` +```cpp +basic_json(const value_t t); // 2 +``` +```cpp +basic_json(const T& value); // 3 +``` +```cpp +basic_json(std::initializer_list init); // 4 +``` + +## Description + +1. Creates a null object. +2. Creates a default-initialized container of a specified type. +3. Creates a value-initialized container of an implicitly specified type. +4. Creates an array or object type from an initializer list. + +In case of item 3 and 4, the following types are valid: + +| Value type | Type `T` | Literal | +| ---------- | --------------------- | ---- | +| null | `std::nullptr_t` | `nullptr` | +| boolean | any value convertible to `BooleanType` (e.g., `bool`) | `true`, `false` | +| string | any value convertible to `StringType` (e.g., `std::string`, `const char *`) | `"hello"` | +| number | any value convertible to `NumberIntegerType` (e.g., `int`, `unsigned int`, `long`, `int64_t`) | `10`, `-23e-23`, `3.1415926` | +| object | any associative container whose `key_type` is convertible to `StringType` and whose `value_type` is convertible to `basic_json` with the rules described above (e.g., `std::map`, `std::unordered_map` | `{{"one", 1}, {"two", 2}}` | +| array | any container whose `value_type` is convertible to `basic_json` with the rules described above (e.g., `std::vector`, `std::list` | {1, false, "hello"} | + +## Parameters + +- `t`: type name; can be `null`, `object`, `array`, `string`, `boolean`, `number_integer`, or `number_float`. +- `value`: can be any value whose type can be translated to a JSON container (see table above). +- `init`: an initializer list of (a) values that can be translated to a JSON container (see table above) to create an array; (b) pairs of a string type and a value that can be translate to a JSON container (see table above) to create an object. + +## Complexity + +1. Constant. +2. Constant. +3. Linear in the passed value. +4. Linear in the size of the initializer list.