@@ -45,53 +45,36 @@ npm link
4545json-diff file1.json file2.json
4646
4747# 指定输出格式
48- json-diff file1.json file2.json --format table
49- json-diff file1.json file2.json --format json
50- json-diff file1.json file2.json --format yaml
51- json-diff file1.json file2.json --format tree
48+ json-diff file1.json file2.json --output table
49+ json-diff file1.json file2.json --output json
50+ json-diff file1.json file2.json --output yaml
51+ json-diff file1.json file2.json --output tree
5252
5353# 保存结果到文件
54- json-diff file1.json file2.json --output result.json
54+ json-diff file1.json file2.json --output-file result.txt
5555
56- # 递归比较目录
57- json-diff dir1/ dir2/ --recursive
58-
59- # 显示统计信息
56+ # 显示统计信息/禁用颜色
6057json-diff file1.json file2.json --stats
61-
62- # 禁用颜色输出
6358json-diff file1.json file2.json --no-color
6459```
6560
66- ### PowerShell 包装脚本
67-
68- 项目还提供了 PowerShell 包装脚本,方便在 Windows 环境中使用:
61+ ### Windows 使用说明
6962
70- ``` powershell
71- # 使用 PowerShell 脚本
72- .\scripts\Compare-JsonFiles.ps1 -File1 "config1.json" -File2 "config2.json"
73-
74- # 指定输出格式
75- .\scripts\Compare-JsonFiles.ps1 -File1 "config1.json" -File2 "config2.json" -Format "table"
76-
77- # 递归比较目录
78- .\scripts\Compare-JsonFiles.ps1 -Directory1 "src" -Directory2 "backup" -Recursive
79-
80- # 保存到文件
81- .\scripts\Compare-JsonFiles.ps1 -File1 "config1.json" -File2 "config2.json" -OutputFile "diff.json"
82- ```
63+ 在 Windows 11 下,建议使用 PowerShell 7+ 直接运行 ` json-diff ` ,命令与参数与示例一致。
8364
8465## 命令行选项
8566
8667| 选项 | 简写 | 描述 | 默认值 |
8768| ------| ------| ------| --------|
88- | ` --format ` | ` -f ` | 输出格式 (table, json, yaml, tree) | ` table ` |
89- | ` --output ` | ` -o ` | 输出文件路径 | - |
90- | ` --recursive ` | ` -r ` | 递归比较目录 | ` false ` |
91- | ` --stats ` | ` -s ` | 显示统计信息 | ` false ` |
69+ | ` --output <format> ` | ` -o ` | 输出格式 (table\| json\| yaml\| tree) | ` table ` |
70+ | ` --output-file <path> ` | - | 将结果写入文件 | - |
71+ | ` --show-unchanged ` | ` -u ` | 显示未更改的值 | ` false ` |
72+ | ` --ignore-order ` | ` -i ` | 忽略数组顺序 | ` false ` |
73+ | ` --depth <number> ` | ` -d ` | 最大比较深度 | ` 10 ` |
74+ | ` --filter <pattern> ` | ` -f ` | 路径过滤正则表达式 | - |
75+ | ` --stats ` | ` -s ` | 显示统计信息 | ` true ` |
9276| ` --no-color ` | - | 禁用颜色输出 | ` false ` |
93- | ` --help ` | ` -h ` | 显示帮助信息 | - |
94- | ` --version ` | ` -v ` | 显示版本信息 | - |
77+ | ` --verbose ` | ` -v ` | 详细输出 | ` false ` |
9578
9679## 输出格式示例
9780
@@ -127,10 +110,10 @@ Statistics:
127110 }
128111 ],
129112 "summary" : {
130- "total" : 4 ,
131113 "added" : 1 ,
132114 "removed" : 1 ,
133- "modified" : 2
115+ "modified" : 2 ,
116+ "unchanged" : 0
134117 }
135118}
136119```
@@ -431,10 +414,13 @@ json-diff file1.json file2.json --verbose
431414| 选项 | 简写 | 描述 | 默认值 |
432415| ------| ------| ------| --------|
433416| ` --output <format> ` | ` -o ` | 输出格式 (table\| json\| yaml\| tree) | table |
417+ | ` --output-file <path> ` | - | 将结果写入文件 | - |
434418| ` --show-unchanged ` | ` -u ` | 显示未更改的值 | false |
435419| ` --ignore-order ` | ` -i ` | 忽略数组顺序 | false |
436420| ` --depth <number> ` | ` -d ` | 最大比较深度 | 10 |
437421| ` --filter <pattern> ` | ` -f ` | 路径过滤正则表达式 | - |
422+ | ` --stats ` | ` -s ` | 显示统计信息 | true |
423+ | ` --no-color ` | - | 禁用颜色输出 | false |
438424| ` --verbose ` | ` -v ` | 详细输出 | false |
439425| ` --help ` | ` -h ` | 显示帮助信息 | - |
440426| ` --version ` | ` -V ` | 显示版本信息 | - |
@@ -535,4 +521,4 @@ mudssky
535521
536522## 贡献
537523
538- 欢迎提交 Issue 和 Pull Request!
524+ 欢迎提交 Issue 和 Pull Request!
0 commit comments