Skip to content

Commit

Permalink
Add explanation for jsonElementNullValueKindCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
timward60 committed Aug 29, 2023
1 parent 6294edf commit 785360a
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ private void AddDeserializeMethod(
.AddCode(jsonElementNullCheck)
.AddEmptyLine();

// When deserializing arrays of nullable values (e.g. [User] => [ { ... }, null, { ... }]) the second
// element will be not null, but instead a JSON element of kind JsonValueKind.Null.
var jsonElementNullValueKindCheck = IfBuilder
.New()
.SetCondition($"{_obj}.Value.ValueKind == System.Text.Json.JsonValueKind.Null")
Expand Down

0 comments on commit 785360a

Please sign in to comment.