json/docs/mkdocs/docs/api/operator_gtgt.md
Florian Albrechtskirchinger e3095f636f
Add operator<<(json_pointer) (#3601)
* Add operator<< for json_pointer

* Deprecate json_pointer::operator string_t()

* Update documentation

* Move operator<<(basic_json) example

* Add example

* Add mkdocs-redirects

* Move operator<< and operator>> doc pages out of basic_json/

* Rename JSON pointer operator_string to operator_string_t

* Add unit test
2022-07-28 22:12:23 +02:00

1.6 KiB

nlohmann::operator>>(basic_json)

std::istream& operator>>(std::istream& i, basic_json& j);

Deserializes an input stream to a JSON value.

Parameters

i (in, out)
input stream to read a serialized JSON value from
j (in, out)
JSON value to write the deserialized input to

Return value

the stream i

Exceptions

Complexity

Linear in the length of the input. The parser is a predictive LL(1) parser.

Notes

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

??? example

The example below shows how a JSON value is constructed by reading a serialization from a stream.
    
```cpp
--8<-- "examples/operator_deserialize.cpp"
```

Output:

```json
--8<-- "examples/operator_deserialize.output"
```

See also

  • accept - check if the input is valid JSON
  • parse - deserialize from a compatible input

Version history

  • Added in version 1.0.0. Deprecated in version 3.0.0.