From 59cb7674be9d4ae4bbb2b41906e64f3acb9c245e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 23 Jul 2020 14:15:20 +0200 Subject: [PATCH] :memo: update documentation --- doc/mkdocs/docs/features/arbitrary_types.md | 4 ++++ doc/mkdocs/docs/features/macros.md | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/doc/mkdocs/docs/features/arbitrary_types.md b/doc/mkdocs/docs/features/arbitrary_types.md index 7bd7adf7..23913bba 100644 --- a/doc/mkdocs/docs/features/arbitrary_types.md +++ b/doc/mkdocs/docs/features/arbitrary_types.md @@ -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: diff --git a/doc/mkdocs/docs/features/macros.md b/doc/mkdocs/docs/features/macros.md index 7147be7e..48a5159b 100644 --- a/doc/mkdocs/docs/features/macros.md +++ b/doc/mkdocs/docs/features/macros.md @@ -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(); + ``` + ## `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.