Splitting the values of an array based on a property and then form a new array of objects : <p>I have an objects that contains arrays with following structure:</p>

<pre><code>var obj  = {
  "feature1" : ["val1","val2"],
  "feature2" : ["val3"]
}

</code></pre>

<p>Now I want to split the values that are present inside of this each array and form a new array of objects that should like :</p>

<pre><code>var result = [
  {
    "field": "feature1",
    "value": "val1",
    "type": "add"
  },
  {
    "field": "feature1",
    "value": "val2",
    "type": "add"
  },
  {
    "field": "feature2",
    "value": "val3",
    "type": "add"
  }
]

</code></pre>

<p>Here splitting must happen based on the "field" and it show something that is similar to above.here "type" is an extra field that is hardcoded</p>

<p>Help would be appreciated.</p>
