如何在json文件中保存对象列表? 这是我的代码:
string json = System.IO.File.ReadAllText(Server.MapPath("~/settings.conf"));
dynamic jsonObj = JsonConvert.DeserializeObject(json);
City city = svm.City;
jsonObj["city"]["name"] = city.Name;
jsonObj["city"]["latitude"] = city.Latitude;
jsonObj["city"]["longitude"] = city.Longitude;
jsonObj["city"]["id"] = city.ID;
List<Social> bottomSocial = svm.BottomSocials;
jsonObj["bottomSocial"] = bottomSocial;
string output = JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
System.IO.File.WriteAllText(Server.MapPath("~/settings.conf"), output);
它适用于City,但不适用于bottomSocial。