title: Cannot Transform Correctly with Elasticsearch Watcher {{ctx.payload.hits.hits}}
body: <p>I have a watcher configuration as follows:</p>
  
  <pre><code>{
    "trigger": {
      "schedule": {
        "interval": "5s"
      }
    },
    "input" : {
      "search" : {
        "request" : {
          "indices" : [ "my_index" ],
          "types" : [ "my_type" ],
          "body" : {
            "query" : {
              "match_all" : {}
             }
          }
        }
      }
    },
    "transform" : {
        "script" : "return [ body: groovy.json.JsonOutput.toJson(ctx.payload.hits.hits)]"
    },
    "actions" : {
      "hbase_webhook" : {
          "webhook" : {
              "method" : "POST",
              "host" : "&lt;some_ip&gt;",
              "port" : &lt;some_port&gt;,
              "path": "/v0.1/_events",
              "body" : "data: {{ctx.payload.body}}"
          }
      }
    }
  }
  </code></pre>
  
  <p>The data posted in the body is not a valid JSON: Something like:</p>
  
  <pre><code>{ 'data: ': { '{"_index":"my_index","_type":"my_type","_source":{"key":"val"}},"_id":"&lt;some_id&gt;","_score":1.0}': '' } }
  </code></pre>
  
  <p>I don't know how to parse this output as JSON.parse in Node.js won't correctly parse it anyway.</p>