0

Using Newtsonsoft JSON, is it possible to use either the JsonProperty or the C# Property name when deserializing? Basically, is there an option I am missing that allows both of the example JSON files below to be deserialized?

C# Class

public class MyClass 
{
    [JsonProperty("CustomerName")]
    public string ExternalId { get; set; }
}

First JSON File

{
    "ExternalId":"Test1"
}

Second JSON File

{
   "CustomerName":"Test2"
}
Jason H
  • 4,996
  • 6
  • 27
  • 49

0 Answers0