I'm using a 3rd party map for some charting functionality within our intranet. To populate the regions, I need to pass it an Object Collection (javascript) formatted thusly:
simplemaps_usmap_mapdata.state_specific = {
AZ: {
name: "Arizona",
description: "The best state in the whole got damn union",
color: "#cecece",
hover_color: "default",
url: "",
},
NH: {
name: "New Hampshire",
description: "Small and insignificant",
color: "#f68831",
hover_color: "default",
url: "",
}
}
Obviously, it'd be much better if it were an array of objects, then it'd be simple enough to return via my C# controller a List, but since it's an object collection, what is the best way to return JSON formatted this way via my C# controller?
[Data Contract]for each State object, serialise these to JSON and then manually format the rest of the JSON? I'm not sure of a way to automatically convert an array of objects with custom structure like that. I can put together an example for this if you think this would help.