json作为SSIS中的数据源

时间:2016-11-14 11:48:33

标签: c# json ssis

我正在尝试从openweathermap.org api反序列化json提要。经过大量的尝试,使用脚本转换任务,我得到的是错误,甚至是不同的错误。基于JSON生成的以下类,我应该如何为每个语句编写(因为类Weather和Main是类RootObject的一部分)? 我甚至可以从api获取XML数据,而不是JSON。实施这个过程会更容易吗? 我不是要求答案,只是一个开始的推动。

JSON

{  
   "coord":{  
      "lon":-122.08,
      "lat":37.39
   },
   "weather":[  
      {  
         "id":741,
         "main":"Fog",
         "description":"fog",
         "icon":"50n"
      }
   ],
   "base":"stations",
   "main":{  
      "temp":286.14,
      "pressure":1022,
      "humidity":82,
      "temp_min":285.15,
      "temp_max":287.15
   },
   "visibility":16093,
   "wind":{  
      "speed":1.11,
      "deg":13.5055
   },
   "clouds":{  
      "all":1
   },
   "dt":1479110160,
   "sys":{  
      "type":1,
      "id":397,
      "message":0.1452,
      "country":"US",
      "sunrise":1479134859,
      "sunset":1479171466
   },
   "id":5375480,
   "name":"Mountain View",
   "cod":200
}

public class Coord
{
    public double lon { get; set; }
    public double lat { get; set; }
}

public class Weather
{
    public int id { get; set; }
    public string main { get; set; }
    public string description { get; set; }
    public string icon { get; set; }
}

public class Main
{
    public double temp { get; set; }
    public int pressure { get; set; }
    public int humidity { get; set; }
    public double temp_min { get; set; }
    public double temp_max { get; set; }
}

public class Wind
{
    public double speed { get; set; }
    public double deg { get; set; }
}

public class Clouds
{
    public int all { get; set; }
}

public class Sys
{
    public int type { get; set; }
    public int id { get; set; }
    public double message { get; set; }
    public string country { get; set; }
    public int sunrise { get; set; }
    public int sunset { get; set; }
}

public class RootObject
{
    public Coord coord { get; set; }
    public List<Weather> weather { get; set; }
    public string @base { get; set; }
    public Main main { get; set; }
    public int visibility { get; set; }
    public Wind wind { get; set; }
    public Clouds clouds { get; set; }
    public int dt { get; set; }
    public Sys sys { get; set; }
    public int id { get; set; }
    public string name { get; set; }
    public int cod { get; set; }
}

0 个答案:

没有答案