将 json 写入文件

import groovy.json.JsonOutput;

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