jsonsoapuijson-path-expression

How to ignore the dynamic value in the JSONPath Expression of SoapUI while only validate against the rest complete payload?


I want to validate the JSON response of all key value pair except the timestamp which is Dynamics. Either I have to write multiple JSONPath Expression assertions or can achieve this in one assertion?

Only want to ignore timestamp value match and rest all should match.

enter image description here


Solution

  • Use script assertion to validate the required fields in response.

    // Read response
    def response=messageExchange.response.responseContent
     // Parse json Response
    def jsonSul=new JsonSlurper().parseText(response)
    
    def actualEnvironment = jsonSul.environment
    def actualMessage = jsonSul.message
    // add all required fields
    
    def expectedEnvironment = "qa" // You can read from Properties file as well depends where you are storing the expected results.
    
    // Validate
    assert expected==actual