Friday, April 15, 2011

Debugging JSON results

With the renewed interest in jQuery and AJAX,  we sooner or later need to check some JSON results. Just opening the browser and typing the url will not result in some JSON  directly in the browser(with the exception of Chrome).

Enter JSONView which allows you to simply display JSON results directly in the browser.

Normally when encountering a JSON document content type "application/json", Firefox simply prompts you to download the file. With the JSONView extension, JSON documents are shown in the browser similar to how XML documents are shown. The document is formatted, highlighted, and arrays and objects can be collapsed. Even if the JSON document contains errors, JSONView will still show the raw text.

Note that this is a Firefox add in. To get a similar experience in IE to you can add a Mime type mapping in the registry:

Create a new application/json key in:

  • HKEY_CLASSES_ROOT\MIME\Database\ContentType\application/json

  • Add a string value of CLSID with a value of {25336920-03F9-11cf-8FD0-00AA00686F13}

  • Add a DWORD value of Encoding with a value of 80000

No comments: