Skip to content

fix JsonNode deserialising from null#85463

Merged
eiriktsarpalis merged 2 commits into
dotnet:mainfrom
adj123:fix-jsonnode-null-deserialisations
May 10, 2023
Merged

fix JsonNode deserialising from null#85463
eiriktsarpalis merged 2 commits into
dotnet:mainfrom
adj123:fix-jsonnode-null-deserialisations

Conversation

@adj123

@adj123 adj123 commented Apr 27, 2023

Copy link
Copy Markdown
Contributor

Fixes #85172

@ghost ghost added area-System.Text.Json community-contribution Indicates that the PR has been added by a community member labels Apr 27, 2023
@ghost

ghost commented Apr 27, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #85172

Author: adj123
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

Assert.IsAssignableFrom<JsonValue>(JsonNode.Parse(ToUtf8("\"str\"")));
Assert.IsType<JsonElement>(JsonSerializer.Deserialize<object>("\"str\""));

Assert.Null(JsonSerializer.Deserialize<JsonNode>("null"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to

  1. Also test deserializing an object containing a JsonNode property?
  2. Add tests validating the same behavior for JsonObject and JsonArray?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing!

@eiriktsarpalis eiriktsarpalis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eiriktsarpalis

Copy link
Copy Markdown
Member

@adj123 would you mind responding to the CLA bot as well?

#85463 (comment)

Thanks!

@adj123

adj123 commented May 9, 2023

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree company="DRW Holdings"

@eiriktsarpalis eiriktsarpalis merged commit c77d916 into dotnet:main May 10, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.Json community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deserialising null to JsonNode in nested structures fails in System.Text.Json

3 participants