I have a JSON file that I need to convert to a C# object, which will then be written to a SQL database. The JSON is in this format:
{
"AK": {
"Anchorage": [{
"Name": "John Doe",
"Address": "123 Main St.",
"City": "Anchorage",
"State": "AK",
"Zip": "12345"
}],
"Fairbanks": [{
"Name": "Sally Smith",
"Address": "987 Main St.",
"City": "Fairbanks",
"State": "AK",
"Zip": "98765"
}]
}
}
I have a C# class that looks like this:
public class Location
{
public string Name { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public int Zip { get; set; }
}
public class Locations
{
public List<Location> Location { get; set; }
}
I'm using the Newtonsoft JSON library. I'm not sure how I can grab the inner values (Name, Address, City, State, Zip) when the outer values "AK", "Anchorage", "Fairbanks" do not have common names?