44#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT (type, conversion... )
55```
66
7- The ` NLOHMANN_JSON_SERIALIZE_ENUM_STRICT ` allows to define a user-defined serialization for every enumerator.
7+ The ` NLOHMANN_JSON_SERIALIZE_ENUM_STRICT ` macro allows defining a user-defined serialization for every enumerator.
88
99This macro declares strict serialization and deserialization functions (` to_json ` and ` from_json ` ) for an enum type.
1010Unlike [ ` NLOHMANN_JSON_SERIALIZE_ENUM ` ] ( nlohmann_json_serialize_enum.md ) , this macro enforces strict validation and
@@ -16,7 +16,7 @@ throws errors for unmapped values instead of defaulting to the first enum value.
1616: name of the enum to serialize/deserialize
1717
1818` conversion ` (in)
19- : a pair of an enumerator and a JSON serialization; arbitrary pairs can be given as a comma-separated list
19+ : A list of parameters alternating between an enumerator value and a string to use in the JSON serialization.
2020
2121## Default definition
2222
@@ -37,10 +37,9 @@ inline void from_json(const BasicJsonType& j, type& e);
3737
3838!!! important "Important notes"
3939
40- - If an enum value appears more than once in the mapping, only the first occurrence will be used for serialization,
41- subsequent mappings for the same enum value will be ignored.
42- - If a JSON value appears more than once in the mapping, only the first occurrence will be used for deserialization,
43- subsequent mappings for the same JSON value will be ignored.
40+ - Duplicate enum or JSON values in the mapping are not supported. Only the first occurrence will be used,
41+ and subsequent mappings will be ignored.
42+ This behavior is currently tolerated but may become an error in future versions.
4443 - Unlike `NLOHMANN_JSON_SERIALIZE_ENUM`, this macro enforces strict validation:
4544 - Attempting to serialize an unmapped enum value will throw a `type_error.302` exception
4645 - Attempting to deserialize an unmapped JSON value will throw a `type_error.302` exception
0 commit comments