How to count length of response in new syntax

I am struggling with the new syntax and would need your input. How can you write below test with pm? (the new syntax)

responseJson = JSON.parse(responseBody);
tests["Nr of plans returned = " +responseJson.length] = responseJson.length === 2;

I appreciate your help!

Hey @captain_hoy, here’s how you can achieve what you want with the new pm.* syntax.

var data = pm.response.json();

pm.test('Number of plans returned = ' + data.length, function () {

In case you want to check the count of keys in a JSON object, simply replace data with Object.keys(data) and you’ll be good to go.

Also, you can access the complete API reference here in case you would like to check it out. Hope this helps.