87,917
社区成员
发帖
与我相关
我的任务
分享
var provinceList = [
{
name:'北京',
cityList:[
{
name:'市辖区',
areaList:['东城区','西城区','崇文区','宣武区']
},
{
name:'县',
areaList:['密云县','延庆县']
}
]
},
{
name:'上海',
cityList:[
{
name:'市辖区',
areaList:['黄浦区','卢湾区','徐汇区','南汇区','奉贤区']
},
{
name:'县',
areaList:['崇明县']
}
]
}
public class provinceList
{
public string name{ get; set; }
public List<info> cityList{ get; set; }
}
public class info
{
public string name{ get; set; }
public string[] areaList{ get; set; }
}
[WebMethod]
public static string GetData(string msg)
{
provinceList grid1 = new provinceList ();
info grid2 = new info();
grid1.name= "北京";
grid2.name= "市区";
grid2.areaList= new string[] { "东城区","宣武区"};
//
//接下来不知道该怎么写了
//
string datafirst = Newtonsoft.Json.JsonConvert.SerializeObject(grid1);
return datafirst;
}
List<provinceList> prolist = new List<provinceList>();
provinceList pro = new provinceList();
pro.cityList = new List<info>();
pro.name = "北京";
info city= new info();
city.name = "市区";
city.areaList = new string[] { "东城区", "宣武区" };
pro.cityList.Add(city);
prolist.Add(pro);
//...more
string datafirst = Newtonsoft.Json.JsonConvert.SerializeObject(prolist);
return datafirst;