Here是结果的一个例子,(facebook public exmaple)
(/搜索Q =咖啡&安培;类型=地方&安培;中心= 37.76,-122.427&安培;距离= 1000)
我有这个型号:
[DataContract]
public class FBPlaces
{
[DataMember(Name = "data")]
public List<Place> Data { get; set; }
[DataMember(Name = "paging")]
public Paging Paging { get; set; }
}
[DataContract]
public class Paging
{
[DataMember(Name = "next")]
public string Next { get; set; }
}
[DataContract]
public class Place
{
[DataMember(Name = "location")]
public List<Location> Locations { get; set; }
[DataMember(Name = "category")]
public string Category { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "id")]
public string ID { get; set; }
}
[DataContract]
public class Location
{
[DataMember(Name = "street")]
public string Street { get; set; }
[DataMember(Name = "city")]
public string City { get; set; }
[DataMember(Name = "state")]
public string State { get; set; }
//[DataMember(IsRequired = false, Name = "country ")]
//public string Country { get; set; }
[DataMember(Name = "zip")]
public string Zip { get; set; }
[DataMember(Name = "latitude")]
public double Latitude { get; set; }
[DataMember(Name = "longitude")]
public double Longitude { get; set; }
}
问题是映射“location”数组,我得
System.ArgumentException:为调用方法'Void set_Item(Int32,MyProject.Models.Location)'提供的参数数量不正确
如果我删除地点,一切都很好,我得到了Catergory + Name + Id。 (但没有地点)
如何解决?
在我的实例(不同位置查询)中,“country”并不总是显示,我如何处理这类数据?我评论了乡村财产。
答案 0 :(得分:1)
位置不是一个阵列。
尝试
[DataContract]
public class Place
{
[DataMember(Name = "location")]
public Location Locations { get; set; }
[DataMember(Name = "category")]
public string Category { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "id")]
public string ID { get; set; }
}