title: Jenkinsfile pipeline construct JSON object and write to file
body: <p>I would like to construct a JSON object and write the content to file.</p>
  
  <p>Originally I was inspired by <a href="https://stackoverflow.com/questions/44707265/jenkins-pipeline-groovy-json-parsing">this</a> and tried:</p>
  
  <pre><code>def data = [
          a:"test: ${myVar}"
      ]
      writeJSON(file: 'message1.json', json: data)
  </code></pre>
  
  <p>But this failed with:</p>
  
  <blockquote>
    <p>Could not instantiate {file=message1.json, json={a=test}} for WriteJSONStep(file: String, json: JSON{}, pretty?: int): java.lang.UnsupportedOperationException: must specify $class with an implementation of interface net.sf.json.JSON</p>
  </blockquote>
  
  <p>So next I tried:</p>
  
  <pre><code>def data = readJSON text: '{}'
  data.a = "test: ${myVar}"
  writeJSON(file: 'message1.json', json: data, pretty: 4)
  </code></pre>
  
  <p>Now the build passes, but the content of the file looks like:</p>
  
  <pre><code>{
       "a":     {
  
          "bytes":         [
  
              114,
  
              101,
  
              108,
  
              101,
  
              97,
  
              115,
  
              101
  
              50
  
          ],
  
          "strings":         [
  
              "test: ",
  
              ""
  
          ],
  
          "valueCount": 1,
  
          "values": ["v1.0.2"]
  
      }
  }
  </code></pre>
  
  <p>Whereas my intention was <code>{"a": "test: v1.0.2"}</code></p>
  
  <p>My end goal is that I want to dynamically construct a JSON object, set some properties with some dynamic data and then write the JSON file.</p>
  
  <p>Is there some syntax that can be used to assign the values as strings, rather than some bytes.</p>