Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-63720

add returnText option to writeJSON

XMLWordPrintable

    • 2.7.0

      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.

      Example usage:

      String json = writeJSON json: object, returnText: true

       

            rsandell rsandell
            rittneje Jesse Rittner
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: