using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Net;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
HttpWebRequest songRequest = (HttpWebRequest)WebRequest.Create("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=dockgg&api_key=e28039161acc777b14cfb09eb41ef896&limit=1&format=json");
HttpWebResponse songResponse = (HttpWebResponse)songRequest.GetResponse();
string songResult = new StreamReader(songResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd();
songResult = songResult.Replace("{\"#", "{\"");
songResult = @songResult.Replace("@", "");
Artist account = JsonConvert.DeserializeObject<Artist>(songResult);
Console.WriteLine(account.mbid);
}
}
public class Artist
{
public string text { get; set; }
public string mbid { get; set; }
}
public class Album
{
public string text { get; set; }
public string mbid { get; set; }
}
public class Image
{
public string text { get; set; }
public string size { get; set; }
}
public class Attr
{
public string nowplaying { get; set; }
}
public class Date
{
public string text { get; set; }
public string uts { get; set; }
}
public class Track
{
public Artist artist { get; set; }
public string name { get; set; }
public string streamable { get; set; }
public string mbid { get; set; }
public Album album { get; set; }
public string url { get; set; }
public List<Image> image { get; set; }
public Attr attr { get; set; }
public Date date { get; set; }
}
public class Attr2
{
public string user { get; set; }
public string page { get; set; }
public string perPage { get; set; }
public string totalPages { get; set; }
public string total { get; set; }
}
public class Recenttracks
{
public List<Track> track { get; set; }
public Attr2 attr { get; set; }
}
public class RootObject
{
public Recenttracks recenttracks { get; set; }
}
}