I made a code that uses the APIs provided by football-data.org, I managed to download the json containing all parameters that I expect to receive. Unless the content in responseText, now I would like to divide the content of responseText in some variables.
string requestUrl = "http://api.football-data.org/alpha/soccerseasons/?season=2014";
HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
request.Method = "GET";
request.ContentType = "application/json";
string responseText;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
using (var responseStream = new StreamReader(response.GetResponseStream()))
{
responseText = responseStream.ReadToEnd();
}
Console.WriteLine(responseText);
As you can see the structure of the json also shown in the documentation it is as follows:
Example response:
{
"_links": {
"self": { "href": "http://api.football-data.org/alpha/soccerseasons/354" },
"teams": { "href": "http://api.football-data.org/alpha/soccerseasons/teams" },
"fixtures": { "href": "http://api.football-data.org/alpha/soccerseasons/fixtures" },
"leagueTable": { "href": "http://api.football-data.org/alpha/soccerseasons/leagueTable" }
},
"caption": "Premier League 2014/15",
"league": "PL",
"year": "2014",
"numberOfTeams": 20,
"numberOfGames": 380,
"lastUpdated": "2014-12-21T10:47:43Z"
}
I would then create variables that once obtained content in responseText, split of all as:
String caption = the caption of json so (Premier League 2014/15)
String league = PL
I do not know if I made clear the idea and if the code that I made is good. I relied on my experience with vb.net strong and now I'm trying to migrate to c# for purposes of study.