I use the JavaScriptSerializer
class of ASP.net to serialize my object and return it to the client side. How can I deserialize the string using JavaScript?
| |||||
feedback
|
If you're using jQuery already, you'll be happy to know that you can parse a JSON string with If you aren't using jQuery and don't want to, you can always use the wonderful I would avoid | |||||
feedback
|
I am going to propose ... do nothing. This assumes the serialized result is returned with the page and/or an additional HTML fragment.
This works and is valid because JSON is a subset of JavaScript literals. Note that I did not put quotes around the If the de-serialization is the result on an AJAX call returning JSON, etc, then see Zack's answer. | |||
feedback
|
Pretty trivial -- just do
which should get everything except ASP.Net's unique serialization of
which will invoke the special Date handling and probably get you better security. | |||||
feedback
|
Pretty standard, not so safe:
Kind of cool thing that jQuery does, still not very safe:
| |||||||
feedback
|