title: Parsing the json array to map using Underscore.js
body: <p>I am having a json array which I want to parse it to a <code>map</code> object. The key should be the state and the value should be an array objects which has the same state. The sample json is given below:</p>
  
  <pre><code>{
    "totalRec": 10,
    "content": [
      {
        "name": "Pradeep",
        "age": "24",
        "state": "KA"
      },
      {
        "name": "Praveen",
        "age": "30",
        "state": "KA"
      },
      {
        "name": "Navnish",
        "age": "32",
        "state": "GOA"
      },
      {
        "name": "Vinod",
        "age": "32",
        "state": "MH"
      },
      {
        "name": "Vikas",
        "age": "32",
        "state": "MH"
      },
      {
        "name": "Harry",
        "age": "44",
        "state": "MP"
      },
      {
        "name": "Linda",
        "age": "22",
        "state": "GOA"
      },
      {
        "name": "June",
        "age": "18",
        "state": "KA"
      },
      {
        "name": "Sachin",
        "age": "32",
        "state": "GOA"
      },
      {
        "name": "Arjun",
        "age": "30",
        "state": "UP"
      }
    ]
  }
  </code></pre>
  
  <p>I tried using <code>Underscore.js</code> and used the following code:</p>
  
  <pre><code>  var some_map = _.object(_.map(data.content, function(item) {
              return [item.state, item]
          }));
  </code></pre>
  
  <p>But the above code does not give me a list object as a value for a particular state. I want the value to hold all the objects which contain the state as key.</p>
  
  <p>Can you please let me know where I am going wrong?</p>