Skip to content

Commit 768eb66

Browse files
committed
added documentation and changed readme to include NLOHMANN_JSON_SERIALIZE_ENUM_STRICT
Signed-off-by: Caillin Nugent <caillinn@student.unimelb.edu.au>
1 parent ff66dad commit 768eb66

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ Just as in [Arbitrary Type Conversions](#arbitrary-types-conversions) above,
10741074

10751075
Other Important points:
10761076

1077-
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully.
1077+
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. If you desire an exception in this circumstance use `NLOHMANN_JSON_SERIALIZE_ENUM_STRICT()` which behaves identically except for throwing an exception on unrecognized values.
10781078
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON.
10791079

10801080
### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)

docs/mkdocs/docs/features/enum_conversion.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Just as in [Arbitrary Type Conversions](arbitrary_types.md) above,
5555
Other Important points:
5656

5757
- When using `get<ENUM_TYPE>()`, undefined JSON values will default to the first pair specified in your map. Select this
58-
default pair carefully.
58+
default pair carefully. If you desire an exception in this circumstance use `NLOHMANN_JSON_SERIALIZE_ENUM_STRICT()`
59+
which behaves identically except for throwing an exception on unrecognised values.
5960
- If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the
6061
map will be returned when converting to or from JSON.
6162
- To disable the default serialization of enumerators as integers and force a compiler error instead, see [`JSON_DISABLE_ENUM_SERIALIZATION`](../api/macros/json_disable_enum_serialization.md).

0 commit comments

Comments
 (0)