0

I have the below JSON response to be validated. I need to validate all the "createdDate" from all the Arrays irrespective. Is there any easy way to capture them or loop through them (since it has the same object name, but in different arrays) and put them in variables to do an assertion against their corresponding values from a JDBC response?

Right now I have used JSON Assertion for each and every "createdDate" using the JSON path to validate against the database value.

{
    "someobject1": 123,
    "Array1": 
    [
        {
            "someobject2": 2,
            "createdDate": "2019-03-26T20:29:44.631+0000",
            "someobject3": "SCRIPT1"
        },

        {
            "someobject4": 3,
            "createdDate": "2019-03-27T20:29:44.631+0000",
            "someobject5": "SCRIPT2"
        }
    ],

    "Array2": 
    [
        {
            "someobject6": 4,
            "createdDate": "2019-03-28T20:29:44.631+0000",
            "someobject7": "SCRIPT3"
        },

        {
            "someobject8": 5,
            "createdDate": "2019-03-29T20:29:44.631+0000",
            "someobject9": "SCRIPT4"
        }
    ]
}

1 Answer 1

1

You can use JSON Assertion configured like:

  • Assert JSON Path Exists: $..createdDate
  • Expected Value: ["2019-03-26T20:29:44.631+0000","2019-03-27T20:29:44.631+0000","2019-03-28T20:29:44.631+0000","2019-03-29T20:29:44.631+0000"]

Full configuration:

enter image description here

More information:

Sign up to request clarification or add additional context in comments.

1 Comment

Is it possible to compare it one to one. In case if one of them fails, can any of the listeners tell?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.