mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
📝 add more API documentation
This commit is contained in:
@ -73,8 +73,9 @@ constexpr const PointerType get_ptr() const noexcept;
|
||||
|
||||
`PointerType`
|
||||
: pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md),
|
||||
[`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or [`number_unsigned`](number_unsigned.md),
|
||||
[`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). Other types will not compile.
|
||||
[`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
|
||||
[`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
Other types will not compile.
|
||||
|
||||
## Return value
|
||||
|
||||
|
@ -14,8 +14,9 @@ Implicit pointer access to the internally stored JSON value. No copies are made.
|
||||
|
||||
`PointerType`
|
||||
: pointer type; must be a pointer to [`array_t`](array_t.md), [`object_t`](object_t.md), [`string_t`](string_t.md),
|
||||
[`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or [`number_unsigned`](number_unsigned.md),
|
||||
[`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md). Other types will not compile.
|
||||
[`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
|
||||
[`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
Other types will not compile.
|
||||
|
||||
## Return value
|
||||
|
||||
|
@ -15,7 +15,7 @@ Implicit reference access to the internally stored JSON value. No copies are mad
|
||||
`ReferenceType`
|
||||
: reference type; must be a reference to [`array_t`](array_t.md), [`object_t`](object_t.md),
|
||||
[`string_t`](string_t.md), [`boolean_t`](boolean_t.md), [`number_integer_t`](number_integer_t.md), or
|
||||
[`number_unsigned`](number_unsigned.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
[`number_unsigned_t`](number_unsigned_t.md), [`number_float_t`](number_float_t.md), or [`binary_t`](binary_t.md).
|
||||
Enforced by static assertion.
|
||||
|
||||
## Return value
|
||||
|
58
doc/mkdocs/docs/api/basic_json/get_to.md
Normal file
58
doc/mkdocs/docs/api/basic_json/get_to.md
Normal file
@ -0,0 +1,58 @@
|
||||
# basic_json::get_to
|
||||
|
||||
```cpp
|
||||
template<typename ValueType>
|
||||
ValueType& get_to(ValueType& v) const noexcept(
|
||||
noexcept(JSONSerializer<ValueType>::from_json(
|
||||
std::declval<const basic_json_t&>(), v)))
|
||||
```
|
||||
|
||||
Explicit type conversion between the JSON value and a compatible value. The value is filled into the input parameter by
|
||||
calling the `json_serializer<ValueType>` `from_json()` method.
|
||||
|
||||
The function is equivalent to executing
|
||||
```cpp
|
||||
ValueType v;
|
||||
JSONSerializer<ValueType>::from_json(*this, v);
|
||||
```
|
||||
|
||||
This overloads is chosen if:
|
||||
|
||||
- `ValueType` is not `basic_json`,
|
||||
- `json_serializer<ValueType>` has a `from_json()` method of the form `void from_json(const basic_json&, ValueType&)`
|
||||
|
||||
## Template parameters
|
||||
|
||||
`ValueType`
|
||||
: the value type to return
|
||||
|
||||
## Return value
|
||||
|
||||
the input parameter, allowing chaining calls
|
||||
|
||||
## Exceptions
|
||||
|
||||
Depends on what `json_serializer<ValueType>` `from_json()` method throws
|
||||
|
||||
## Example
|
||||
|
||||
??? example
|
||||
|
||||
The example below shows several conversions from JSON values to other types. There a few things to note: (1)
|
||||
Floating-point numbers can be converted to integers, (2) A JSON array can be converted to a standard
|
||||
`#!cpp std::vector<short>`, (3) A JSON object can be converted to C++ associative containers such as
|
||||
`#cpp std::unordered_map<std::string, json>`.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/get_to.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/get_to.output"
|
||||
```
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.3.0.
|
@ -33,14 +33,14 @@ class basic_json;
|
||||
| -------------------- | ----------- | ------------ |
|
||||
| `ObjectType` | type for JSON objects | [`object_t`](object_t.md) |
|
||||
| `ArrayType` | type for JSON arrays | [`array_t`](array_t.md) |
|
||||
| `StringType` | type for JSON strings and object keys | `string_t` |
|
||||
| `BooleanType` | type for JSON booleans | `boolean_t` |
|
||||
| `StringType` | type for JSON strings and object keys | [`string_t`](string_t.md) |
|
||||
| `BooleanType` | type for JSON booleans | [`boolean_t`](boolean_t.md) |
|
||||
| `NumberIntegerType` | type for JSON integer numbers | [`number_integer_t`](number_integer_t.md) |
|
||||
| `NumberUnsignedType` | type for JSON unsigned integer numbers | [`number_unsigned_t`](number_unsigned_t.md) |
|
||||
| `NumberFloatType` | type for JSON floating-point numbers | [`number_float_t`](number_float_t.md) |
|
||||
| `AllocatorType` | type of the allocator to use | |
|
||||
| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | |
|
||||
| `BinaryType` | type for binary arrays | `binary_t` |
|
||||
| `JSONSerializer` | the serializer to resolve internal calls to `to_json()` and `from_json()` | [`json_serializer`](json_serializer.md) |
|
||||
| `BinaryType` | type for binary arrays | [`binary_t`](binary_t.md) |
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
@ -48,9 +48,10 @@ Todo
|
||||
|
||||
## Member types
|
||||
|
||||
- [**adl_serializer**](../adl_serializer.md) - the default serializer
|
||||
- [**value_t**](value_t.md) - the JSON type enumeration
|
||||
- [**json_pointer**](../json_pointer.md) - JSON Pointer implementation
|
||||
- json_serializer
|
||||
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON
|
||||
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
|
||||
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
|
||||
- initializer_list_t
|
||||
@ -136,7 +137,7 @@ Functions to inspect the type of a JSON value.
|
||||
Direct access to the stored value of a JSON value.
|
||||
|
||||
- [**get**](get.md) - get a value
|
||||
- get_to - get a value
|
||||
- [**get_to**](get_to.md) - get a value and write it to a destination
|
||||
- [**get_ptr**](get_ptr.md) - get a pointer value
|
||||
- [**get_ref**](get_ref.md) - get a reference value
|
||||
- [**operator ValueType**](operator_ValueType.md) - get a value
|
||||
|
24
doc/mkdocs/docs/api/basic_json/json_serializer.md
Normal file
24
doc/mkdocs/docs/api/basic_json/json_serializer.md
Normal file
@ -0,0 +1,24 @@
|
||||
# basic_json::json_serializer
|
||||
|
||||
```cpp
|
||||
template<typename T, typename SFINAE>
|
||||
using json_serializer = JSONSerializer<T, SFINAE>;
|
||||
```
|
||||
|
||||
## Template parameters
|
||||
|
||||
`T`
|
||||
: type to convert; will be used in the `to_json`/`from_json` functions
|
||||
|
||||
`SFINAE`
|
||||
: type to add compile type checks via SFINAE; usually `#!cpp void`
|
||||
|
||||
## Notes
|
||||
|
||||
#### Default type
|
||||
|
||||
The default values for `json_serializer` is [`adl_serializer`](../adl_serializer.md).
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.0.
|
Reference in New Issue
Block a user