Skip to content

Commit 4c9b3ae

Browse files
Add missing macros and link for more info
Signed-off-by: Nikhil <[email protected]>
1 parent 117aa77 commit 4c9b3ae

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,19 @@ Some important things:
819819

820820
If you just want to serialize/deserialize some structs, the `to_json`/`from_json` functions can be a lot of boilerplate.
821821

822-
There are two macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object:
822+
There are six macros to make your life easier as long as you (1) want to use a JSON object as serialization and (2) want to use the member variable names as object keys in that object:
823823

824-
- `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the namespace of the class/struct to create code for.
825-
- `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the class/struct to create code for. This macro can also access private members.
824+
- [`NLOHMANN_DEFINE_TYPE_INTRUSIVE...`](https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/)
825+
1. `NLOHMANN_DEFINE_TYPE_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the class/struct to create code for. This macro can also access private members.
826+
2. `NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)` is to be defined inside the class/struct to create code for. This macro can also access private members. Falls back to the default value for the respective type of the member variable if a key in the JSON object is missing.
827+
3. `NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(name, member1, member2, ...)` is to be defined inside the class/struct to create code for. This macro can also access private members. Only defines the serialization.
826828

827-
In both macros, the first parameter is the name of the class/struct, and all remaining parameters name the members.
829+
- [`NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE...`](https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/)
830+
1. `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(name, member1, member2, ...)` is to be defined inside the namespace of the class/struct to create code for.
831+
2. `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(name, member1, member2, ...)` is to be defined inside the namespace of the class/struct to create code for. Falls back to the default value for the respective type of the member variable if a key in the JSON object is missing.
832+
3. `NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(name, member1, member2, ...)` is to be defined inside the namespace of the class/struct to create code for. Only defines the serialization.
833+
834+
In all macros, the first parameter is the name of the class/struct, and all remaining parameters name the members.
828835

829836
##### Examples
830837

0 commit comments

Comments
 (0)