Simplify `toJSON` a bit. Ref #191.