Skip to content

Consider tracking JSON path while deserializing JsonElement to return better JsonException #32359

@ahsonkhan

Description

@ahsonkhan

We should only do this if it doesn't regress JsonElement performance noticably.

[Fact]
[ActiveIssue("JsonElement needs to support Path")]
public static void ExtensionPropertyRoundTripFails()
{
try
{
JsonSerializer.Deserialize<ClassWithExtensionProperty>(@"{""MyNestedClass"":{""UnknownProperty"":bad}}");
Assert.True(false, "Expected JsonException was not thrown.");
}
catch (JsonException e)
{
// Until JsonElement supports populating Path ("UnknownProperty"), which will be prepended by the serializer ("MyNestedClass"), this will fail.
Assert.Equal("$.MyNestedClass.UnknownProperty", e.Path);
}
}

cc @steveharter

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions