我在解码api.openkvk.nl的json输出时遇到了问题。我只想将ROWS转换为对象,什么是将json行转换为List的最佳方法?
json的例子是:
[{ “RESULT”:{ “类型”:[ “BIGINT”, “VARCHAR”, “INT”, “INT”, “VARCHAR”, “VARCHAR”, “VARCHAR”, “VARCHAR”, “VARCHAR” “VARCHAR”, “BIGINT”, “VARCHAR”, “双”, “双”, “日期”], “HEADER”:[ “KVK”, “bedrijfsnaam”, “kvks”, “子”, “ADRES” “邮政编码”, “国家地点”, “类型”, “状态”, “网站”, “vestiging”, “rechtsvorm”, “lat_rad”, “lon_rad”, “ANBI”],“的 ROWS “:[[”170401310000“,”Kuijpers Installaties Helmond BV“,”17040131“,null,”Panovenweg 18“,”5708HR“,”Helmond“,”Hoofdvestiging“,null,null,”16667549“,null,” 0.89838484100000005“,”0.098222471000000006“,null],[”170401310001“,”KUIJPERS INSTALLATIES BV“,”17040131“,null,”VELDZIGT 18“,”3454PW“,”DE MEERN“,”Nevenvestiging“,”Vestiging is uitgeschreven uit het handelsregister“,null,”0“,null,null,null,null],[”170401310002“,”Kuijpers Installaties Helmond BV“,”17040131“,null,”Heieinde 12“,”5047SX“,”Tilburg“, “Nevenvestiging”,NULL,NULL, “21790299”,NULL, “0.90039840900000001”, “0.087662925000000003”,NULL]]}}]
对象:
public class KvK
{
public Int64? kvk { get; set; }
public string bedrijfsnaam { get; set; }
public int? kvks { get; set; }
public int? sub { get; set; }
public string adres { get; set; }
public string postcode { get; set; }
public string plaats { get; set; }
public string type { get; set; }
public string status { get; set; }
public string website { get; set; }
public int? vestiging { get; set; }
public string rechtsvorm { get; set; }
public decimal? lat_rad { get; set; }
public decimal? lon_rad { get; set; }
public DateTime? anbi { get; set; }
}
这个想法是使用JavaScriptSerializer.deserialize<>但我无法让它发挥作用..
答案 0 :(得分:0)
var list = new JavaScriptSerializer().Deserialize<List<ROOT>>(json);
public class RESULT
{
public List<string> TYPES { get; set; }
public List<string> HEADER { get; set; }
public List<List<string>> ROWS { get; set; }
}
public class ROOT
{
public RESULT RESULT { get; set; }
}