Support JSON in the API

Another quick feature which should help with my Pebble development, thought I'd do a PR to upstream too :)