writeJson step to serialize to string variable

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      the writeJSON step currently only allows for serialization of a variable object (map, list etc) to file, but for certain operations (such as executing an adhoc curl), it would be nice if you could serialize to a string and then use that as part of the call.

      For example:

      sh (script: "curl -s http://localhost/rpc -d '{ \"field1\": 123 }' -H 'Content-Type: application/json'")

      Could be re-written as:

      def bodyMap = readJSON text: '{}'
      bodyMap.field1 = 123 
      def jsonStr = writeJSON json: bodyMap
      sh (script: "curl -s http://localhost/rpc -d '${jsonStr}' -H 'Content-Type: application/json'")

      Granted you could just serialize to file and then pass that file to the curl command.

            Assignee:
            rsandell
            Reporter:
            Chris White
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: