Created
June 25, 2012 15:50
-
-
Save scottksmith95/2989384 to your computer and use it in GitHub Desktop.
JSON from API as an object using Json.Net
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
using System; | |
using System.Net; | |
public class ApiRequest | |
{ | |
readonly static WebClient WebClient = new WebClient(); | |
public static string GetJson(Uri uri) | |
{ | |
return WebClient.DownloadString(uri); | |
} | |
} |
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
using System; | |
using Newtonsoft.Json; | |
class Program | |
{ | |
const string GitHubPath = "https://api.github.com/users/scottksmith95"; | |
static void Main(string[] args) | |
{ | |
var gitHubUri = new Uri(GitHubPath); | |
var json = ApiRequest.GetJson(gitHubUri); | |
var jsonObject = JsonConvert.DeserializeObject<object>(json); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment