CSharp · Console
using System;
using System.Collections.Generic;
using DalSoft.RestClient;
public class Program
{
public static void Main()
{
dynamic client = new RestClient("http://jsonplaceholder.typicode.com");
List<User> users = client.Users.Get().Result;
foreach (var user in users)
{
Console.WriteLine("User:" + user.name);
Console.WriteLine("Company:" + user.company.name);
}
}
public class User
{
public int id
{
get;
set;
}
public string name
{
get;
set;
}
public string username
{
get;
set;
}
public string email
{
get;
set;
}
public Address address
{
get;
set;
}
public string phone
{
get;
set;
}
public string website
{
get;
set;
}
public Company company
{
get;
set;
}
}
public class Geo
{
public string lat
{
get;
set;
}
public string lng
{
get;
set;
}
}
public class Address
{
public string street
{
get;
set;
}
public string suite
{
get;
set;
}
public string city
{
get;
set;
}
public string zipcode
{
get;
set;
}
public Geo geo
{
get;
set;
}
}
public class Company
{
public string name
{
get;
set;
}
public string catchPhrase
{
get;
set;
}
public string bs
{
get;
set;
}
}
}