📝 update documentation (#4723)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2025-04-05 18:54:35 +02:00
committed by GitHub
parent 11aa5f944d
commit 4424a0fcc1
90 changed files with 377 additions and 339 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ This macro controls which code is executed for [runtime assertions](../../featur
## Parameters
`x` (in)
: expression of scalar type
: expression of a scalar type
## Default definition
@@ -8,14 +8,14 @@ This macro enables position diagnostics for generated JSON objects.
When enabled, two new member functions [`start_pos()`](../basic_json/start_pos.md) and
[`end_pos()`](../basic_json/end_pos.md) are added to [`basic_json`](../basic_json/index.md) values. If the value was
created by calling the[`parse`](../basic_json/parse.md) function, then these functions allow to query the byte positions
created by calling the[`parse`](../basic_json/parse.md) function, then these functions allow querying the byte positions
of the value in the input it was parsed from. In case the value was constructed by other means, `std::string::npos` is
returned.
[`start_pos()`](../basic_json/start_pos.md) returns the position of the first character of a given value in the original
JSON string, while [`end_pos()`](../basic_json/end_pos.md) returns the position of the character _following_ the last
character. For objects and arrays, the first and last characters correspond to the opening or closing braces/brackets,
respectively. For primitive values, the first and last character represent the opening and closing quotes (strings) or
respectively. For primitive values, the first and last character represents the opening and closing quotes (strings) or
the first and last character of the field's numerical or predefined value (`true`, `false`, `null`), respectively.
| JSON type | return value [`start_pos()`](../basic_json/start_pos.md) | return value [`end_pos()`](../basic_json/end_pos.md) |
@@ -9,7 +9,7 @@ Possible values are `1` to enable or `0` to disable (default).
When enabled, exception messages contain a [JSON Pointer](../json_pointer/json_pointer.md) to the JSON value that
triggered the exception. Note that enabling this macro increases the size of every JSON value by one pointer and adds
some runtime overhead.
some runtime overhead.
## Default definition
@@ -91,4 +91,4 @@ When the macro is not defined, the library will define it to its default value.
## Version history
- Added in version 3.10.0.
- As of version 3.11.0 the definition is allowed to vary between translation units.
- As of version 3.11.0, the definition is allowed to vary between translation units.
@@ -4,8 +4,8 @@
#define JSON_SKIP_UNSUPPORTED_COMPILER_CHECK
```
When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows to
use the library with compilers that do not fully support C++11 and may only work if unsupported features are not used.
When defined, the library will not create a compile error when a known unsupported compiler is detected. This allows
using the library with compilers that do not fully support C++11 and may only work if unsupported features are not used.
## Default definition
@@ -21,13 +21,13 @@
These macros can be used to simplify the serialization/deserialization of derived types if you want to use a JSON
object as serialization and want to use the member variable names as object keys in that object.
- Macros 1, 2 and 3 are to be defined **inside** the class/struct to create code for.
- Macros 1, 2, and 3 are to be defined **inside** the class/struct to create code for.
Like [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](nlohmann_define_type_intrusive.md), they can access private members.
- Macros 4, 5 and 6 are to be defined **outside** the class/struct to create code for, but **inside** its namespace.
- Macros 4, 5, and 6 are to be defined **outside** the class/struct to create code for, but **inside** its namespace.
Like [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE`](nlohmann_define_type_non_intrusive.md),
they **cannot** access private members.
The first parameter is the name of the derived class/struct,
The first parameter is the name of the derived class/struct,
the second parameter is the name of the base class/struct and all remaining parameters name the members.
The base type **must** be already serializable/deserializable.
@@ -57,7 +57,7 @@ Summary:
: name of the base type (class, struct) `type` is derived from
`member` (in)
: name of the member variable to serialize/deserialize; up to 64 members can be given as comma-separated list
: name of the member variable to serialize/deserialize; up to 64 members can be given as a comma-separated list
## Default definition
@@ -79,7 +79,7 @@ template<typename BasicJsonType>
void from_json(const BasicJsonType&, type&);
```
Macros 3 and 6 add one function to the namespace which take care of the serialization only:
Macros 3 and 6 add one function to the namespace which takes care of the serialization only:
```cpp
template<typename BasicJsonType>
@@ -169,9 +169,9 @@ void to_json(BasicJsonType& j, const B& b) {
## Version history
1. Added in version 3.11.x.
2. Added in version 3.11.x.
3. Added in version 3.11.x.
4. Added in version 3.11.x.
5. Added in version 3.11.x.
6. Added in version 3.11.x.
1. Added in version 3.12.0.
2. Added in version 3.12.0.
3. Added in version 3.12.0.
4. Added in version 3.12.0.
5. Added in version 3.12.0.
6. Added in version 3.12.0.
@@ -17,7 +17,7 @@ parameter is the name of the class/struct, and all remaining parameters name the
2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the
respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function
default constructs an object and uses its values as the defaults when calling the `value` function.
3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization in required.
3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization is required.
Summary:
@@ -33,7 +33,7 @@ Summary:
: name of the type (class, struct) to serialize/deserialize
`member` (in)
: name of the member variable to serialize/deserialize; up to 64 members can be given as comma-separated list
: name of the member variable to serialize/deserialize; up to 64 members can be given as a comma-separated list
## Default definition
@@ -17,7 +17,7 @@ parameter is the name of the class/struct, and all remaining parameters name the
2. Will use [`value`](../basic_json/value.md) during deserialization and fall back to the default value for the
respective type of the member variable if a key in the JSON object is missing. The generated `from_json()` function
default constructs an object and uses its values as the defaults when calling the `value` function.
3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization in required.
3. Only defines the serialization. Useful in cases when the type does not have a default constructor and only serialization is required.
Summary:
@@ -33,7 +33,7 @@ Summary:
: name of the type (class, struct) to serialize/deserialize
`member` (in)
: name of the (public) member variable to serialize/deserialize; up to 64 members can be given as comma-separated list
: name of the (public) member variable to serialize/deserialize; up to 64 members can be given as a comma-separated list
## Default definition
@@ -5,7 +5,7 @@
```
By default, enum values are serialized to JSON as integers. In some cases this could result in undesired behavior. If an
enum is modified or re-ordered after data has been serialized to JSON, the later de-serialized JSON data may be
enum is modified or re-ordered after data has been serialized to JSON, the later deserialized JSON data may be
undefined or a different enum value than was originally intended.
The `NLOHMANN_JSON_SERIALIZE_ENUM` allows to define a user-defined serialization for every enumerator.