below is json string
st1: {
id: 1,
name: "Alabama",
shortname: "AL",
link: "javascript:window.alert('You can create links to the pages.');",
comment: "Name Surname<br>Business Development Manager<br>Phone: (000) 123-4567<br>Fax: (000) 123-4567<br>E-mail: name@domainname.com",
image: "photo.jpg",
color_map: "#ff5959",
color_map_over: "#f00001"
},
st2: {
id: 2,
name: "Alaska",
shortname: "AK ",
link: "",
comment: "",
image: "",
color_map: "#7798BA",
color_map_over: "#366CA3"
},
st3: {
id: 3,
name: "Arizona",
shortname: "AZ ",
link: "",
comment: "",
image: "",
color_map: "#7798BA",
color_map_over: "#366CA3"
},
I want to serialize with class or list or any other option
What I have tried:
class
public class jsonresultclass
{
public jsonresultclass()
{
mapdata = new List<mapdata>();
}
public List<mapdata> mapdata { get; set; }
}
public class mapdata
{
public int id { get; set; }
public string name { get; set; }
public string shortname { get; set; }
public string link { get; set; }
public string comment { get; set; }
public string image { get; set; }
public string color_map { get; set; }
public string color_map_over { get; set; }
}
call In
private List<jsonresultclass> GetUsers()
{
var usersList = new List<jsonresultclass>
{
new jsonresultclass
{
mapdata = new List<mapdata> {
new mapdata {
id = 1,
name= "Alabama",
shortname= "AL",
link= "javascript:window.alert('You can create links to the pages.');",
comment= "Name Surname<br>Business Development Manager<br>Phone: (000) 123-4567<br>Fax: (000) 123-4567<br>E-mail: name@domainname.com",
image= "photo.jpg",
color_map= "#ff5959",
color_map_over= "#f00001",
},
new mapdata {
id= 2,
name= "Alaska",
shortname= "AK ",
link= "",
comment= "",
image= "",
color_map= "#7798BA",
color_map_over= "#366CA3",
},
new mapdata {
id= 3,
name= "Arizona",
shortname= "AZ ",
link= "",
comment= "",
image= "",
color_map= "#7798BA",
color_map_over= "#366CA3",
},
},
}
};
return usersList;
}</jsonresultclass></jsonresultclass>