相关文章推荐
读研的人字拖  ·  Java 读取 .properties ...·  2 天前    · 
犯傻的绿茶  ·  clickhouse ...·  6 小时前    · 
飞奔的杯子  ·  npm ERR! code ...·  1 年前    · 
大力的砖头  ·  汇编 ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

You could use an excelent json2.js library: https://github.com/douglascrockford/JSON-js

Check out the JSON.stringify method.

Edit:

It seems like the librabry moved to github repo now: https://github.com/douglascrockford/JSON-js

Use the stringify method from Douglas Crockford's JSON object:

http://www.json.org/js.html

This will show your object in an alert box:

alert(JSON.stringify(myObject));
                the JSON library is not part of jQuery, but it is very useful.  I highly recommend using it.
– Silkster
                Sep 2, 2010 at 14:50

when it's an object, it's a javascript object, then it gets encoded as a string, a string that is a javascript syntax that expresses the object json-encoded. (JSON: JavaScript Object Notation).

However, these are the jquery built in function to parse json is jQuery.getJSON (retrieves the object out of the string).

to do things the other way around check this: Serializing to JSON in jQuery

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.