1 个不稳定版本
0.1.0 | 2023年3月12日 |
---|
#10 in #json-diff
75KB
1.5K SLoC
jsondiffpatch.rs
比较和修补JSON对象。
用法
USAGE:
jsondiffpath-cli <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
SUBCOMMANDS:
diff diff two json file
help Print this message or the help of the given subcommand(s)
patch patch a json object with a patch document
diff
diff two json file
USAGE:
jsondiffpath-cli diff <LEFT_JSON> <RIGHT_JSON>
ARGS:
<LEFT_JSON>
<RIGHT_JSON>
OPTIONS:
-h, --help Print help information
例如。
LEFT_JSON
{
"bar": [
1, 2, 3
],
"foo": 10
}
RIGHT_JSON
{
"bar": [
2, 3, 4
],
"foo": 11
}
diff
patch
USAGE:
jsondiffpath-cli patch <ORIGINAL_JSON> <PATCH_JSON>
ARGS:
<ORIGINAL_JSON>
<PATCH_JSON>
OPTIONS:
<ORIGINAL_JSON> 是应用补丁的基础文件
<PATCH_JSON> 是要应用到基础JSON的补丁文件(遵循JSON-Patch RFC6902)
jsondiffpatch-cli patch [left.json] [right.json]
例如。
ORIGINAL_JSON
{
"foo": "Hello World",
"bar": "Unknown"
}
PATCH_JSON
[
{ "op": "replace", "path": "/foo", "value": "new value" },
{ "op": "add", "path": "/baz", "value": "added value" },
{ "op": "remove", "path": "/bar" }
]
结果
{
"baz": "added value",
"foo": "new value"
}
依赖项
~3–11MB
~107K SLoC