Reputation: 7799
In my web application, there is a complex JavaScript object that I need to debug. I'd like to be able to view it in it's JSON form. It is not sent to or from the server, so I can't see it in the network tab of any of the developer tools. I can see it in the "Scope Variables" area, but not as JSON.
Is there a way, using the developer tools for any of the major browsers, to view a local JavaScript variable as JSON?
Upvotes: 2
Views: 72
Reputation: 877
In chrome or in firebug, simply do console.log(myObj)
You will be able to open up the object and see its values and properties.
Upvotes: 1
Reputation: 172458
I think you are looking for:
JSON.stringify(obj, null, 4)
Although you can display objects directly in most debuggers using
console.log(obj);
or
console.dir(obj);
Upvotes: 4