0

我从 api.openkvk.nl 解码 json 输出时遇到问题。我只想将 ROWS 转换为对象,将 json 行转换为列表的最佳方法是什么?

一个json示例是:

[{"RESULT":{"TYPES":["bigint","varchar","int","int","varchar","varchar","varchar","varchar","varchar","varchar ","bigint","varchar","double","double","date"],"HEADER":["kvk","bedrijfsnaam","kvks","sub","adres","邮政编码","plaats","type","status","website","vestiging","re​​chtsvorm","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","无罪",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<> 但我无法让它工作..

4

1 回答 1

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; }
}
于 2013-05-21T13:17:57.813 回答