agentscope.service.file.json module
Operators for json file and directory.
- agentscope.service.file.json.read_json_file(file_path: str) ServiceResponse [源代码]
Read and parse a JSON file.
- 参数:
file_path (str) – The path to the JSON file to be read.
- 返回:
Where the boolean indicates success, the Any is the parsed JSON content (typically a dict), and the str contains an error message if any, including the error type.
- 返回类型:
ServiceResponse
- agentscope.service.file.json.write_json_file(file_path: str, data: Any, overwrite: bool = False) ServiceResponse [源代码]
Serialize data to a JSON file.
- 参数:
file_path (str) – The path to the file where the JSON data will be written.
data (Any) – The data to serialize to JSON.
overwrite (bool) – Whether to overwrite the file if it already exists.
- 返回:
where the boolean indicates success, and the str contains an error message if any, including the error type.
- 返回类型:
ServiceResponse