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 following "flattened" class, using the JsonPropertyAttribute
:
public class JiraIssue
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("fields/issuetype/name")]
public string Type { get; set; }
}
I'm trying to specify a "navigation" rule based on /
as a separator in the name of the JSON property.
Basically, I want to specify that JsonProperty("fields/issuetype/name")
should be used as a navigation rule to the nested property fields.issuetype.name
, which obviously does not work:
var d = Newtonsoft.Json.JsonConvert.DeserializeObject<JiraIssue>(s);
Console.WriteLine("Id:" + d.Id);
Console.WriteLine("Type" + d.Type);
The above recognizes only the Id:
Id: 10
Type:
What do I have to implement to tell Json.NET to use the "/" as a navigation path to the desired nested property?