title: Convert Map to JSON object in Javascript
body: <p>So Ive got the following javascript which contains a key/value pair to map a nested path to a directory.</p>
  
  <pre><code>function createPaths(aliases, propName, path) {
      aliases.set(propName, path);
  }
  
  map = new Map();
  
  createPaths(map, 'paths.aliases.server.entry', 'src/test');
  createPaths(map, 'paths.aliases.dist.entry', 'dist/test');
  </code></pre>
  
  <p>Now what I want to do is create a JSON object from the key in the map.</p>
  
  <p>It has to be,</p>
  
  <pre><code>paths: {
    aliases: {
      server: {
        entry: 'src/test'
      },
      dist: {
        entry: 'dist/test'
      }
    }
  }
  </code></pre>
  
  <p>Not sure if there is an out of a box way to do this. Any help is appreciated.</p>