Forum Discussion
Hi Aaron, This is something different from previous with inner loops.
Json : {"prods": [{"Item":13,"rate":200, "Ids": []},
{"Item":14,"rate":300, "Ids": []},
{"Item":15,"rate":100, "Ids": [ {"level": 1}]},
{"Item":16,"rate":700, "Ids": [ {"level": 1}]},
{"Item":17,"rate":500, "Ids": [ {"level": 2} ], [{"level": 2}, {"level": 2}]} ]}.
So, I retrieve the Ids as below:
def jsonids = json.Ids
log.info jsonids
[[], [], [1], [1], [2, 2, 2]]
But I dont how to read/count the above and get the results like below:
Ids [] =: 2, Level 1 = 2, Level 2 = 3
Hi 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
- SK077 years agoContributor
Thank you! Aaron.
Related Content
- 6 years ago
- 7 years ago
- 3 years ago
- 2 years ago
Recent Discussions
- 5 days ago
- 10 days ago