Rewriting library and spec to use JSON encoding