简体   繁体   中英

Complex Javascript objects to JSON Objects

Duplicate: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM