Conditional jsonpath expression:
$.[?(@.identifier == "369")]..columns.[?(@.type == "relationship")].token
import groovy.json.JsonSlurper
JsonSlurper slurper = new JsonSlurper()
Map parsedJson = slurper.parseText(prev.getResponseDataAsString())
//String idval = parsedJson.sections[1].id
//String idval = parsedJson.[?(@.identifier == "369")]..columns.[?(@.type == "relationship")].token //trail 01 -failed at .[
String idval = parsedJson./[?(@.identifier == "369")]/..columns./[?(@.type == "relationship")]/.token //trail 02 -no such property: columns for class
log.info(""+idval);
You cannot use JSON Path expressions with the JsonSlurper, consider either using find()/ findAll() functions on the returned collection or moving to JsonPath instead
def idval = com.jayway.jsonpath.JsonPath.read(prev.getResponseDataAsString(), '?($..sections[@.identifier == "369")]..columns.[?(@.type == "relationship")]')
More information: Apache Groovy - Why and How You Should Use It