如何将json接受单个值作为数组?json接受单个值作为数组
此JSON抛出异常:
{ “代码”: “1”, “消息”: “OK”, “回应”:{ “合作伙伴”: { “ID “:”33“, ”name“:”“, ”clienttypeid“:”29“, ”logo“:”“, ”description“:”“, ”website“:”www.site.com “ } } }
此JSON解析正确的:
{ “代码”: “1”, “消息”: “OK”, “响应”:{ “伙伴”:[ { “ID”: “33”, “名”: “”, “clienttypeid”: “29”, “标志”: “”, “说明”: “”, “网站”:“WWW。 site.com“ }, { “ID”: “34”, “名”: “”, “clienttypeid”: “29”, “标志”: “”, “说明”: “”, “网站”:“WWW。 site.com” } ] }}
型号:
public class Partner
{
public string id { get; set; }
public string name { get; set; }
public string clienttypeid { get; set; }
public string logo { get; set; }
public string description { get; set; }
public string website { get; set; }
}
public class Response
{
public List<Partner> partners { get; set; }
}
public class RootObject
{
public string code { get; set; }
public string message { get; set; }
public Response response { get; set; }
}
服务器不返回数组符号[...]如果值是单 – 2013-04-24 13:04:21