Forum Discussion

SankarB's avatar
SankarB
Occasional Contributor
7 years ago
Solved

How to get the item count

Hi,   How do i get the count of items for the below JSON response    { "@type": "com.a.common.model.dto.CollectionDTO", "id": null, "items": [ { "@type": "com.a.b.client.model.dto.Asset", ...
  • nmrao's avatar
    7 years ago

    Add Script Assertion with below code:

     

    assert context.response, "Response is empty or null"
    
    def json = new groovy.json.JsonSlurper().parseText(context.response)
    log.info json.items.size()
    
  • groovyguy's avatar
    groovyguy
    7 years ago

    Try replacing [i] with [$i] to reference the value as a number instead of a string.