Skip to content

Converting JSON data to a struct with optional fields #4632

Answered by nlohmann
jozefizso asked this question in Q&A
Discussion options

You must be logged in to vote

It is a difference between (1) the field is null and (2) the field is not provided in the JSON object at all. You probably want to try NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jozefizso
Comment options

Answer selected by jozefizso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants