title: Mule- Extracting key from Json object using dataweave
body: <p>I need to extract key and values from json input object to form different json output. </p>
  
  <p>I went through the documentation and other questions asked similar to this where I could found out that $$ gives the key but, in my case it is giving me index but not the key name. </p>
  
  <p>The input json looks like this :<code>{
  "key2": "val2",
  "key3": "val3",
  "key4": "val4",
  "key5": "val5",
  "key6": "val6"
  }</code></p>
  
  <p>The dataweave code I have written is : </p>
  
  <pre><code>{
  "someOtherKey": "val",
  properties: {
      entry: payload map
  
       {  
          key:$$,
          value:$
       }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>After transformation I am getting : </p>
  
  <pre><code>{
   "someOtherKey": "val",
  "properties": {
      "entry": [
          {
              "key": 0,
              "value": "val2"
          },
          {
              "key": 1,
              "value": "val3"
          },
          {
              "key": 2,
              "value": "val4"
          },
          {
              "key": 3,
              "value": "val5"
          },
          {
              "key": 4,
              "value": "val6"
          }
      ]
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here I am expecting output with key name as value for <strong>Key</strong></p>
  
  <p>Expected output :</p>
  
  <pre><code>{
  "someOtherKey": "val",
  "properties": {
      "entry": [{
              "key": "key2",
              "value": "val2"
          },
          {
              "key": "key3",
              "value": "val3"
          },
          {
              "key": "key4",
              "value": "val4"
          },
          {
              "key": "key5",
              "value": "val5"
          },
          {
              "key": "key6",
              "value": "val6"
          }
  
      ]
  }
  </code></pre>
  
  <p>}</p>