'JSONView' Articles

JSONView is back

On November 14th of 2017, Firefox 57 was released, and JSONView stopped working. This was not unexpected - Mozilla had been warning for a while that they were going to shut off their old extension system completely and move to the WebExtension system pioneered by Google Chrome. All of the Firefox extensions using the old system were silently disabled.

I had hoped to have a new version of JSONView available that was compatible with this new system before Firefox 57 released, but unfortunately the deprecation coincided with a crunch period at work and I wasn’t able to make the time. However, last month I had a chance to relax for a bit while out of town for my wife’s show at Archimedes Gallery in Cannon Beach and I took a couple hours to hack out a WebExtension version of JSONView.

I had always been hesitant to write a WebExtension version (or a Chrome version) because the way JSONView works on Firefox is that it actually intercepts the request and rewrites it into HTML. Existing Chrome ports of JSONView ran on every page load and did stuff to try and rewrite the page, imposing a cost and a security exposure to every page. However, Firefox’s implementation of WebExtensions includes StreamFilter which lets me intercept and rewrite content in the same way as I did before!

Once I had a version working on Firefox, I got something working on Chrome as well. This works differently because StreamFilter is not available on Chrome, so I use a technique that still reformats the page after it loads, but it figures out which pages to act on in a fast, safe way. Thus, for the first time, there is an official JSONView for Google Chrome. If and when Chrome supports StreamFilter, JSONView will start using it transparently, with no changes required.

