且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Json Response反序列化为对象

更新时间:2023-01-16 20:20:18

尝试反序列化为以下内容:

Try deserializing into the following:
public class alist
{
   public Place[] places;
}
...
var obj = JsonConvert.DeserializeObject<alist>(json);
...
</alist>


大家好,



我已经解决了通过修改我的课程来解决问题如下:



Hi All,

I have solved the aboce issue by modifying my class as given below:

public class places
    {
        [JsonProperty("addressType")]
        public string AddressType { get; set; }
        [JsonProperty("city")]
        public string City { get; set; }
        [JsonProperty("country")]
        public string Country { get; set; }
        [JsonProperty("featureType")]
        public string FeatureType { get; set; }
        [JsonProperty("position")]
        public Position Positions { get; set; }
        [JsonProperty("state")]
        public string State { get; set; }
        [JsonProperty("street")]
        public string Street { get; set; }
        [JsonProperty("zip")]
        public string Zip { get; set; }
    }

    public class Position
    {
        public string lat { get; set; }
        public string lon { get; set; }
    }

    public class status
    {
        public int duration { get; set; }
        public string procedure { get; set; }
        public bool success { get; set; }
    }

    public class obJson
    {
        public places[] places { get; set; }
        [JsonProperty("status")]
        public status Status { get; set; }
    }









obJson obj = JsonConvert .DeserializeObject< objson>(json);



谢谢



Umesh Tayade




and
obJson obj = JsonConvert.DeserializeObject<objson>(json);

Thanks

Umesh Tayade