groovy – Write a json to a file

import groovy.json.JsonOutput;

def json = JsonOutput.toJson([foo: 'bar', baz: [1]])
 
new File("/tmp/output.json").write(json)

if you want to reproduce, please indicate the source:
groovy – Write a json to a file - CodeDay