Advertisement
Guest User

json2sharp

a guest
Apr 30th, 2013
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using Newtonsoft.Json;
  5.  
  6.  
  7.  
  8.  
  9. public class Test
  10. {
  11.     public static void Main()
  12.     {
  13.         WebClient request = new WebClient();
  14.         var url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=B88B7699C6EACAE138DDB93BED6467EC&steamids=76561198026602449";
  15.         var response = request.DownloadString(url);
  16.  
  17.         var myObject = new RootObject();
  18.  
  19.         JsonConvert.PopulateObject(response, myObject);
  20.  
  21.         foreach (var player in myObject.response.players)
  22.         {
  23.             Console.WriteLine(player.personaname);
  24.         }
  25.  
  26.  
  27.         Console.ReadKey();
  28.     }
  29. }
  30.  
  31.  
  32.  
  33. public class Player
  34. {
  35.     public string steamid { get; set; }
  36.     public int communityvisibilitystate { get; set; }
  37.     public int profilestate { get; set; }
  38.     public string personaname { get; set; }
  39.     public int lastlogoff { get; set; }
  40.     public string profileurl { get; set; }
  41.     public string avatar { get; set; }
  42.     public string avatarmedium { get; set; }
  43.     public string avatarfull { get; set; }
  44.     public int personastate { get; set; }
  45. }
  46.  
  47. public class Response
  48. {
  49.     public List<Player> players { get; set; }
  50. }
  51.  
  52. public class RootObject
  53. {
  54.     public Response response { get; set; }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement