3

Duplicate: Converting HTML TAG Object to JSON Object

Hi, Is there is any Javascript API that converts complex Javascript Objects To JSON String???

8
  • 3
    What do you mean by "complex" ? Commented May 24, 2010 at 3:47
  • How complex are you referring too? Commented May 24, 2010 at 3:47
  • @cooldude give a sample of it? Commented May 24, 2010 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? Commented May 24, 2010 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/…. Commented May 24, 2010 at 5:17

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

I have an example which it was not converting which i have sent in my previous post: stackoverflow.com/questions/2891476/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.