title: How to convert a javascript map of array into a json object in javascript?
body: <p>I have a javascript MAP object which is holding key as a string and value as a javascript array, each array is holding set of strings inside it. I want to convert the map of arrays into a json object in javascript. </p>
  
  <p>Here is the code which i tried </p>
  
  <p>function addRole() {</p>
  
  <pre><code> var jsonObjectOfMap={};
      subMenuSelectedIdMap.forEach(function(items,key,subMenuSelectedIdMap){
          jsonObjectOfMap[key]=JSON.stringify(items);
      }); 
      alert(JSON.stringify(jsonObjectOfMap));
  </code></pre>
  
  <p>I am getting the json object as like this 
  <strong>{"1004":"[1005,1006,1023]","1007":"[1008,1053]"}</strong> </p>
  
  <p>But is this json format object is valid and what i have to do if i want it the format as this:
  <strong>{"1004":["1005","1006","1023"]","1007":["1008","1053"]}</strong></p>
  
  <p>Please help me out</p>