SK07Contributor8 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 Contributor8 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 SK078 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 SK078 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 DiscussionsReadyAPI 3.62.0 - com.jcraft.jsch.JSchAlgoNegoFailException: Algorithm negotiation failSolvedReadyAPI 3.62.0 - org.springframework.jdbc.BadSqlGrammarExceptionConnect ready API with JMS
Related ContentGroovy script to count JSON elements found by a JSONPath queryArray null valuesNull Value testing