Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  23] [ 6]  / answers: 1 / hits: 40065  / 13 Years ago, wed, february 15, 2012, 12:00:00

What is the easiest way to read json from Firefox or Chrome's developer console? Do I need to install a plugin? Or hopefully there's a javascript function that lets you view json in a way that's much easier to read...



For example. If I try console.log(data) where data is the json object, the developer console displays it like a one huge chunk of string instead of displaying the structure, so it's really hard to sift through and filter out what I want.



EDIT:
I apologize for the confusion I caused. I just checked Chrome and it seems Chrome does display JSON in a structured way. However on Firefox it's all jumbled together. I attached the screenshot. I guess the question is Is there a way to display this in a more structured way like on Chrome?, and as I learned from below, I guess console.dir() takes care of this. Then my last question would be: Is this an intended behavior?



console.log(data)


More From » firefox

 Answers
9

Firebug and Webkits developer tools display any object, structured and well readable.
It seems like you try to output a JSON string instead an object. If thats the case, just parse it into an object before



console.log( JSON.parse( data ) );


and by the way, there are lots of neat methods on the console object, like console.dir() which directly lists an object properties/keys.


[#87440] Tuesday, February 14, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
morganm

Total Points: 626
Total Questions: 95
Total Answers: 95

Location: South Sudan
Member since Sun, Jul 11, 2021
3 Years ago
;