Oct
27
2006
JQuery and ASP.NET - using JSon.NET to serialize object
Posted by admin under
Ajax
Continued from this article
The GetResultDataJSON function we created might not be so fun to implement for each type of object you want to serialize up to the javascript client code.
There is help - JSon.NET offers a serializer component which makes the code look just like this:
public string GetResultDataJSON()
{
return Newtonsoft.Json.JavaScriptConvert.SerializeObject(this);
}
On the other side - you might think - it was not all that hard - why should I depend on some third party component (even though it's free i.e released under Creative Commons Attribution 2.5 License )? Well, our sample was really simple - wait until you need to serialize say an array or collection...Then you will want to get every help you can I my guess.