If you're using a groovy step script, you can do it like this:
import groovy.json.JsonSlurper
testStep = testRunner.testCase.testSteps["YourApiRequestStep"]
def Response = testStep.getProperty("response").value;
def someFieldYouWantToSave = ""
if (Response == null) {
log.error('No Response found.');
}
else {
def jSlurper = new JsonSlurper();
def json = jSlurper.parseText(Response);
if (json.get("theFieldFromTheResponse") == null){
log.error "TheFieldFromTheResponse not found in response. Please execute the teststep and try again"
} else {
someFieldYouWantToSave = json.get("theFieldFromTheResponse").toString()
// YOUR LOGIC HERE FOR MODIFYING THE "someFieldYouWantToSave" value
//SAVE THE FIELD
testRunner.testCase.setPropertyValue("someFieldYouWantToSave", someFieldYouWantToSave)
}
}
Keep in mind that you can always see what context variables you can use by looking in the upper - right location of the script window. For example, if you're using a Groovy Script step, the variables are: log, context and testRunner. If you try to use the above example somewhere else, like in the test case assertion script, it won't work since that one is invoked with log, context and messageExchange. You can find out how to grab the values from various places in your project by taking a look at the examples from the documentation
With these 3 pieces of information, you should be able to achieve your goal, regardless of the place you're using it.