I've got JSON data that looks like this...
{
"generated" : "Sat, 20 Dec 3049 12:30:01",
"1" : { ... },
"2" : { ... },
...
"2400" : { ... },
}
Personally, I would've expected an array of objects to be outputted using the JSON array syntax (this is my first foray into JSON). I'm using Json.Net to try parse this mess into an object model for querying purposes and eventually display.
I was going to use the JsonSerializationAttribute
method of transforming the JSON into an object model. I've already tried going straight to XML instead but apparently this particular JSON file is not XML compatible ("1" is an invalid XML element name).
My initial object model class representing the high level snippet of JSON above is as follows:
public class MwoMapData
{
[JsonProperty(PropertyName = "generated")]
public DateTime Generated { get; set; }
[JsonArray]
public List<Planet> Planets { get; set; }
}
The resources I've read basically say that an array is not represented the way this has been and I'm totally stumped on how to parse this with Json.Net
into my object model.
My question is: How do I translate the object properties into an array using Json.Net
and JsonSerializationAttributes
?