Refactor with_json_equivalent.