1

i am doing an automation script in which i m getting inner levels json and the keys are unknown to me so how can we parse the json so that it convert the json into a map with key value pairs it contains the json array as well as json object i want to create them separately so that we can distinguish b/w these.

i m having a json format as-:

{  
   "seatbid":[  
      {  
         "bid":[  
            {  
               "id":"1",
               "impid":"1",
               "price":3.5999999046325684,
               "nurl":"abc.com",
               "adomain":[  
                  "zagg.com",
                  "zagg.com"
               ],
               "iurl":"abc.com",
               "crid":"30364.s320x50m",
               "h":0,
               "w":0
            }
         ],
         "group":0
      }
   ],
   "cur":"USD",
   "nbr":0
}

my code is as follows but its not working at all because the key values i have to enter to get the values -:

 def respSlurper = new JsonSlurper()
 def respJson = respSlurper.parseText(content)
 log.info(respJson.keySet())
 log.info(respJson.values())
 log.info(respJson.get("seatbid"))` 
Gergely Toth
  • 6,638
  • 2
  • 38
  • 40
naval dogra
  • 9
  • 1
  • 7

0 Answers0