I have the following class
public class Airport
{
[MaxLength(75)]
public string Name { get; set; }
public bool NotInUse { get; set; }
[MaxLength(50)]
public string City { get; set; }
[MaxLength(50)]
public string Country { get; set; }
[MaxLength(2)]
public string Iso { get; set; }
[MaxLength(3)]
public string Iata { get; set; }
[MaxLength(4)]
public string Icao { get; set; }
}
I have the following json file - Not all properties are within the json
{
"Airports":{
[
{
"Name": "Belfast International",
"City": "Belfast",
"Country": "United Kingdom",
"Iso": "GB",
"Iata": "BFS"
},
{
"Name": "City of Derry",
"City": "Derry",
"Country": "United Kingdom",
"Iso": "GB",
"Iata": "LDY"
}
]
}
}
I am trying to deserialise the json with this method
public IList<Airport> ReadAirportsFromJson()
{
if (File.Exists(AirportJsonFilename))
{
string fileContents = File.ReadAllText(AirportJsonFilename);
var airports = JsonConvert.DeserializeObject<List<Airport>>(fileContents);
return airports;
}
return null;
}
I get the following exception

I am unsure how to progress this and resolve the issue.
{...}, if"Airports"is supposed to be an array or is missing a key to go with the combined object and array.List<Airports> Airportsproperty, but even so the value is an object directly containing an array, which I don't think is valid JSON.