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 countFetch the row count in DDT driver
Recent DiscussionsAssert Step Not Executing All AssertionsInclude external files (XML) for JDBC connectionAccessing database connection string from groovy test stepJDBC database connection poolingJDBC "Some connection settings are not specified"