I need to create a new CSV file by capturing 100s of array values retured as part of a JSON response Payload.
My response payload for a GET call:
{ "total": 5, "limit": 5, "results": [ 1273614, 1298245, 1298246, 1298247, 1298248 ] }
I need to capture what’s within the “results” array (e.g., 1273614, 1298245, 1298246, …) and create a csv file (e.g., userId.csv).
Thank you in advance.
I found one of the post (Click Here) which seems to have a solution, but my response payload is different than what’s in the original post.
I tried below:
new groovy.json.JsonSlurper().parse(prev.getResponseData()).results.each { entry -> new File('userId.csv') << entry.get('results') << System.getProperty('line.separator') }
Apologies for mistakes in my code above, I am rusty with my coding skills.