是否有一个内置的方式在.net AJAX手动序列化对象到JSON字符串? [英] Is there a built in way in .Net AJAX to manually serialize an object to a JSON string?

查看:106
本文介绍了是否有一个内置的方式在.net AJAX手动序列化对象到JSON字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx\"><$c$c>ScriptingJsonSerializationSection但我不知道如何使用它。我可以写一个函数来手动将对象转换为JSON字符串,但由于净能做到这一点上使用&LT飞; System.Web.Services.WebMethod()&GT; &LT; System.Web.Script.Services.ScriptMethod()&GT; 属性,所以必须有我就是缺少一个内置的方式。

I've found ScriptingJsonSerializationSection but I'm not sure how to use it. I could write a function to convert the object to a JSON string manually, but since .Net can do it on the fly with the <System.Web.Services.WebMethod()> and <System.Web.Script.Services.ScriptMethod()> attributes so there must be a built-in way that I'm missing.

PS:使用Asp.Net 2.0和VB.Net - 我把这个标签,但我认为人们错过了

PS: using Asp.Net 2.0 and VB.Net - I put this in the tags but I think people missed it.

推荐答案

这应该做的伎俩

Dim jsonSerialiser As New System.Web.Script.Serialization.JavaScriptSerializer
Dim jsonString as String = jsonSerialiser.Serialize(yourObject)

这篇关于是否有一个内置的方式在.net AJAX手动序列化对象到JSON字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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