add support for json output to query command

This is my first go pull request, so feel free to pick it apart!