Update documentation

This commit is contained in:
Florian Albrechtskirchinger 2022-07-23 19:14:38 +02:00
parent 7ce92a6375
commit df12a090e8
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D
4 changed files with 50 additions and 32 deletions

View File

@ -1,4 +1,4 @@
# operator>>(basic_json) # <small>nlohmann::</small>operator>>(basic_json)
```cpp ```cpp
std::istream& operator>>(std::istream& i, basic_json& j); std::istream& operator>>(std::istream& i, basic_json& j);
@ -33,6 +33,12 @@ Linear in the length of the input. The parser is a predictive LL(1) parser.
A UTF-8 byte order mark is silently ignored. A UTF-8 byte order mark is silently ignored.
!!! warning "Deprecation"
This function replaces function `#!cpp std::istream& operator<<(basic_json& j, std::istream& i)` which has
been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like `#!cpp j << i;`
with `#!cpp i >> j;`.
## Examples ## Examples
??? example ??? example
@ -56,10 +62,4 @@ A UTF-8 byte order mark is silently ignored.
## Version history ## Version history
- Added in version 1.0.0 - Added in version 1.0.0. Deprecated in version 3.0.0.
!!! warning "Deprecation"
This function replaces function `#!cpp std::istream& operator<<(basic_json& j, std::istream& i)` which has
been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like `#!cpp j << i;`
with `#!cpp i >> j;`.

View File

@ -1,42 +1,58 @@
# operator<<(basic_json) # <small>nlohmann::</small>operator<<(basic_json), <small>nlohmann::</small>operator<<(json_pointer)
```cpp ```cpp
std::ostream& operator<<(std::ostream& o, const basic_json& j); std::ostream& operator<<(std::ostream& o, const basic_json& j); // (1)
std::ostream& operator<<(std::ostream& o, const json_pointer& ptr); // (2)
``` ```
Serialize the given JSON value `j` to the output stream `o`. The JSON value will be serialized using the 1. Serialize the given JSON value `j` to the output stream `o`. The JSON value will be serialized using the
[`dump`](dump.md) member function. [`dump`](dump.md) member function.
- The indentation of the output can be controlled with the member variable `width` of the output stream `o`. For
- The indentation of the output can be controlled with the member variable `width` of the output stream `o`. For instance, using the manipulator `std::setw(4)` on `o` sets the indentation level to `4` and the serialization
instance, using the manipulator `std::setw(4)` on `o` sets the indentation level to `4` and the serialization result result is the same as calling `dump(4)`.
is the same as calling `dump(4)`. - The indentation character can be controlled with the member variable `fill` of the output stream `o`.
- The indentation character can be controlled with the member variable `fill` of the output stream `o`. For instance, For instance, the manipulator `std::setfill('\\t')` sets indentation to use a tab character rather than the
the manipulator `std::setfill('\\t')` sets indentation to use a tab character rather than the default space character. default space character.
2. Write a string representation of the given JSON pointer `ptr` to the output stream `o`. The string representation is
obtained using the [`to_string`](../json_pointer/to_string.md) member function.
## Parameters ## Parameters
`o` (in, out) `o` (in, out)
: stream to serialize to : stream to write to
`j` (in) `j` (in)
: JSON value to serialize : JSON value to serialize
`ptr` (in)
: JSON pointer to write
## Return value ## Return value
the stream `o` the stream `o`
## Exceptions ## Exceptions
Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON value 1. Throws [`type_error.316`](../../home/exceptions.md#jsonexceptiontype_error316) if a string stored inside the JSON
is not UTF-8 encoded. Note that unlike the [`dump`](dump.md) member functions, no `error_handler` can be set. value is not UTF-8 encoded. Note that unlike the [`dump`](dump.md) member functions, no `error_handler` can be set.
2. None.
## Complexity ## Complexity
Linear. Linear.
## Notes
!!! warning "Deprecation"
Function `#!cpp std::ostream& operator<<(std::ostream& o, const basic_json& j)` replaces function
`#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` which has been deprecated in version 3.0.0.
It will be removed in version 4.0.0. Please replace calls like `#!cpp j >> o;` with `#!cpp o << j;`.
## Examples ## Examples
??? example ??? example "Example: (1) serialize JSON value to stream"
The example below shows the serialization with different parameters to `width` to adjust the indentation level. The example below shows the serialization with different parameters to `width` to adjust the indentation level.
@ -52,11 +68,6 @@ Linear.
## Version history ## Version history
- Added in version 1.0.0 1. Added in version 1.0.0. Added support for indentation character and deprecated
- Support for indentation character added in version 3.0.0. `#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` in version 3.0.0.
3. Added in version 3.11.0.
!!! warning "Deprecation"
This function replaces function `#!cpp std::ostream& operator>>(const basic_json& j, std::ostream& o)` which has
been deprecated in version 3.0.0. It will be removed in version 4.0.0. Please replace calls like `#!cpp j >> o;`
with `#!cpp o << j;`.

View File

@ -19,6 +19,13 @@ operator string_t() const
} }
``` ```
## Notes
!!! warning "Deprecation"
This function is deprecated in favor of [`to_string`](to_string.md) and will be removed in a future major version
release.
## Examples ## Examples
??? example ??? example
@ -38,4 +45,4 @@ operator string_t() const
## Version history ## Version history
- Since version 2.0.0. - Since version 2.0.0.
- Changed type to `string_t` in version 3.11.0. - Changed type to `string_t` and deprecated in version 3.11.0.

View File

@ -212,7 +212,7 @@ nav:
- '(Constructor)': api/json_pointer/json_pointer.md - '(Constructor)': api/json_pointer/json_pointer.md
- 'back': api/json_pointer/back.md - 'back': api/json_pointer/back.md
- 'empty': api/json_pointer/empty.md - 'empty': api/json_pointer/empty.md
- 'operator std::string': api/json_pointer/operator_string.md - 'operator string_t': api/json_pointer/operator_string.md
- 'operator/': api/json_pointer/operator_slash.md - 'operator/': api/json_pointer/operator_slash.md
- 'operator/=': api/json_pointer/operator_slasheq.md - 'operator/=': api/json_pointer/operator_slasheq.md
- 'parent_pointer': api/json_pointer/parent_pointer.md - 'parent_pointer': api/json_pointer/parent_pointer.md