I would like to extract multiple properties from a specific object in a response array. I am using jmesPath
and saveAs
within a check
.
Example Data:
{
"fruits":[
{
"type": "pineapple",
"size": "medium",
"price": 6
},
{
"type": "watermelon",
"size": "large",
"price": 10
},
{
"type": "apple",
"size": "small",
"price": 2
},
{
"type": "pear",
"size": "small",
"price": 2
},
]
}
Using JmesPath I can select the apple object out of this list. I want to be able to save the size
, and price
, properties for later use.
I know I can use multiple jmesPath and save the data in the form
.check(
jmesPath("pathToAppleProperty").find().saveAs("propertyName")
)
Within this example I can see the simplicity of that. However, with my real work data, It would be very convenient to save the object I find, and then pull out the properties I need.
.check(
jmesPath("pathToApple").find().saveAs("fruitObject")
)
.exec(session -> {
String size = session.getString(fruitObject)["size"]
int price = session.getString(fruitObject)["price"]
})
What is the best way to pull out specific properties from a specific object in a response array?