Reputation: 53
I want to extract JSON block where it satisfies multiple conditions. For example, extract a block which has variables with two or more desired value. Please see below given example.
[
{
id:"1",
name:"ABC",
appName:"XYZ",
state:"New",
appType:"owner",
date:"May 12"
},
{
id:"2",
name:"DEF",
appName:"UVW",
state:"In Progress",
appType:"manager",
date:"May 13"
},
{
id:"3",
name:"GHI",
appName:"RST",
state:"In Progress",
appType:"owner",
date:"May 12"
}
]
From the above JSON, I want to extract the JSON block where state:"In Progress" and appType:"Owner"; i.e. the following block:
{
id:"3",
name:"GHI",
appName:"RST",
state:"In Progress",
appType:"owner",
date:"May 12"
}
I've been using JSON Extractor where I put JSON Path expressions:
$.[?(@.state == "In Progress") && ?(@.appType== "owner")]
But it doesn't extract any result. Is there any "AND/&&" condition to extract that particular block. Please help!
Thanks, Sid
Upvotes: 1
Views: 1699
Reputation: 307
Try this way:
$..[?(@.state=="In Progress" && @.appType=="owner")]
this will give you the desired block from array.
Upvotes: 2