0

To check if the Respondy Body has a string, I can use this:

tests["Body matches string"] = responseBody.has("string_you_want_to_search");

But I have a responseBody like this:

{  
 "total": 20000,
 "amount": {
   "total": 10000,
   "fees": 0,
   "refunds": 0,
   "liquid": 10000,
   "currency": "BRL"
 },
}

How can I check the field amount.total?

  • Possible duplicate of [postman jetpacks - testing for nested data](http://stackoverflow.com/questions/31161571/postman-jetpacks-testing-for-nested-data) – PMerlet Nov 18 '16 at 12:39
  • You can use `JSON.parse(responseBody)` – Aruna Nov 18 '16 at 12:51

1 Answers1

0

Use dot operator to test to access the nested value:

var data = JSON.parse(responseBody);
tests["10000"] = data.amount.liquid === "10000";
tests["BRL"] = data.amount.currency === "BRL";

Hope it helps!

Ankit0047
  • 144
  • 1
  • 10