Use oj for json encoding

Supersedes #771