Added --json option and tests.

This adds the ability to export to JSON.  The benefit is easy integration with other tools.  It would have been slightly cleaner to leverage something like [aeson](https://github.com/bos/aeson), but I figured it was simpler to not introduce an additional dependency.