Created
May 3, 2013 18:18
-
-
Save kbrammer/5512319 to your computer and use it in GitHub Desktop.
Simple example of calling GitHub API from LINQPad and serializing the returned JSON
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
void Main() | |
{ | |
System.Net.WebClient client = new System.Net.WebClient(); | |
JavaScriptSerializer js = new JavaScriptSerializer(); | |
var url = "https://api.github.com/repos/kbrammer/kevinbrammer.azurewebsites.net/contents"; | |
var results = client.DownloadString(url); | |
Content[] r = js.Deserialize<Content[]>(results); | |
r.Dump("Results"); | |
} | |
[Serializable] | |
public class Links | |
{ | |
public string self { get; set; } | |
public string git { get; set; } | |
public string html { get; set; } | |
} | |
[Serializable] | |
public class Content | |
{ | |
public string sha { get; set; } | |
public string size { get; set; } | |
public string name { get; set; } | |
public string path { get; set; } | |
public string type { get; set; } | |
public string url { get; set; } | |
public string git_url { get; set; } | |
public string html_url { get; set; } | |
public Links _links { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment