Write a JSON file in the
current working directory. That for example was previously read by readJSON
.
json
:
The object to write. Can either be a
JSON
instance or another Map/List implementation. Both are supported.
file
:
Path to a file in the workspace to write to.
pretty
(optional):
Prettify the output with this number of spaces added to each level of indentation.
Example:
def input = readJSON file: 'myfile.json'
//Do some manipulation
writeJSON file: 'output.json', json: input
// or pretty print it, indented with a configurable number of spaces
writeJSON file: 'output.json', json: input, pretty: 4