1

i'm trying to serialize a class which has multiple properties with DataMember attribute. Like this:

[DataMember(Name = "F")]
public string FontFamily { get; set; }

If i serialize my object the name FontFamily was replaced by the name F:

JsonConvert.SerializeObject(obj)

results in

\"F\":\"Arial\"  

How can i force NewtonSoft Json to ignore the DataMember attribute and use the original name?

\"FontFamily\":\"Arial\"  

I have no source code access to change the DataMember attribute.

Saftpresse99
  • 849
  • 7
  • 16
  • 2
    Without access to the source class that you are serializing, you'd probably have to write a custom `JsonConverter`. – Matt Burland Jun 16 '20 at 12:09

0 Answers0