Created
September 20, 2014 07:39
-
-
Save CH3COOH/4b2b3adac840eed9de78 to your computer and use it in GitHub Desktop.
東京メトロ オープンデータ API の遅延情報取得例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Hoge() | |
{ | |
var endPoint = "https://"; | |
var parm = new Dictionary<string, string>(); | |
parm["rdf:type"] = "odpt:TrainInformation"; | |
parm["acl:consumerKey"] = アクセスキー"; | |
var url = string.Format("{0}?{1}", endPoint, | |
string.Join("&", parm.Select(p => string.Format("{0}={1}", p.Key, p.Value)))); | |
var client = new WebClient(); | |
client.Encoding = Encoding.UTF8; | |
var jsondl = client.DownloadString(url); | |
JsonConvert.DeserializeObject<Class1[]>(jsondl) | |
.ToList() | |
.ForEach(item => | |
{ | |
Debug.WriteLine("{0} /{1}", item.railway, item.context); | |
}); | |
} | |
public class Class1 | |
{ | |
[JsonProperty("@context")] | |
public string context { get; set; } | |
[JsonProperty("@id")] | |
public string id { get; set; } | |
[JsonProperty("dc:date")] | |
public DateTime date { get; set; } | |
[JsonProperty("dct:valid")] | |
public DateTime tvalid { get; set; } | |
[JsonProperty("odpt:operator")] | |
public string Operator { get; set; } | |
[JsonProperty("odpt:railway")] | |
public string railway { get; set; } | |
[JsonProperty("odpt:timeOfOrigin")] | |
public DateTime timeOfOrigin { get; set; } | |
[JsonProperty("odpt:trainInformationText")] | |
public string trainInformationText { get; set; } | |
[JsonProperty("@type")] | |
public string type { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment