up vote 2 down vote favorite
1

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???

flag

0% accept rate
3  
What do you mean by "complex" ? – CMS May 24 at 3:47
How complex are you referring too? – gurun8 May 24 at 3:47
@cooldude give a sample of it? – Pandiya Chendur May 24 at 3:47
JSON.stringify (from http://www.json.org/json2.js) serializes nested objects, arrays, numbers, strings, bools, and null. Do you need more? – Joey Adams May 24 at 3:50
@CMS,@gurun8,@Pandiya,@Joey: By complex objects I mean Html Tag object like Canvas object, graphics objects created by Cake Api. Example I Have provided in previous post: stackoverflow.com/questions/2891476/…. – cooldude May 24 at 5:17
show 3 more comments

1 Answer

up vote 1 down vote

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

link|flag
@Alex: I have an example which it was not converting which i have sent in my previous post: stackoverflow.com/questions/2891476/… – cooldude May 24 at 5:19

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.