【发布时间】:2020-07-08 10:23:26
【问题描述】:
我想使用来自deepdash(任何其他解决方案也可以)的 filterDeep 来过滤下面的数据,以使判决汇总保持不变。
{
"diff": [
{
"actual": "parent1",
"expected": "parent1",
"match": true,
"children": [
{
"actual": "child1",
"expected": "child1",
"match": true,
"children": [
{
"actual": "grandchild1",
"expected": "grandchild1_NOT",
"match": true
}
]
},
{
"actual": "child2",
"expected": "child2",
"match": true,
"children": [
{
"actual": "C2_grandchild1",
"expected": "C2_grandchild1",
"match": true
},
{
"actual": "C2_grandchild2",
"expected": "C2_grandchild2_NOT",
"match": false
}
]
}
]
}
]
}
json的简单视图如下:
我想以这样一种方式过滤掉,因为 C2_grandchild2 失败(匹配:false),json 应该包含 parent1--> child2-->C2grandchild2。我试图通过显示其父层次结构来突出失败。所以 child1、grandchild1 和 C2_grandchild1 也不存在于过滤的 json 中
我已经尝试了示例here,但似乎无法很好地理解它以实现这一目标
PS:json 大部分时候都很大很深。
【问题讨论】:
标签: javascript json reactjs lodash