Forum Discussion
Hi SK07,
I believe you should can get solution from scripts which I replied to you in your previous topic, right?
firstly, you should parse json string as a json object, right? you should do this at first step.
secondly, retrieve 'Ids' and get content. (if "Ids" 's value is always like []. if not, you can add a 'if' condition to determine, like: if(a instanceof ArrayList), a means Ids' value)
thirdly, you also get all values of Ids, so you can count the numer of them.
If any enquires, please post your questions here
Regards,
/Aaron
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