Basic REST JSON support

The first commit here is also in the #262 pull request.

This implements REST JSON support on top of the text-stream channels.