I am using jQuery. I am dealing with JSON object and time and again I need to look at the data. I do alert(data) and I get nothing useful.
In the Prototype world they have inspect method which is highly useful. inspect method in Prototype
I am looking for equivalent method in jQuery. I looked at the API and couldn't find anything. I am sure someone would have developed some plugin to solve this problem.
If you are using FireBug, you can just call
console.log(myJsonObject)
, and FireBug will give you a nice display of your JSON object in the console.Also, firefox and other good browsers support toSource() method on objects and functions.
alert(foo.toSource())
You can do this, too...
You can use the
jQuery.param
function, which will format it into a querystring format.I have the best result with http://www.JSON.org/json2.js. As the docs say:
Just include the library and call
alert(JSON.stringify(data))
to see a legible representation of your object.