SK07Contributor6 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 SK076 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 SK076 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 queryFetch the row count in DDT driverArray null valuessubitem countNull Value testing
Recent DiscussionsGroovyScript - Extract specific number of attribute values from variable content responseMultipart requests getting blocked by the Azure WAF 200003Multiple Kafka consumers performance testAutomated Regression / Health-checks?Solvedcommand line on how to retrieve license file ?