The below JSON and C# object works but it is UGLY c# object and with 50 states, it looks more ugly and not manageable. Looking for cleaner way to create c# object and that generates the same JSON. I can't modify the JSON because it is defined by the plugin.This website http://json2csharp.com/ is generating the below class. The application doesn't support the latest c# language
{
"main_settings": {
"width": "700",
"background_color": "#FFFFFF",
"fade_time": 0.1,
"link_text": "View Website"
},
"state_specific": {
"AB": {
"name": "Alberta",
"description": "default",
"color": "default",
"hover_color": "default",
"url": "default"
},
"AK": {
"name": "Alaska",
"description": "default",
"color": "default",
"hover_color": "default",
"url": "default"
},
"AL": {
"name": "Alabama",
"description": "default",
"color": "default",
"hover_color": "default",
"url": "default"
},
"AR": {
"name": "Arkansas",
"description": "default",
"color": "default",
"hover_color": "default",
"url": "default"
},
"AZ": {
"name": "Arizona",
"description": "default",
"color": "default",
"hover_color": "default",
"url": "default"
},
"YT": {
"name": "Yukon",
"description": "default",
"color": "default",
"hover_color": "default",
"url": "default"
}
}
}
C# class - to create the same JSON. May be better way to handle lists and arrays
public class MainSettings
{
public string width { get; set; }
public string background_color { get; set; }
public double fade_time { get; set; }
public string link_text { get; set; }
}
public class AB
{
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string hover_color { get; set; }
public string url { get; set; }
}
public class AK
{
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string hover_color { get; set; }
public string url { get; set; }
}
public class AL
{
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string hover_color { get; set; }
public string url { get; set; }
}
public class AR
{
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string hover_color { get; set; }
public string url { get; set; }
}
public class AZ
{
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string hover_color { get; set; }
public string url { get; set; }
}
public class YT
{
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string hover_color { get; set; }
public string url { get; set; }
}
public class StateSpecific
{
public AB AB { get; set; }
public AK AK { get; set; }
public AL AL { get; set; }
public AR AR { get; set; }
public AZ AZ { get; set; }
public YT YT { get; set; }
}
public class RootObject
{
public MainSettings main_settings { get; set; }
public StateSpecific state_specific { get; set; }
}