<p>I've found <a href="http://msdn.microsoft.com/en-us/library/system.web.configuration.scriptingjsonserializationsection.scriptingjsonserializationsection.aspx" rel="noreferrer"><code>ScriptingJsonSerializationSection</code></a> 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 <code>&lt;System.Web.Services.WebMethod()&gt;</code> and <code>&lt;System.Web.Script.Services.ScriptMethod()&gt;</code> attributes so there must be a built-in way that I'm missing. </p>

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

[{'answer_id': 35125, 'author': 'TonyB', 'author_id': 3543, 'author_profile': 'https://Stackoverflow.com/users/3543', 'pm_score': 5, 'selected': True, 'text': '<p>This should do the trick</p>\n\n<pre><code>Dim jsonSerialiser As New System.Web.Script.Serialization.JavaScriptSerializer\nDim jsonString as String = jsonSerialiser.Serialize(yourObject)\n</code></pre>\n'}, {'answer_id': 35128, 'author': 'Joseph Kingry', 'author_id': 3046, 'author_profile': 'https://Stackoverflow.com/users/3046', 'pm_score': 3, 'selected': False, 'text': '<p>I think what you\'re looking for is this class:</p>\n\n<p><code>System.ServiceModel.Web.DataContractJsonSerializer</code></p>\n\n<p>Here\'s an example from Rick Strahl: <a href="http://www.west-wind.com/WebLog/posts/218001.aspx" rel="nofollow noreferrer">DataContractJsonSerializer in .NET 3.5</a></p>\n'}, {'answer_id': 35132, 'author': 'Jarrod Dixon', 'author_id': 3, 'author_profile': 'https://Stackoverflow.com/users/3', 'pm_score': 2, 'selected': False, 'text': '<p>In the System.Web.Extensions assembly, version 3.5.0.0, there\'s a <a href="http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx" rel="nofollow noreferrer">JavaScriptSerializer</a> class that should handle what you want.</p>\n'}, {'answer_id': 35133, 'author': 'Steven Williams', 'author_id': 3294, 'author_profile': 'https://Stackoverflow.com/users/3294', 'pm_score': 1, 'selected': False, 'text': '<p>Try</p>\n\n<pre><code>System.Web.Script.Serialization.JavaScriptSerializer\n</code></pre>\n\n<p>or Check out <a href="http://www.json.org/" rel="nofollow noreferrer">JSON.org</a> there is a whole list of libraries written to do exactly what you want.</p>\n'}, {'answer_id': 35134, 'author': 'Dave Ward', 'author_id': 60, 'author_profile': 'https://Stackoverflow.com/users/60', 'pm_score': 2, 'selected': False, 'text': '<p>Since the JavaScriptSerializer class is technically being deprecated, I believe <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx" rel="nofollow noreferrer">DataContractJsonSerializer</a> is the preferable way to go if you\'re using 3.0+.</p>\n'}, {'answer_id': 35136, 'author': 'Jason Bunting', 'author_id': 1790, 'author_profile': 'https://Stackoverflow.com/users/1790', 'pm_score': 2, 'selected': False, 'text': '<p>Well, I am currently using the following extension methods to serialize and deserialize objects:</p>\n\n<pre><code>using System.Web.Script.Serialization;\n\npublic static string ToJSON(this object objectToSerialize)\n{\n  JavaScriptSerializer jss = new JavaScriptSerializer();\n  return jss.Serialize(objectToSerialize);\n}\n\n/// &lt;typeparam name="T"&gt;The type we are deserializing the JSON to.&lt;/typeparam&gt;\npublic static T FromJSON&lt;T&gt;(this string json)\n{\n  JavaScriptSerializer jss = new JavaScriptSerializer();\n  return jss.Deserialize&lt;T&gt;(json);\n}\n</code></pre>\n\n<p>I use this quite a bit - be forewarned, this implementation is a bit naive (i.e. there are some potential problems with it, depending on what you are serializing and how you use it on the client, particularly with DateTimes).</p>\n'}]
['https://Stackoverflow.com/questions/35106', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1414/']