To serialize an object to json using json.net, I need to create POCOs with attributes labled for each json property:
public class Priority
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("iconUrl")]
public string IconUrl { get; set; }
}
I'm using this to interact with Jira's REST API, and it works well for all the standard fields. Unfortunately, custom fields are where things trip up. Custom fields don't have determined field names, and instead have numbers assigned to them. So if I have a "Resolution Type" custom field, the property won't be called "ResolutionType", but rather "customfield_10200".
I'm dealing with multiple deployments with the same custom fields, but they all have different field Ids. What I'd love to do is something like this:
[JsonProperty(ConfigurationManager.AppSettings["JiraResolutionTypeId"])]
public string ResolutionType{ get; set; }
But you can only have compile-time constants in attributes like that, so I can't dynamically set the id in that manner.
How can I get around this?