如何对象列表转换成JSON在ASP.NET [英] How to convert an Object List into JSON in ASP.NET

查看:225
本文介绍了如何对象列表转换成JSON在ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想响应的jQueryAjax请求派人对象的列表。我想送列表为JSON格式。列表如下 -

I have a list of person objects which I want to send in response to a jquery' ajax request. I want to send the list into JSON format. The list is as follows -

List<Person> PersonList = new List<Person>();

Person X = new Person("X", 23, "This is X");
Person Y = new Person("Y", 24, "This is Y");

PersonList.Add(X);
PersonList.Add(Y);

我如何转换这种 PersonList 列表成JSON?

推荐答案

JSON.NET已经工作对我很好。 HTTP://www.$c$cplex.com/Json

JSON.NET has worked really well for me. http://www.codeplex.com/Json

如果你正在做的Web窗体和JQuery那么这个链接可能帮助你:

And if you are doing Web Forms and JQuery then this link might help you out:

http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

这篇关于如何对象列表转换成JSON在ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