[Fork] <no name>

CSharp · Console

/Program.cs

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;


// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
    public class Fields
    {
        [JsonProperty("System.Url")]
        public string SystemUrl { get; set; }

        [JsonProperty("System.Type")]
        public string SystemType { get; set; }

        [JsonProperty("System.State")]
        public string SystemState { get; set; }

        [JsonProperty("System.AssignedTo")]
        public SystemAssignedTo SystemAssignedTo { get; set; }
    }

    public class WorkItemDetail
    {
        public int id { get; set; }
        public int rev { get; set; }
        public Fields fields { get; set; }
    }

    public class SystemAssignedTo
    {
        public string displayName { get; set; }
    }



public class Program
{
	public static void Main()
	{
		string ResponseBody =@"{
""id"": 161635,
""rev"": 1,
""fields"": {
  ""System.Url"": ""http://google.com"",
  ""System.Type"": ""Bug"",
  ""System.State"": ""New"",
  ""System.AssignedTo"": {
    ""displayName"": ""John Doe""
    }
  }
}";
		var WorkItemDetailResponse = JsonConvert.DeserializeObject<WorkItemDetail>(ResponseBody);
		
		
		Console.WriteLine(WorkItemDetailResponse.fields.SystemAssignedTo.displayName);
	}
}
;