Duplicate: http://stackoverflow.com/questions/2891476/converting-html-tag-object-to-json-object
Hi, Is there is any Javascript API that converts complex Javascript Objects To JSON String???
Duplicate: http://stackoverflow.com/questions/2891476/converting-html-tag-object-to-json-object
Hi, Is there is any Javascript API that converts complex Javascript Objects To JSON String???
I don't think what you're looking for a an API
per se. That would be a something like a service where you send data and receive back something else.
What you want is called a serializer. It turns a javascript object into a string of text representing the object-literal. For example:
var foo = {};
foo[bar] = "baz";
//do serializing to get a -string- that looks like this:
{bar: "baz"}
That way when a service receives this JSON information, if it uses javascript, it's already in a format where it can be read directly into memory without conversion. Here is an example javascript serializer:
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx