Forum Discussion

richie's avatar
richie
Community Hero
6 years ago

Verify a repeating attribute in .json response appears in ascending and descending order

Hi,   I have a GET request that interacts with a database retrieving records based on the URI/Template and Query Parameters in the URI string submitted and the response returned is in .json type....
  • nmrao's avatar
    nmrao
    6 years ago

    richie ,

     

    Does the below helps?

     

    //Define the ordered list which is in the same order of the values as expected
    def expectedList = []
    
    def response = context.expand( '${REST Request#Response}' )
    def json = new groovy.json.JsonSlurper().parseText(response)
    
    assert expectedList == json.data.Name