【发布时间】:2021-07-19 07:29:24
【问题描述】:
每个人。
我想我的问题很简单。
我的用例:
Jenkins 从 Gitlab WebHook 接收到一个巨大的 JSON 负载(超过 2500 行)。我想摆脱超过 2000 行的特定节点。我得到的 JSON 太大了,Jenkins 无法正确解析它,所以我想删除一个我不需要的节点。
假设documentation page中的样本树:
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
除了一棵树外,我怎样才能得到整棵树?例如,如果我想获取除 book 节点之外的所有内容...
{
"store": {
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
我或多或少地了解过滤器功能,并且我认为我需要找出一个合适的过滤器,但似乎它们仅对根据某些条件搜索节点有用。我不确定它们是否有助于根据过滤条件删除元素。
非常感谢您的帮助。
【问题讨论】: