Added proper to_json method.