mardi 19 février 2019

Get JSON PropertyName from C# Class, like "nameof(class.prop)" for json properties?

How would I get the JSON PropertyName of the following class & Property? Something like a "nameof()" equivilent for JSON Properties?

ie, something like

var jsonName = GetJSONPropertyName(SampleClass.SampleClassID); //should return "jsoniD"

public class SampleClass
{
    public SampleClass() { }
    [JsonProperty(PropertyName = "jsoniD")]
    public string SampleClassID { get; set; }
}





Aucun commentaire:

Enregistrer un commentaire