#json-diff #patch #json #diff #patch-file #json-file

jsonpatch_rs

Rust中的JSON Patch实现

1个不稳定版本

0.1.0 2023年3月12日

#10 in #patch-file


jsondiffpatch_rs 中使用

MIT 许可证

25KB
574 代码行

补丁

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"
}

依赖

~0.8–1.8MB
~37K SLoC