如何json接受单个值作为数组?
这个 json 抛出异常:
{ "code": "1", "message": "OK", "response": { "partners": { "id": "33", "name": "", "clienttypeid": "29", “标志”:“”,“描述”:“”,“网站”:“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; }
}