Forum Discussion

SK07's avatar
SK07
Contributor
7 years ago

Groupby using groovy

I want to display by groupby item and count the rate using groovy in ReadyAPI.(Like this: Item 12: Count(Rate) : 400

Json1 : {"prods": [{"Item":"11","rate": 100},{Item":"12","rate":200},{Item":"12","rate":200}]}. 

    • SK07's avatar
      SK07
      Contributor

      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}]},
      {"Item":13,"rate":200, "Ids": [ {"level": 1}]},
      {"Item":12,"rate":200, "Ids": [ {"level": 2} ], [{"level": 2}, {"level": 2}]} ]}.

      def jsonids = json.Ids
      log.info jsonids
      [[], [], [1], [1], [2, 2, 2]]

      I tried and couldnt seperate...Any help is appreciated.