I want to make a program that reads some data from JSON file generated from an API.
Here's an example of that JSON file:
{"block4o": {
"id": 20153910,
"name": "Block4o",
"profileIconId": 616,
"revisionDate": 1408783284000,
"summonerLevel": 30
}}
What I need to do is to get e.g the id and the name from it. Here is my code so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.IO;
using System.Net;
namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{
}
public void HowToMakeRequestsToHttpBasedServices()
{
Uri serviceUri = new Uri("https://eune.api.pvp.net/api/lol/eune/v1.4/summoner/by-name/Block4o?api_key=****");
WebClient downloader = new WebClient();
downloader.OpenReadCompleted += new OpenReadCompletedEventHandler(downloader_OpenReadCompleted);
downloader.OpenReadAsync(serviceUri);
}
void downloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
Stream responseStream = e.Result;
// Continue working with responseStream here...
}
}
}
}
Any ideas will be really appreciated :)