0

I have a class where the properties have decorators when I serialize a json string I am expecting to bind the data with the Column decorator case. but its not taking in such a way.

public class SaveDtails
{
    [Column("DetailId")]
    public Guid? detailUid { get; set; }
}

When serialize with the below code

string jSONString = JsonConvert.SerializeObject(dtpod);

I am expecting the Json as

{"DetailId" :"value"} 

instead of

{"detailUid" :"value"}
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Alai
  • 1
  • 3
  • That is called an `Attribute` and it is part of the class not the data. If you deserialize intoi a class which also has that `Attribute` all should be well. Serializating doesnt act on meta data – Ňɏssa Pøngjǣrdenlarp May 26 '19 at 13:56
  • You mean `[JsonProperty("DetailId")]`. Unless the class is marked as `[Serializable]`. In this case, you should implement `ISerializable` and return the property name in the `GetObjectData` method. – Jimi May 26 '19 at 14:16

0 Answers0