SK07Contributor7 years agoGroovy- count all nulls in an array I want to print how many nulls, 1's and 2's seperately. Json : {"prods": [{"Item":13,"rate":200, "Ids": []}, {"Item":13,"rate":200, "Ids": []}, {"Item":11,"rate": 100, "Ids": [ {"level": 1}]}, ...Show More
aaronpliuFrequent Contributor to SK07Hi SK07, Dont think of it to be complex. If you only wanna count the number of "[]", try // your list aa=[[], [], [1,1],[2,2,2]] def num = 0 for(item in aa){ if(item.size() < 1) num++ } log.info "[Ids []: $num]" Regards, /Aaron
Olga_TSmartBear Alumni (Retired) to SK077 years agoaaronpliu, thanks for your help in sorting this out! SK07, do I get it right that the suggestion below helps? If so, could you please Accept it as Solution in order for other users to find it easier?Thank you in advance,
Olga_TSmartBear Alumni (Retired) to SK077 years agoaaronpliu, thanks for your help in sorting this out! SK07, do I get it right that the suggestion below helps? If so, could you please Accept it as Solution in order for other users to find it easier?Thank you in advance,
Related ContentGroovy script to count JSON elements found by a JSONPath queryArray null valuesNull Value testingsubitem countGroovy Script for assertion to check whether the value is 0 or null in groovy script response
Recent DiscussionsGroovy script to access network domain nameReadyAPI Docker Image COMMAND_LINE -I option is being ignoredAMQP - Cannot connect to ActiveMQ with AMQP PluginSolvedmore screen real estate by moving the Testcase progress barJSON Schema Compliance URL