【发布时间】:2021-01-04 19:35:59
【问题描述】:
我有一些 JSON(我们称之为 json1),我想将它与其他一些 JSON (json2) 结合起来。我不只是想合并或附加数据,我还希望能够通过在json2 中嵌入“命令”来删除json1 中的数据。
例子
json1 = {
"a": 1,
"b": "xyz",
"c": ["foo", "bar"]
}
json2 = {
"b": "hello world",
"d": 4,
"c": ["-foo", "+foobar"],
}
output = combine(json1, json2)
// Expected result from the fictional "combine()" method
output = {
"a": 1,
"b": "hello world",
"c": ["bar", "foobar"],
"d": 4
}
当然我可以提出自己的语法和逻辑,但我很好奇是否有任何现有的技术可以使用 JSON 来操作 JSON?
免责声明:我不是在问recommendations for books, tools, software libraries (or more)。我只有与a specific programming problem 相关的a practical, answerable problem that is unique to software development,并且正在询问software tools commonly used by programmers,或者可能是software algorithm。天哪。
【问题讨论】:
-
听起来像 JSON Patch 文档。 jsonpatch.com