Closed jgroom33 closed 6 years ago
Potential implementations or workarounds (assuming that modifying the request URL is not possible) :
Any other approaches?
JSONPath seems to be a good option: https://github.com/dchester/jsonpath#jpvalueobj-pathexpression-newvalue
This works:
$.phoneNumbers[?(@.type=="iPhone")].number
using:
http://jsonpath.com/
Presumed implementation JsonPath()
:
version: 1
requests:
todoOne:
url: https://jsonplaceholder.typicode.com/posts
method: POST
data:
json:
myArray:
- foo: 1
bar: 1
- foo: 2
bar: winner winner chicken dinner
todoTwo:
url: https://jsonplaceholder.typicode.com/posts
method: POST
data:
json:
baz: JsonPath(todoOne.$.myArray[?(@.foo==2)].bar # evaluates to: "winner winner chicken dinner"
Assume a request returns:
It would be beneficial to extract the value of key
bar
given a value for foo.This is typically handled in code using loops or find functions.