title: Wiremock variable substitution in JSON response
body: <p>I am trying to configure Wiremock mappings to return a JSON response with a value from the request.</p>
  
  <p>The request is simply</p>
  
  <pre><code>{ "clientTag": "123" }
  </code></pre>
  
  <p>And the mapping for it is:</p>
  
  <pre><code>{
    "priority": 4,
    "request": {
      "method": "POST",
      "urlPattern": "/test"
    },
    "response": {
      "status": 200,
      "body": "{ \"loginId\": \"${loginId}\" }",
      "headers": {
        "Content-Type": "application/json"
      }
    },
    "captures" : [ {
              "source" : "BODY",
              "target" : "loginId",
              "pattern" : "$..clientTag",
              "captureGroup" : 1
    } ]
  }
  </code></pre>
  
  <p>I receive the response:</p>
  
  <pre><code>{ "loginId": "" }
  </code></pre>
  
  <p>while the expected one is:</p>
  
  <pre><code>{ "loginId": "123" }
  </code></pre>
  
  <p>If I switch to XML requests, everything works fine with the pattern <code>&lt;clientTag&gt;(.*?)&lt;/clientTag&gt;</code>, but I would like to stick to JSON.</p>
  
  <p>Unfortunately Wiremock documentation is scarce hence the question. Any ideas? </p>
  
  <p>UPDATE: If someone is reading this later, you'd do best to use the transforms in the code, which are available in the later Wiremock versions.</p>