如何根据特定变量从嵌套JSON中获取特定变量值

How to get the specific variable value from nested JSON based on the specific variable

下面是 JSON 调用之一的 API 输出,现在需要根据名称值获取日期,例如要迭代 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"
                                        }
                                    ]
                     }
                 ]
}

假设您将整个 JSON 文本放在一个字符串变量中,比如 $Json,这对您有用吗?

$obj = $Json | ConvertFrom-Json
$obj.analyses | ForEach-Object { if ($_.Events.Name -eq "1.0"){$_.Date}}