I have a class like so:
public class ResearchTerm
{
[JsonProperty("1")]
public string Term { get; set; }
[JsonProperty("2")]
public int Count { get; set; }
[JsonProperty("3")]
public long Score { get; set; }
}
A JSON array in a string:
[{"1":"ifn","2":7,"3":1.81818181818182},{"1":"macrophages","2":5,"3":1.2987012987013},{"1":"n =","2":5,"3":1.2987012987013},{"1":"p <","2":5,"3":1.2987012987013}]
And this line of code that converts the JSON array to an array of type ResearchTerm:
var researchTerms = Newtonsoft.Json.JsonConvert.DeserializeObject<ResearchTerm[]>(personTask.Result.ResearchKeywords);
This is working beautiful and return an array of ResearchTerms with the property names in my class. The problem is that when I serialize this for my API to return, it's converting it all back to property names 1, 2, and 3. How can I use JsonProperty to deserialize like it's currently doing, but not serialize? I don't really care about this data going back in, so I don't need to serialize it once it's retrieved from the database as this string and deserialized into my ResearchTerm class.