Skip to content

Instantly share code, notes, and snippets.

@hminaya
Created April 15, 2013 01:07
Show Gist options
  • Save hminaya/5384988 to your computer and use it in GitHub Desktop.
Save hminaya/5384988 to your computer and use it in GitHub Desktop.
get JSON api with C#
using System;
using System.Net;
using Newtonsoft.Json;
namespace api
{
class MainClass
{
public static void Main (string[] args)
{
var url = "http://www.emplea.do/jobs.json";
var json = new WebClient().DownloadString(url);
Job[] result = JsonConvert.DeserializeObject<Job[]>(json);
foreach (var j in result) {
Console.WriteLine(j.title);
Console.WriteLine(j.description);
//etc..
}
}
}
class Job
{
public string apply {get; set;}
public int category_id {get; set;}
public string company_email {get; set;}
public string company_name {get; set;}
public string company_url {get; set;}
public int days {get; set;}
public string description {get; set;}
public string location {get; set;}
public string title {get; set;}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment