Currently the writeJSON step is only able to output the json to a file. However, sometimes we need the resulting json as a string in Groovy. The only workaround is either to write to some temp file and then call readJSON, or to directly call into JSONObject, neither of which is ideal.
I propose adding a boolean returnText parameter to writeJSON. If it is omitted or false, then writeJSON preserves its existing behavior. If it is true, then file must not be specified and writeJSON will return the json as a string.
String json = writeJSON json: object, returnText: true