I cannot seem to figure out the best approach to parsing this API. JSONPath doesn’t seem to do what I need, unless I am misunderstanding the documentation. Could anyone suggest an approach?
Assuming your json string is in a variable named s
Something like this will tell you how many elements are in the JSON array.
val int numElements = Integer.parseInt(transform("JSONPATH", "$.length()", s))
logInfo("test", "There are {} elements in array", numElements)
Then you can iterate over the array elements like this.
var int i
var String key
var String value
for (i=0; i < numElements; i++) {
key = transform("JSONPATH", "$.[" + i + "].key", s)
value = transform("JSONPATH", "$.[" + i + "].value", s)
logInfo("test", "key:value={}:{}", key, value)
}