Created nlohmann::basic_json::basic_json (markdown)
1 parent
625bee0f14
commit
2c38017708
1 file changed
+44
@@ -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<basic_json> 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::string, basic_json>`, `std::unordered_map<std::string, int>` | `{{"one", 1}, {"two", 2}}` |
|
||||
| array | any container whose `value_type` is convertible to `basic_json` with the rules described above (e.g., `std::vector<basic_json>`, `std::list<std::string>` | {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.
|
||||
Reference in new issue
Block a user