Skip to content

Instantly share code, notes, and snippets.

@kbrammer
Created May 3, 2013 18:18
Show Gist options
  • Save kbrammer/5512319 to your computer and use it in GitHub Desktop.
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
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