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));
–
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.