我正在使用RestSharp來使用restful web服務。我正在使用內置的Json解串器來反序列化響應。 這是迴應。Json響應類映射Restharp反序列化
[{"id":"1","latitude":"18.0155848","longitude":"-77.4988293","rating":"1","streetid":"1","username":"joel","verified":"1"},{"id":"2","latitude":"18.0155892","longitude":"-77.498774","rating":"1","streetid":"2","username":"joel","verified":"0"},{"id":"3","latitude":"18.0227736","longitude":"-77.4980039","rating":"1","streetid":"3","username":"joel","verified":"0"}]
這些是它被映射到的模型。
List<Pothole> list = new List<Pothole>();
public class Pothole
{
//getters and setters for the attributes of Pothole Model
public long Id { get; set;}
public double Latitude { get; set; }
public double Longitude { get; set; }
public double Rating{ get;set;}
public long StreetId { get; set; }
public string Username { get; set; }
public bool Verified { get; set; }
}
然而,當我使數據是不是被deserialized.I想知道是否有與JSON響應到類映射問題的呼籲。由於返回的坑洞物體數組,我將映射到一個坑洞列表。我檢查HTTP狀態代碼和響應的內容,以便數據被返回,其正好是反序列化導致的問題。
我猜你有一個JSON和你正在映射的類之間的情況的差異問題... – 2013-03-06 02:36:58
@SteveWellens更新 – 2013-03-06 02:39:10
@PaulSasik是的,這就是我有一個問題。 – 2013-03-06 02:39:50