📝 update documentation
This commit is contained in:
parent
0cd120f7e1
commit
59cb7674be
2 changed files with 24 additions and 0 deletions
|
@ -92,6 +92,10 @@ There are two macros to make your life easier as long as you (1) want to use a J
|
|||
|
||||
In both macros, the first parameter is the name of the class/struct, and all remaining parameters name the members.
|
||||
|
||||
!!! note
|
||||
|
||||
At most 64 member variables can be passed to `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE` or `NLOHMANN_DEFINE_TYPE_INTRUSIVE`.
|
||||
|
||||
??? example
|
||||
|
||||
The `to_json`/`from_json` functions for the `person` struct above can be created with:
|
||||
|
|
|
@ -32,6 +32,26 @@ This macro overrides `#!cpp try` calls inside the library. It has no arguments a
|
|||
|
||||
See [Switch off exceptions](../home/exceptions.md#switch-off-exceptions) for an example.
|
||||
|
||||
## `JSON_USE_IMPLICIT_CONVERSIONS`
|
||||
|
||||
When defined to `0`, implicit conversions are switched off. By default, implicit conversions are switched on.
|
||||
|
||||
??? example
|
||||
|
||||
This is an example for an implicit conversion:
|
||||
|
||||
```cpp
|
||||
json j = "Hello, world!";
|
||||
std::string s = j;
|
||||
```
|
||||
|
||||
When `JSON_USE_IMPLICIT_CONVERSIONS` is defined to `0`, the code above does no longer compile. Instead, it must be written like this:
|
||||
|
||||
```cpp
|
||||
json j = "Hello, world!";
|
||||
auto s = j.get<std::string>();
|
||||
```
|
||||
|
||||
## `NLOHMANN_DEFINE_TYPE_INTRUSIVE(type, member...)`
|
||||
|
||||
This macro can be used to simplify the serialization/deserialization of types if (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object.
|
||||
|
|
Loading…
Reference in a new issue