下面是API调用之一的JSON输出,现在需要基于名称值获取日期,例如想要迭代JSON文件并查找等于1.0的名称变量值,然后日期为2018-12-13T18:04:42-0500
。
VERBOSE: {
"paging": {
"pageIndex": 1,
"pageSize": 100,
"total": 2
},
"analyses": [
{
"key": "xxxx",
"date": "2019-06-07T18:04:56-0400",
"events": [
{
"key": "xxxxxx",
"category": "VERSION",
"name": "01.00"
}
]
},
{
"key": "yyyyyy",
"date": "2018-12-13T18:04:42-0500",
"events": [
{
"key": "yyyyyy",
"category": "VERSION",
"name": "1.0"
}
]
}
]
}
答案 0 :(得分:0)
假设您将整个JSON文本包含在一个字符串变量中,例如$Json
,这对您有用吗?
$obj = $Json | ConvertFrom-Json
$obj.analyses | ForEach-Object { if ($_.Events.Name -eq "1.0"){$_.Date}}