1

I am trying to extract some particular fields from json list response
following snapshot shows the json expression enter image description here

Below image is my response: enter image description here

How can i store this response i.e., name and id to a csv file. please suggest the best solution.

Thanks in advance!!

user2319276
  • 47
  • 1
  • 5

1 Answers1

1

You can go for JSR223 Listener and Groovy language, the relevant code would be something like:

1.upto(vars.get('enrolledDevices_matchNr') as int, { idx ->
    def enrolledDevice = new groovy.json.JsonSlurper().parseText(vars.get('enrolledDevices_' + idx))
    new File('myfile.csv') << enrolledDevice.name << ',' << enrolledDevice.id << System.getProperty('line.separator')
})

More information: Groovy Parsing and producing JSON

Dmitri T
  • 159,985
  • 5
  • 83
  • 133