我正在尝试为对象列表连接两个属性。
{
"image": "golang:1.3",
"unapproved": [
"CVE-2016-5421",
"CVE-2019-5010"
],
"vulnerabilities": [
{
"featurename": "curl",
"featureversion": "7.38.0-4+deb8u2",
"vulnerability": "CVE-2016-5421",
"namespace": "debian:8",
"description": "Use-after-free vulnerability in libcurl before 7.50.1 allows attackers to control which connection is used or possibly have unspecified other impact via unknown vectors.",
"link": "https://security-tracker.debian.org/tracker/CVE-2016-5421",
"severity": "High",
"fixedby": "7.38.0-4+deb8u4"
},
{
"featurename": "python2.7",
"featureversion": "2.7.9-2",
"vulnerability": "CVE-2019-5010",
"namespace": "debian:8",
"description": "Test description",
"link": "https://security-tracker.debian.org/tracker/CVE-2019-5010",
"severity": "Unknown",
"fixedby": ""
}
]
}
顶级
image
属性应用作description
列表中每个对象的vulnerabilities
。
{
"image": "golang:1.3",
"unapproved": [
"CVE-2016-5421",
"CVE-2019-5010"
],
"vulnerabilities": [
{
"featurename": "curl",
"featureversion": "7.38.0-4+deb8u2",
"vulnerability": "CVE-2016-5421",
"namespace": "debian:8",
"description": "golang:1.3 - Use-after-free vulnerability in libcurl before 7.50.1 allows attackers to control which connection is used or possibly have unspecified other impact via unknown vectors.",
"link": "https://security-tracker.debian.org/tracker/CVE-2016-5421",
"severity": "High",
"fixedby": "7.38.0-4+deb8u4"
},
{
"featurename": "python2.7",
"featureversion": "2.7.9-2",
"vulnerability": "CVE-2019-5010",
"namespace": "debian:8",
"description": "golang:1.3 - Test description",
"link": "https://security-tracker.debian.org/tracker/CVE-2019-5010",
"severity": "Unknown",
"fixedby": ""
}
]
}
我当前的过滤器:
{image, unapproved, vulnerabilities: [{description: (.image + " - " + .vulnerabilities[].description)}] }
{
"image": "golang:1.3",
"unapproved": [
"CVE-2016-5421",
"CVE-2019-5010"
],
"vulnerabilities": [
{
"description": "golang:1.3 - Use-after-free vulnerability in libcurl before 7.50.1 allows attackers to control which connection is used or possibly have unspecified other impact via unknown vectors."
},
{
"description": "golang:1.3 - Test description"
}
]
}
不幸的是,我仅将description
字段与当前的过滤器一起返回。我想要具有修改后的description
字段的完整漏洞对象。
如何连接嵌套字段并保留对象的其他属性?
答案 0 :(得分:2)
最简单的解决方案可能是:
zonesViewModel.merchantInfoBottomLayout!!.state = BottomSheetBehavior.STATE_COLLAPSED
换句话说:如图所示,使用.image更新所有zonesViewModel.merchantInfoBottomLayout!!.state = BottomSheetBehavior.STATE_SETTLING
值。
等效地,也许更不深奥地:
.image as $prefix
| .vulnerabilities[].description |= $prefix + " - " + .