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 - Project 1",
appName:"XYZ",
state:"New",
appType:"owner",
date:"May 12"
},
{
id:"2",
name:"DEF - Project 2",
appName:"UVW",
state:"In Progress",
appType:"manager",
date:"May 13"
},
{
id:"3",
name:"GHI - Project 3",
appName:"RST",
state:"In Progress",
appType:"owner",
date:"May 12"
},
{
id:"4",
name:"JKL - Project 4",
appName:"OPQ",
state:"Expired",
appType:"entity owner",
date:"July 13"
}
]
From the above JSON, I want to extract the JSON block where state:"In Progress" or state:"New", either of these states and it should of appType:"Owner" along with name:... Project 1; i.e. the following blocks as output:
{
id:"1",
name:"ABC - Project 1",
appName:"XYZ",
state:"New",
appType:"owner",
date:"May 12"
}
Which JSON Path expressions whould I use to extract:
$.[?((@.state == "In Progress" || @.state == "New") && @.appType== "owner" && <some regex expression>)]
But it doesn't extract any result. Is there any way to use multiple conditions for "OR/||" and "AND/&&" condition to extract that particular block. Please help!
Thanks, Sid
