Hi
I am tring to ge the values of the Json file.
WebRequest request = WebRequest.Create ("https://api.myjson.com/bins/25td0");
request.Credentials = CredentialCache.DefaultCredentials;
WebResponse response = request.GetResponse ();
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
Stream dataStream = response.GetResponseStream ();
StreamReader reader = new StreamReader (dataStream);
string json = reader.ReadToEnd ();
Console.WriteLine ("Json is printing " + json);
From the above code I am able to print the json file content.
var list = JsonConvert.DeserializeObject<List>(json);
Console.WriteLine("list it is showing"+list.);
From this line I am getting
list it is showing System.Collections.Generic.List`1[Json.NET.Android.Sample.MyClass]
This is my model.
public class MyClass
{
public string id;
public string displayName;
public string name;
public string slug;
public string imageUrl;
}
My Json file content is below.
[
{
"id": "5241585099662481339",
"displayName": "Music",
"name": "music",
"slug": "music",
"imageUrl": "http://kcdn3.klout.com/static/images/music-1333561300502.png"
},
{
"id": "6953585193220490118",
"displayName": "Celebrities",
"name": "celebrities",
"slug": "celebrities",
"imageUrl": "http://kcdn3.klout.com/static/images/topics/celebrities_b32741b6703151cc7bd85fba24c44c52.png"
},
{
"id": "5757029936226020304",
"displayName": "Entertainment",
"name": "entertainment",
"slug": "entertainment",
"imageUrl": "http://kcdn3.klout.com/static/images/topics/Entertainment_7002e5d2316e85a2ff004fafa017ff44.png"
},
{
"id": "3718",
"displayName": "Saturday Night Live",
"name": "saturday night live",
"slug": "saturday-night-live",
"imageUrl": "http://kcdn3.klout.com/static/images/icons/generic-topic.png"
},
{
"id": "8113008320053776960",
"displayName": "Hollywood",
"name": "hollywood",
"slug": "hollywood",
"imageUrl": "http://kcdn3.klout.com/static/images/topics/hollywood_9eccd1f7f83f067cb9aa2b491cd461f3.png"
}
]
How can I repeat the loop and print each and every id and displayname in the json file.