【发布时间】:2011-01-05 14:57:17
【问题描述】:
嗨,我正在尝试将字符串发送到看起来像 json 的视图。
我正在发送地点列表:
class Place
{
public string title { get; set; }
public string description { get; set; }
public double latitude { get; set; }
public double longitude { get; set; }
}
List<Place> placeList = new List<Place>();
//add places to PlaceList
//Then i do this
System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(placeList);
ViewBag.Places = sJSON;
在视图中它的渲染输出是这样的:
[{"title":"sdf sdfsd sdf sd f","description":"sdf sdf sd fsd sd sdf sdf dssd sdf sd s","latitude":53.740259851464685,"longitude":-2.4602634343627927},
如何让它在视图中呈现为正常的 json?减去&quot;etc?
【问题讨论】:
标签: c# asp.net-mvc json