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 Contributor7 years agoHi 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_TAlumni 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_TAlumni 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,
Recent DiscussionsDate as a Global propertyTestcase Report in teardown scriptReadyAPI 3.65 – Confirmation of bundled Log4j version and remediation guidance
Related ContentGroovy script to count JSON elements found by a JSONPath queryArray null valuesNull Value testing