How to get size of element in API Response

guys, need help to get number/length of element in api response
i tried to use java int sizeOfList = “results.so_number.size()”; , but it doesn’t work. pls help, thank you

If your response is in JSON format, then you can use below groovy scripts to get its size:

def results = new groovy.json.JsonSlurper().parseText( response.getResponseBodyContent() )
println results.size()

Hi @“Vinh Nguyen” , thank you.

import groovy.json.JsonSlurper
responseData = WS.sendRequest(findTestObject("POST RESTFUL"));
responseText = responseData.getResponseText();
def json = new JsonSlurper().parseText(responseText)
println json.results.size();

every time I run I got err msg : _**there are errors in the script, **_but it works and i got correct element size.

seems like “results” is wrong (json.results.size();), because it got underline. CMIIW :slight_smile: