I am fetching an API that returns a JSON response like this:
{
"id": 161635,
"rev": 1,
"fields": {
"System.Url": "http://google.com",
"System.Type": "Bug",
"System.State": "New",
"System.AssignedTo": {
"displayName": "John Doe"
}
}
}
I want to display the id and everything inside fields.
This is my model:
public class WorkItemDetail {
public int id { get; set; }
public Dictionary<string, object> fields {get;set;}
}
Here is the problem, I can display the id and everything in fields except for some reason, I can't show displayName
Here is what I doing:
@WorkItemDetailResponse.id
@WorkItemDetailResponse.fields["System.WorkItemType"];
@WorkItemDetailResponse.fields["System.State"];
@WorkItemDetailResponse.fields["System.AssignedTo"];
@WorkItemDetailResponse.fields["System.AssignedTo"]["displayName"]; <!-- does not work -->
@code{
WorkItemDetailResponse = JsonConvert.DeserializeObject<WorkItemDetail>(ResponseBody);
}
I am new to C# so I don't know why this line is not working
@WorkItemDetailResponse.fields["System.AssignedTo"]["displayName"]