Test case to validate nested array with multiple values

Hi Everyone…

I want to validate some interest rates and term of one of use case…

Interest rates and term combination can be many in array and sequence is also not fixed.

“Test 1” :
“Account_number” : “123”,
“Card” : [
“Type” : “white”,
“Deatils” : [
“Term” = 12,
“Rate” = 8.99

“Term” = 24,
“Rate” = 9.99
} ,

Term" = 36,
“Rate” = 10.99
} ,

Sequence can change like 36/12/24.

Want to test with pm.expect but need help.

Thank you in advance

Hey @maintenance-archit11

Welcome to the Postman community :postman:

What have you tried so far? Do you have any tests that you can share?

Have you tried using Postbot to help with the test creation?

There’s a missed learning opportunity if someone just hands you some code to run. :sweat_smile:

Hi @danny-dainton.

Thank you for response.

I have tried to test but only able validate one term which ever coming first not able to do it dynamically.

And not used postbot yet.

Thank you

Please use the preformatted text option in the editor when pasting code of JSON as its stops everything from being aligned to the left. Can you also close out the JSON tags, so its valid JSON. This way, we can cut and paste into a request and send it to Postman Echo which will give us the same response to work with.

Postman uses JavaScript under the hood, so this is where you need to look for solutions.

The terms are under the “Details” array. You can use the JavaScript find or filter function to search for the term that you want to assert against.

Have a go at that. If you run into problems targetting the values, please post what code you’ve got, plus a valid JSON response and I will help you from there.