Fixed to_json method.