我需要从服务器端返回一个对象数组。如何序列化下面的示例,使其看起来像使用 c# 和 webforms?
var word_list = [
{text: "Lorem", weight: 15},
{text: "Ipsum", weight: 9, url: "http://jquery.com/", title: "I can haz URL"},
{text: "Dolor", weight: 6},
{text: "Sit", weight: 7},
{text: "Amet", weight: 5}
// ...other words
];
我尝试了以下方法,但它在属性中添加了引号并且似乎不起作用。
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);