Skip to content

"JsonPatchTestOperationException: The value '1000' is invalid for target location." for nullable valuetype-props #32

@Rgaroth

Description

@Rgaroth

Consider the following minimalistic test:

[Fact]
public void Test()
{
    Class1 obj = new();
    var sourcePatch = new JsonPatchDocument<Class1>().Replace(c => c.Id, 1000);
    var deserealizedPatch = JsonSerializer.Deserialize<JsonPatchDocument<Class1>>(JsonSerializer.Serialize(sourcePatch));

    sourcePatch.ApplyTo(obj); // success
    deserealizedPatch.ApplyTo(obj); // JsonPatchTestOperationException: The value '1000' is invalid for target location.
}

public class Class1
{
    public int? Id { get; set; }
}

When I try to patch a NULLABLE property by deserialized JsonPatchDocument, I get an error JsonPatchTestOperationException: The value '1000' is invalid for target location

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions