Add a test for JSON encoding

This is mostly as an example for how to use it.