Given the following nested JSON string:
string s = @"
{
""id"": 10,
""fields"":{
""issuetype"": {
""name"": ""Name of the jira item""
}
}
}";
How can I deserialize it to the next flattened class using JsonPropertyAttribute:
public class JiraIssue
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("fields/issuetype/name")]
public string Type { get; set; }
}
I am trying to specify a "Navigation" rule based on /as a JSON name separator.
Basically, I want to indicate what JsonProperty("fields/issuetype/name")should be used as a navigation rule for a nested property fields.issuetype.name, which obviously doesn't work:
var d = Newtonsoft.Json.JsonConvert.DeserializeObject<JiraIssue>(s);
Console.WriteLine("Id:" + d.Id);
Console.WriteLine("Type" + d.Type);
The above only recognizes Id:
Id: 10
Type:
What do I need to implement in order to tell Json.NET to use "/" as the navigation path to the desired attached property?