loop on data returned after deserializing

588 views Asked by At

I get data from instagram api. So i use below

var responseStream = webRequest.GetResponse().GetResponseStream();
Encoding encode = System.Text.Encoding.Default;

using (StreamReader reader = new StreamReader(responseStream, encode))
 {
     var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     var jsonObject = serializer.DeserializeObject(reader.ReadToEnd());
 }

I dont know how to loop on this data. I tried

 foreach (var item in  jsonObject)
 {

 }

But it gives compile time error Type object is not enumerable

How do i loop?

1

There are 1 answers

5
PMerlet On

Your variable jsonObject is an object which is not an enumerable. You must specify an enumerable type when deserializing :

var jsonObject = serialize.Deserialize<enumerableType>(reader.ReadToEnd());