Skip to content

.NET Core new JSON DeSerializer dont work with extra properties #475

Closed

Description

@radenkozec

In JSON.NET when we sent object with extra properties from JavaScript app in body of requests deserializer just ignored extra properties.
New deserializer don't work and deserialize null if model does not match 100% which is wrong.
We use ES6/ES7 and we don't need to have all models match 100% like in TypeScript.

Any workaround?

Activity

  1. added
    untriaged
    on Dec 3, 2019
  2. radenkozec commented on Dec 3, 2019

    @radenkozec
    Author

    My error in code delete this.

  3. ahsonkhan commented on Dec 9, 2019

    @ahsonkhan
    Contributor

    My error in code delete this.

    @radenkozec - out of curiosity, what was the error you fixed? I want to understand it, particularly for the benefit of others who might hit the same issue you did.

    deserializer just ignored extra properties.

    If you have extra properties in the payload and need to roundtrip them, you could use the JsonExtensionData attribute to annotate an "overflow" dictionary.

    New deserializer don't work and deserialize null if model does not match 100% which is wrong.

    Was there a naming policy or casing mismatch issue?

  4. added this to the 5.0 milestone on Dec 9, 2019
  5. removed
    untriaged
    on Dec 9, 2019
  6. radenkozec commented on Dec 16, 2019

    @radenkozec
    Author

    This was not extra properties problem.
    I was sending "5" in JSON instead of 5 for integer property. JSON.NET probably fixed these conversion issues however I fixed my errors in code. I don't prefer these kind of "auto-fixing" because it will affect performance. So on your side you don't need to do anything

  7. ghost locked as resolved and limited conversation to collaborators on Dec 11, 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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions