title: Convert the groovy map's key value pair to JSON array elements
body: <p>How to take in key/value pair values of groovy map and loop into JSON array elements in groovy?.</p>
  
  <p>For example:</p>
  
  <p><strong>Input</strong>: </p>
  
  <p>def childmap = ["data1": "123", "data2": "234", "data3": "456"]</p>
  
  <p>def childmap2= ["data4": "123", "data5": "234", "data6": "456","date7":"676"]</p>
  
  <p>def parentmap=          ["Key1":"Value1","Key2":"Value2","Key3":childmap,"key4":childmap2]</p>
  
  <p><strong>Expected JSON Output</strong>:</p>
  
  <pre><code>{
   "Json":{
     "Key1":"Value1",
     "Key2":"Value2"
     "key3":[
        {
           "Name": "data1",
           "ID": "123"
        },
        {
           "Name": "data2",
           "ID": "234"
        },
        {
            "Name": "data3",
            "ID": "456"
        }
     ],
    "key4":[
        {
           "Name": "data4",
           "ID": "123"
        },
        {
           "Name": "data5",
           "ID": "123"
        },
        {
           "Name": "data6",
           "ID": "234"
        },
        {
            "Name": "data7",
            "ID": "456"
        }
     ]
  }
  </code></pre>
  
  <p>}</p>