简体   繁体   中英

JMeter: JSON Extractor - Extract using multiple conditions

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"; ie 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

Try this way:

$..[?(@.state=="In Progress" && @.appType=="owner")]

this will give you the desired block from array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM