Forum Discussion

fmensah's avatar
fmensah
Occasional Contributor
5 years ago

Json response format assertion

Hello everybody,   I am looking for a way to find an assertion which could help me  check that I got the json schema in the exact order. Let'us look at the example below. I want an assertion whic...
  • HimanshuTayal's avatar
    5 years ago

    fmensah 

     

    You can verify the data by writing below in script assertion : 

    import groovy.json.JsonSlurper
    
    def response = messageExchange.responseContent
    
    def jsonSlurper = new JsonSlurper().parseText(response)
    
    assert jsonSlurper.message == "FLEET_ALREADY_EXISTS" : "Data for message is different"
    assert jsonSlurper.details == null : "Data for details is different"

     

    I don't think i order matter, what is your use case to match order.