export_to_file
Export JSON data to a specified file in JSON, JSONL, or CSV format. Supports absolute or relative paths, automatic directory creation, and precise insertion at defined line numbers.
Instructions
将JSON数据导出到指定文件,支持多种格式和插入位置。支持绝对路径和相对路径,自动创建不存在的目录。
Input Schema
Name | Required | Description | Default |
---|---|---|---|
file_path | Yes | 目标文件路径:支持绝对路径(如'D:/data/export.json')或相对路径(如'./output/export.json')。相对路径相对于当前工作目录 | |
format | No | 输出格式:json(标准JSON格式)、jsonl(每行一个JSON)、csv(逗号分隔值,仅支持扁平结构) | json |
insert_line | No | 插入行号:从1开始,指定在文件的第几行插入内容。不指定则覆盖整个文件 | |
json_ids | Yes | JSON ID列表:要导出的JSON的ID数组。使用item_operations工具查看可用的JSON ID | |
pretty_print | No | 是否美化输出:true(格式化缩进)、false(紧凑格式) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"file_path": {
"description": "目标文件路径:支持绝对路径(如'D:/data/export.json')或相对路径(如'./output/export.json')。相对路径相对于当前工作目录",
"type": "string"
},
"format": {
"default": "json",
"description": "输出格式:json(标准JSON格式)、jsonl(每行一个JSON)、csv(逗号分隔值,仅支持扁平结构)",
"enum": [
"json",
"jsonl",
"csv"
],
"type": "string"
},
"insert_line": {
"description": "插入行号:从1开始,指定在文件的第几行插入内容。不指定则覆盖整个文件",
"type": "number"
},
"json_ids": {
"description": "JSON ID列表:要导出的JSON的ID数组。使用item_operations工具查看可用的JSON ID",
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"pretty_print": {
"default": true,
"description": "是否美化输出:true(格式化缩进)、false(紧凑格式)",
"type": "boolean"
}
},
"required": [
"json_ids",
"file_path"
],
"type": "object"
}