Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a built in way in .Net AJAX to manually serialize an object to a JSON string?

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: using Asp.Net 2.0 and VB.Net - I put this in the tags but I think people missed it.

like image 248
travis Avatar asked Aug 29 '08 19:08

travis


1 Answers

This should do the trick

Dim jsonSerialiser As New System.Web.Script.Serialization.JavaScriptSerializer
Dim jsonString as String = jsonSerialiser.Serialize(yourObject)
like image 106
TonyB Avatar answered Oct 04 '22 16:10

TonyB