Deseriaize Json from WebAPI using HttpClient

后端 未结 1 943
孤城傲影
孤城傲影 2021-01-21 22:20

I have the following Json format returned from a WebAPI. Can you guys help to deserialize please?.

{
  \"@odata.context\":\"http://....... \",\"value\":[
    **         


        
相关标签:
1条回答
  • 2021-01-21 22:52

    You can deserialize to concrete classes (with the help of http://json2csharp.com/)

    var result = JsonConvert.DeserializeObject<SOTest.Result>(json);
    

    public class SOTest
    {
        public class PropertyAddress
        {
            public string Address1 { get; set; }
            public object Address2 { get; set; }
            public string Zip { get; set; }
            public string City { get; set; }
            public string State { get; set; }
            public string County { get; set; }
        }
    
        public class Summary
        {
            public object BorrowerName { get; set; }
            public object ProductCode { get; set; }
            public string Status { get; set; }
        }
    
        public class Value
        {
            public string RecordNumber { get; set; }
            public string RecordType { get; set; }
            public PropertyAddress PropertyAddress { get; set; }
            public Summary Summary { get; set; }
        }
    
        public class Result
        {
            [JsonProperty("@odata.context")]
            public string Context { get; set; }
            public List<Value> Value { get; set; }
        }
    }
    
    0 讨论(0)
提交回复
热议问题