Reputation: 145
im using the next code:
dynamic jsonObj = JsonConvert.DeserializeObject(reader.ReadToEnd());
foreach (var item in jsonObj)
{
Console.WriteLine("");
}
Where reader.ReadToEnd()
has a json string.
But i have an error on foreach,
Error 13 foreach statement cannot operate on variables of type 'System.Collections.IEnumerable' because 'System.Collections.IEnumerable' does not contain a public definition for 'GetEnumerator' C:\Users\myUser\Desktop\app\appRecept\Paises.cs 47 29 appPreregistro
Upvotes: 1
Views: 5529
Reputation: 41008
If you're deserializing an array of objects from JSON, something that looks like this:
[
{blah},
{blah},
{blah}
]
then deserialize to a List type:
var jsonObj = JsonConvert.DeserializeObject<List<dynamic>>(reader.ReadToEnd());
Upvotes: 1