【发布时间】:2017-01-21 22:24:11
【问题描述】:
我在 PowerShell 中调用 REST api,它返回一些 JSON
$records = Invoke-RestMethod $uri -Headers $headers
如果我使用 .data 属性,我会得到我假设的 PowerShell 数组对象,因为我可以检查 $records.data.count 并得到预期的记录数。检查其中一条记录,例如$records.data[5]
id : 123
zone_id : example.com
parent_id :
name : z1
content : 1.2.3.4
ttl : 3600
priority :
type : A
regions : {global}
system_record : False
created_at : 2015-01-10T02:33:46Z
updated_at : 2015-01-10T02:33:46Z
我想获取 type 为 A 的所有记录。我试过$records.data.Where($_.type -eq 'A') 但这给了我一个类型异常。我应该使用什么查询来根据属性值进行过滤?
【问题讨论】:
标签: json powershell