我想从一个json中获取值并传递给另一个json。我只需要几个参数,如name,severity,range,cwe,cvssand fixAvailable。这是我的json文件:
{
"auditReportVersion": 2,
"vulnerabilities": {
"@babel/traverse": {
"name": "@babel/traverse",
"severity": "critical",
"isDirect": false,
"via": [
{
"source": 1094446,
"name": "@babel/traverse",
"dependency": "@babel/traverse",
"title": "Babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code",
"url": "https://github.com/advisories/GHSA-67hx-6x53-jw92",
"severity": "critical",
"cwe": [
"CWE-184",
"CWE-697"
],
"cvss": {
"score": 9.3,
"vectorString": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
},
"range": "<7.23.2"
}
],
"effects": [],
"range": "<7.23.2",
"nodes": [
"node_modules/@babel/traverse"
],
"fixAvailable": true
}
}}
字符串
我想要这样的文件:
{
"auditReportVersion": 2,
"vulnerabilities": {
"@babel/traverse": {
"name": "@babel/traverse",
"severity": "critical",
"range": "\<7.23.2",
"fixAvailable": true
}
}
}
型
需要帮助..谢谢
1条答案
按热度按时间iyfjxgzm1#
这里是你可以做到这一点的方法之一,使用
ConvertFrom-JSON
小工具将JSON输入转换为一个对象,然后创建一个具有所需属性设置的自定义对象,如果你想在JSON中使用它,你可以使用$obj | ConvertTo-JSON
小工具。字符串