Skip to content

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

Closed

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

Activity

  1. added this to the Future milestone on Feb 15, 2020
  2. added
    untriaged
    on Feb 15, 2020
  3. removed
    untriaged
    on Feb 15, 2020
  4. layomia commented on Feb 21, 2020

    @layomia
    Contributor

    Closing as duplicate of #29715.

  5. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions