I have a JSON file, that I have copied into my project. It contains data like below.
{"_id":707860,"name":"Hurzuf","country":"UA","coord":{"lon":34.283333,"lat":44.549999}} {"_id":519188,"name":"Novinki","country":"RU","coord":{"lon":37.666668,"lat":55.683334}}
It has 20,000 such rows.
These are my classes.
public class Rootobject
{
public int _id { get; set; }
public string name { get; set; }
public string country { get; set; }
public Coord coord { get; set; }
}
public class Coord
{
public float lon { get; set; }
public int lat { get; set; }
}
What I want to do is deserialize the json data from the file and put it in a List object.
This is how I am deserializing the data.
var result = JsonConvert.DeserializeObject<Rootobject>(File.ReadAllText("list_city.json"));
It says foreach cannot operate on variables of type RootObject because RootObject doesn't contain public definition for 'GetEnumerator'.
What am I missing here?