Json Deserialization with same property name with different case

Kiran

I want to understand how Json.NET deserializes a JSON object to corresponding c# object when we have multiple property names with different cases(I know this is not a good practice, but just curious to know how JSON.NET deals with this).

I have a c# object defined as below:

public class TestModel
{
    public string Name { get; set; }
    public bool IsEmployee { get; set; }
}

And json object as

{ "Name": "TestName","Isemployee":true, "isemployee":false};

Then, if I use the JSON.NET de-serialize method to convert above json string to TestModel object, which one of those two properties will be assigned to IsEmployee variable? And why?

Thanks.

Anders Gustafsson

In deserialization, Json.NET attempts case insensitive matching of an attribute if exact matching fails, as discussed here. This is in contrast to the built-in .NET JSON serializers, see here.

If multiple matches are detected, the last match takes precedence.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Jackson mapping: Deserialization of JSON with different property names

From Dev

XML Deserialization with multiple elements with same name but different content

From Dev

JMSSerializerBundle: handle different name for same entity property

From Dev

Deserialize JSON which can have different objects under same property name

From Dev

Newtonsoft json deserialization - key as property

From Dev

Git remote two branches same name different case

From Dev

Linux python scripting check for directory that have the same name but different case

From Dev

NSBundle files with the same name but different Upper / Lower case at first letter

From Dev

two classes, same property name, different type -> gets overridden

From Dev

Json.NET case-sensitive deserialization

From Dev

Json.net deserialization null guid case

From Dev

JSON Deserialization - handle property that can be a array

From Dev

JSON Deserialization - handle property that can be a array

From Java

.NET NewtonSoft JSON deserialize map to a different property name

From Dev

How to serialize enums to different property name using json.net

From Dev

CompositeConfiguration - property with same name

From Dev

Deserialize property with a different name?

From Dev

Property with the same name as the subtype name

From Dev

Boon JSON - Change Field Name for Object Deserialization

From Dev

Newtonsoft.Json Custom Root Name for Deserialization

From Dev

Boon JSON - Change Field Name for Object Deserialization

From Dev

JsonProperty - Use different name for deserialization, but use original name for serialization?

From Dev

How to get json parent property instead of taken all of same property name in json4s

From Java

Json schema with anyOf field with same name and different types to POJO + Jackson

From Dev

Concat Same Name different Value JSON object into unique one

From Dev

Property name in Bindings case insensitive?

From Dev

different apps with the same name?

From Dev

Same variable, different name

From Dev

JsonSerializerSettings to change case of property name but not name of property's property

Related Related

  1. 1

    Jackson mapping: Deserialization of JSON with different property names

  2. 2

    XML Deserialization with multiple elements with same name but different content

  3. 3

    JMSSerializerBundle: handle different name for same entity property

  4. 4

    Deserialize JSON which can have different objects under same property name

  5. 5

    Newtonsoft json deserialization - key as property

  6. 6

    Git remote two branches same name different case

  7. 7

    Linux python scripting check for directory that have the same name but different case

  8. 8

    NSBundle files with the same name but different Upper / Lower case at first letter

  9. 9

    two classes, same property name, different type -> gets overridden

  10. 10

    Json.NET case-sensitive deserialization

  11. 11

    Json.net deserialization null guid case

  12. 12

    JSON Deserialization - handle property that can be a array

  13. 13

    JSON Deserialization - handle property that can be a array

  14. 14

    .NET NewtonSoft JSON deserialize map to a different property name

  15. 15

    How to serialize enums to different property name using json.net

  16. 16

    CompositeConfiguration - property with same name

  17. 17

    Deserialize property with a different name?

  18. 18

    Property with the same name as the subtype name

  19. 19

    Boon JSON - Change Field Name for Object Deserialization

  20. 20

    Newtonsoft.Json Custom Root Name for Deserialization

  21. 21

    Boon JSON - Change Field Name for Object Deserialization

  22. 22

    JsonProperty - Use different name for deserialization, but use original name for serialization?

  23. 23

    How to get json parent property instead of taken all of same property name in json4s

  24. 24

    Json schema with anyOf field with same name and different types to POJO + Jackson

  25. 25

    Concat Same Name different Value JSON object into unique one

  26. 26

    Property name in Bindings case insensitive?

  27. 27

    different apps with the same name?

  28. 28

    Same variable, different name

  29. 29

    JsonSerializerSettings to change case of property name but not name of property's property

HotTag

Archive