Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome display JSON AJAX response as tree and not as a plain text

People also ask

How do I change the JSON formatter in Chrome?

JSON Formatter (app) Just insert code into the single box visible on the web page and press the “Format JSON” button. The desired re-formatted text will be displayed below. An “Un-Format JSON” button is available to edit JSON files back to their space-saving original form.

Can Chrome display JSON?

It works with any JSON page, regardless of the URL you opened. It also works with local files, after you enable it in chrome://extensions . You can inspect the JSON by typing json into the console.


To see a tree view in recent versions of Chrome:

Navigate to Developer Tools > Network > the given response > Preview


Google Chrome now supports this (Developer Tools > Network > [XHR item in list] Preview).

In addition, you can use a third party tool to format the json content. Here's one that presents a tree view, and here's another that merely formats the text (and does validation).


The correct content-type for JSON data is application/json. I assume that is what you are missing.


You can use Google Chrome Extension: JSONView All formatted json result will be displayed directly on the browser.


I've found the answer:

You MUST encode your json like this: {"c":21001,"m":"p"} but not {c:21001,m:"p"} or {'c':21001,'m':'p'}

Thus, the key of a dict must be wrapped in double quotes:", then chrome will preview it as json rather than plain text.


In order for it to display the JSON message properly it has to have the "application/json" mime type and to be correctly structured.

You can check the structure here


There was an issue with a build of Google Chrome Dev build 24.0.1312.5 that caused the preview panel to no longer display a json object tree but rather flat text. It should be fixed in the next dev

See more here: http://code.google.com/p/chromium/issues/detail?id=160733