Extra context: API + CLI

Fixes #12
Synthesizes parts of: #75, #100, #116, #161 and #199.
Thanks @fcurella, @aventurella, @emonty, @schacki, @ryanolson!
Please add an explicit encoding here. It can be UTF-8 for now, I'll review all encodings at a later date, but it'll be much easier if all the places encodings are used are explicit.

Note that the JSON spec makes no mention of what encoding should be used for JSON files, the JSON format is a text format defined in terms of Unicode code points.