There are a few bits of functionality that had to be left behind. JSONView had the option to add application/json to your Accept header in order to convince APIs using content negotiation to serve JSON. That turned out not to be a popular way to write APIs, and JSON has since won over XML completely, so this option isn’t as necessary. On the plus side, the method by which I detect content types that contain JSON is much more flexible now, so any content type matching application/*+json will now work with JSONView as well - a long standing feature request.

On Firefox, you may notice that local files open in Firefox’s own JSON viewer instead of JSONView. To fix this, go to about:config and set devtools.jsonview.enabled to false.

JSONView remains a mature project that doesn’t need to change much, but I’m really happy that people can continue using it, and now Chrome users can get the same experience. If you don’t already have it, download JSONView for Firefox or Chrome.

The state of JSONView in 2017

I released JSONView in early 2009 to solve a simple problem I had - I’d been working with a number of JSON APIs, but Firefox had no way of directly viewing JSON documents. At the time, it wouldn’t even display them as text, showing a download dialog instead. Even after Firefox started showing JSON as text, it was still useful to show JSON nicely formatted and highlighted rather than however it was served. In the nearly eight years since its launch, JSONView has grown to about 130,000 daily users and has been downloaded 1.5 million times.

Once the initial few versions were out, I’ve updated JSONView on average every six months. Following that trend, I released JSONView 1.2.0 in late November. I’ve expected Firefox to subsume JSONView’s functionality ever since I first launched it, but amazingly this hasn’t happened yet. That said, Firefox has recently gained a very nice native JSON viewer hidden behind a developer flag (that’s only on by default in Firefox Developer Edition) and JSONView now offers the option of simply turning on that viewer instead of doing its own thing. Hopefully soon, JSONView won’t be needed at all.

I’ve always applied a minimalist philosophy to the extension. I’ve resisted adding a lot of bells and whistles in favor of a simple extension that does one thing well. This has the side-effect of reducing the rate of change of the extension, since besides the constant work of keeping it up to date with changes to Firefox, it’s pretty much done. There are still capabilities I’d like to add to JSONView, but those that haven’t already happened are usually impossible within the bounds of Firefox’s extension API. Speaking of which, Firefox is generally moving away from the sort of deep integration for extensions that JSONView requires - I hope JSONView is completely obviated by the time it can no longer work at all.

I personally don’t use JSONView anymore at all, because I no longer use Firefox. When I interact with JSON APIs I make use of the Chrome devtools, Emacs restclient-mode, and the jq and gron command-line tools. I’ve continued to maintain the extension, which remains open sourced on GitHub with several contributors helping out over time.

JSONView has been cloned, without permission (but without any resistance - it’s open source after all) as a Chrome extension in at least two instances. One of them became very popular but has been abandoned and is no longer on the Chrome web store because it contains security vulnerabilities. I never made a Chrome version myself because Chrome doesn’t offer the same integration APIs that Firefox does, so I couldn’t make it work the same way. JSONView for Firefox intercepts requests for JSON documents and produces HTML instead. The Chrome ports run on every single page that Chrome loads and try to figure out whether it looks like a JSON document, then reformats the document in-place. I never liked the security and performance implications of that, so I’ve avoided an official port. I keep an eye on Chrome’s extension API in case it ever becomes possible to do things the way I want to.

In summary, JSONView the Firefox extension is doing well, but is a mature project that will change slowly, if at all. JSONView for Chrome appears to be dead, and I don’t have immediate plans to produce an official port myself, but I won’t rule it out and I’d accept a well-implemented contribution as long as it matched the design and implementation philosophy of the original.

JSONView 0.7 works with Firefox 8+

Just slightly ahead of the release of Firefox 8, JSONView 0.7 has been approved on the Mozilla Add-ons site. Firefox 8 actually handles JSON documents in the browser for the first time, reducing the need for extensions like JSONView - now, a vanilla Firefox will display JSON as plain text instead of prompting a download of the document. Still, JSONView provides much more than what’s built in, and it will continue to be compatible with Firefox going forward (and it’s still compatible with older versions all the way back to version 3.0). If you’re on a modern version of Firefox you’ve probably already updated, and if not, you’ll get the new version when you upgrade.

After this update, I’ll be starting work on version 1.0, which should include some power user functionality that a few people have asked for, as well as some infrastructure changes that modernize how JSONView works with Firefox. Please fork the code on GitHub and contribute if you have something you want to add!

JSONView 0.6

Last week I released JSONView 0.6 to addons.mozilla.org. This is mostly a bugfix release, but I honestly don’t want to change much about such a simple addon. With over 60,000 daily users at this point, I feel that updates should be infrequent and unobtrusive. I do plan for some big new features for JSONView 1.0, but for now I’m mostly keeping the extension working with newer Firefoxes and fixing bugs that affect existing features. That said, one big change since the last version is that the source code is now on GitHub. I’m hoping this makes it easier for other developers to contribute, so please send pull requests! I’ll probably move the issues list over to GitHub as well at some point, but for now they’re still over at Google Code.

JSONView 0.6 fixed a couple of bugs around formatting text, especially when odd Unicode characters were present. Where previously JSONView would stop showing content after those characters, it now shows the Unicode escape sequence. Also, when there’s an error parsing a JSON document, the original document is displayed with its formatting intact, rather than squashed into a single line.

However, the most important bugfix is that disabling JSONView from the Addons page will un-do the “Include ‘application/json’ in the HTTP Accept header for requests” option. This is especially important since some popular websites handle content negotiation poorly and break when that option is on. Netflix was one high-profile example, but they’ve fixed their site now. I explained why this happens in detail in the issue report, and I won’t be removing the option because of it, but at least disabling the addon will fix the issue (of course, just unchecking the option will fix it too). I’ve added a warning to the option as well, just in case. Honestly I don’t think most people should need to turn that on, which is why it’s off by default.

The last big change is sort of halfway between a feature and a bugfix - copying and pasting from JSONView’s output will produce valid JSON. This includes all the quotes that JSONView omits for readability, and doesn’t include the “+/-” symbols used for collapsing objects and arrays. Hopefully this makes it easier to copy and paste bits of JSON out of Firefox and into your code or data without having to rewrite it.

Please update JSONView (if it hasn’t updated automatically by now) or download it if you haven’t tried it yet, and check out the code on GitHub if you find any bugs or have a feature you want to see.

JSONView 0.4 with content negotiation

JSONView 0.4 was just approved on addons.mozilla.org. This one is mostly a bugfix release from 0.3, but I couldn’t let it go out without one new feature, so I finally added support for content negotation. This means that you can go to the new JSONView options dialog (in the Addons menu) and enable sending the “application/json” content type with your HTTP Accept header. Some applications (like some Ruby on Rails websites) are set up to return JSON if you ask for it via the HTTP Accept header, and XML or HTML otherwise. This means thay you can now specify a preference for JSON, which should help when you’re in that situation. I specifically made sure it works with CouchDB, which is an exiting document-based database with a JSON API. Before this option, CouchDB would return plain text to browsers, but now you can make it send JSON that’ll be nicely formatted by JSONView. Note that the option to modify the HTTP Accept header isn’t on by default because many people won’t need it, and it has the potential to screw up some websites that don’t expect browsers to ask for JSON. That said, I’m sure this will be helpful in a bunch of situations.

JSONView Options

On the bugfix side, I fixed the issue I mentioned in my post about JSONView 0.3 where values that were 0 or false wouldn’t show up at all as a result of some overzealous error-checking. I also hunted down an infuriating bug where JSON documents would sometimes report as invalid when Firebug was on. This took a while to track down, but apparently Firebug slows down the loading of the document enough to mess with how I was reading a stream (and I had to be careful not to re-trigger an earlier bug that could cause Firefox on OSX to crash.) Anyway, it’s fixed now, and everybody should see more reliable document rendering, Firebug or not. For those living on the edge, JSONView is also marked as compatible up to Firefox 3.7a1pre, so you should have no trouble installing it on Minefield or the upcoming Firefox 3.6 alpha.

One thing that might stand out is that the new options dialog might not be localized for your language. JSONView’s localizations are handled by the generous volunteers at Babelzilla, which is great for me, but not as great when I want to rush out a release with important bugfixes. In this case I chose to ship 0.4 before all the new localizations had arrived, but I’ll add them all in again for the next release once the translators have caught up.

So grab JSONView 0.4 from addons.mozilla.org, or just update your extensions if you’ve already got it installed. As usual, feel free to send me feedback as comments on this post, and file bugs and feature requests at Google Code.

Updates to JSONView, XBList, and TopProcess

, ,

I’ve finally gotten around to doing some maintenance updates on three of my most-used bits of software (JSONView, XBList, and TopProcess), all in the last couple weeks. Now that they’re all approved and live, I thought I’d summarize what’s changed.

JSONView 0.3

JSONView 0.3 is now available at addons.mozilla.org. This fixes an error that was showing up when really large JSON files were being displayed, and adds a feature that displays empty arrays and object on one line instead of on two (and doesn’t display the expand/collapse button for them). I also put in some preliminary support for JSONP, based on a patch submitted by Gabriel Barros. The catch is that it only works with content served with the “application/json” MIME type, which is actually not the correct MIME type for JSONP - it should be “text/javascript” or another JavaScript type. Unfortunately I haven’t been able to figure out how to get Firefox to let me handle “text/javascript” the way I do with “application/json” - it seems to be special-cased or something. If any Firefox gurus are reading and know a solution, please let me know! I was holding onto this release for a while hoping to fix that, but I decided that releasing something was better than nothing, so it’s out there and you can play with it. You can see an example JSONP response with the callback highlighted here. I did notice a bug with the 0.3 release right after it was approved - if a value is 0 or false, it shows up as blank. I’ll have that bug fixed with the next release, which should be very soon. It’s great to see that JSONView has become so popular, with over 50,000 downloads and about 12,000 regular users.

XBList 3.2.4

Halo 3: ODST was released a couple weeks ago, and Bungie redesigned their site a bit to include ODST info in your Service Record. This included changing the pages just enough that XBList got confused trying to figure out emblems for people who had never played Halo, and started showing the wrong emblems for those people (only if you prefer Halo emblems to Xbox emblems, which isn’t the default). Not a huge bug, but I took the opportunity to clean up a bunch of stuff in XBList and put out a little release. In addition to the Halo emblem fix, I fixed a bug where your settings could get corrupted and you wouldn’t be able to start XBList. I also cleaned up the menus and settings, consolidating the Halo links into one item, and removing the option to choose a custom notification sound or turn off debug logging. The debug log is much easier to get to if you’re having trouble - previously I had people dig through their Application Data folders for the log, but now there’s an item in the Help menu that opens the debug log directly. Paired with some much more detailed logging, I should be able to fix future problems much more easily. I also changed the system tray icon to bring XBList to the front on a single click rather than a double click, since that feels much more natural in Windows 7. Lastly (and probably not too importantly for most people), I’m storing emblems in your local Windows profile now, instead of the roaming profile. For the few people who use XBList and have roaming profiles enabled, this should save you some sync time. Anyway, you should have been prompted to update when I pushed the update two weeks ago, but if you haven’t gotten it yet you should download and install it now. I still have plans for a major overhaul of XBList, but it’s low on my list of priorities - XBList is still pretty popular, but not as much as it used to be, with maybe 5,000 active users.

TopProcess 1.4

This last update has been a long time coming. Ever since I installed Internet Explorer 8, the TopProcess sidebar gadget has been randomly crashing. I’m not sure what changed in Internet Explorer to make it screw up every so often, but it does. However, it only crashes after running for a few days, so for months I’ve been tweaking the code a bit, then waiting until it crashes, then tweaking some more, rinse, repeat. I’ve finally nailed it down to the point where crashes are very rare, and then I added some code that automatically resets the gadget when it crashes. So you should never see it mess up again. There is also a gadget log file in the gadget’s install directory that I’m using to store errors, so it should be easier to troubleshoot in the future. Lastly, Jean-Pierre van Riel contributed a patch that added IO tracking to TopProcess, so there is now a third way to view your processes. This view shows you the total IO usage (combined bytes in and out, per second) which seems to cover both disk and network access. Get the update from me or from Windows Live Gallery and be sure to rate the gadget. I’m excited to see that it’s been downloaded over 100,000 times from WLG (plus who knows how many downloads from my site).

JSONView 0.2 adds support for opening local .json files

Just a quick update on JSONView - I’ve submitted version 0.2 to addons.mozilla.org. This new version doesn’t have a lot of changes, but it adds some new translations (Hungarian, Bulgarian, German, and some Turkish), and you can now open “.json” files saved on your computer, enabling offline JSON viewing. This new version is also compatible with the latest Firefox 3.5 betas.

Of course, the extension must be reviewed before this new version can be released from the sandbox, but if you want to try it out you can download version 0.2 from the sandbox. Hopefully it’ll be approved soon and will show up on the main extension listing. Please give it a look and rate and review the extension on addons.mozilla.org.

I’ll be out of the US on vacation until next month, but after that I intend to do some more work on the feature backlog for JSONView, as well some updates to other projects. Remember you can vote on features or file new ones at the Google Code issue tracker for JSONView.

JSONView Updated to 0.1b3

Today I uploaded a new version of JSONView to addons.mozilla.org. I’m sticking with the wimpy version number for now, but I think JSONView has been proving itself out in the wild. One major bug was uncovered that caused JSON documents larger than 8KB to render incorrectly, and that’s fixed in this new version. I’ve also added three new translations of the extension (French, Dutch, and Czech) courtesy of the folks at BabelZilla.org - if you want to help out you can check out the available translations and add yours. Lastly, the extension is now compatible with Firefox 3.1b3. I’ve been trying to keep things tested on the beta browsers within a day or two of their release. If you have an older version of the extension you’ll need to go back to AMO and install it again - automatic updates won’t work until JSONView is out of the sandbox.

JSONView has gotten a bit of coverage on the blogs, too, which I’ve enjoyed. It made it onto the front page of Delicious and reddit programming, and Ars Technica wrote an article in their journals. Also, I was interviewed on OpenSource Release Feed, which was fun. I’m glad that people are getting to use the extension and find it helpful. Hopefully when it gets released from the sandbox it’ll get even broader exposure.

JSONView - View JSON documents in Firefox

I’m a big fan of JSON as a data exchange format. It’s simple, lightweight, easy to produce and easy to consume. However, JSON hasn’t quite caught up to XML in terms of tool support. For example, if you try to visit a URL that produces JSON (using the official “application/json” MIME type), Firefox will prompt you to download the file. If you try the same thing with an XML document, it’ll display a nice formatted result with collapsible sections. I’ve always wanted a Firefox extension that would give JSON the same treatment that comes built-in for XML, and after searching for it for a while I just gave up and wrote my own. The JSONView extension (install) will parse a JSON document and display something prettier, with syntax highlighting, collapsible arrays and objects, and nice readable formatting. In the case that your JSON isn’t really JSON (JSONView is pretty strict) it’ll display an error but still show you the text of your document. If you want to see the original text at any time, it’s still available in “View Source” too.

JSONView logo

I’ve been eager to release this for some time, but I finally pushed it to addons.mozilla.org last night. I actually started development on it about 7 months ago, but work got paused on it for about 6 months due to stuff out of my control, and then I had some other projects I was working on. The actual development only took a few days (including digging through some confusing Unicode bugs). I thought it was funny that right as I was resuming work on JSONView I noticed that a JSON explorer had actually landed for Firebug 1.4, which I’ll also be looking forward to. Initially I had intended to build that functionality as part of my extension. There’s a lot I’d like to add on, like JSONP support and a preference to send the “application/json” MIME type in Firefox’s accept headers.

This is actually my first real open source project - I’ve released some code under open source licenses before, but this is actually set up at Google Code with an issue tracker and public source control and everything. I’ve licensed it under the MIT license. I’m really hoping people get interested in improving the extension with me. I’ve pre-seeded the issue tracker with some known bugs and feature requests.

The extension itself is pretty simple. I wasn’t sure how to approach the problem of supporting a new content type for Firefox, so I followed the example of the wmlbrowser extension and implemented a custom nsIStreamConverter. What this means is that I created a new component that tells Firefox “I know how to translate documents of type application/json into HTML”. And that it does - parsing the JSON using the new native JSON support in Firefox 3 (for speed and security) and then constructing an HTML document that it passes along the chain. This seems to work pretty well, though there are some problems - some parts of Firefox forget the original type of the document and treat it as HTML, so “View Page Info” reports “text/html” instead of “application/json”, “Save as…” saves the generated HTML, Firebug sees the generated HTML, etc. Just recently I came across the nsIURLContentListener interface, which might offer a better way of implementing JSONView, but I’m honestly not sure - the Mozilla documentation is pretty sparse and it was hard enough to get as far as I did. I’m hoping some Mozilla gurus can give me some pointers now that it’s out in the open.

Right now the extension is versioned at “0.1b1” which is a wimpy way of saying “this is a first release and it could use some work”. It’s also trapped in the “sandbox” at addons.mozilla.org, where it will stay until it gets some downloads and reviews. Please check it out, write a little review, and soon people won’t have to log in to install it!

Note: While composing this post I ran across the JSONovich extension which was apparently released in mid-December and seems to do similar stuff to JSONView. No reason we can’t have two competing extensions, though.