Fixe some messy JSON encoding.