$w = $wallets | ConvertTo-Json -Depth 3
{
"result": {
"wallets": [
{
"name": "W1"
},
{
"name": "W2"
},
{
"name": "W3"
},
{
"name": "W4"
}
]
},
"error": null,
"id": "test"
}
I want to check if the JSON response above contains wallet name "W1". So I wrote this in PowerShell which doesn't work:
if ($w.wallets.name -contains "W1") {
Write-Host "Wallet 'W1' exists"
}
How do I check something in above JSON using PowerShell?
ConvertFrom-Jsonif($json.result.wallets.name -contains 'W1'){...}