title: Change the values of JSON file but keep the structure
body: <p>Let's say I have a JSON file like this:</p>
  
  <pre><code>{
      "public": {
          "hello": "world",
          "bye": "stranger"
      }
  }
  </code></pre>
  
  <p>I then have a form where I can edit the values of <code>hello</code> and <code>bye</code>.</p>
  
  <pre><code>var keys = [];
  var values = [];
  
  $.each($(event.currentTarget).find('input'), function(key, val) {
      if($(this).attr('name') == 'skey') {
          keys.push($(this).val());
      }
  
      if($(this).attr('name') == 'svalue') {
          values.push($(this).val());
      }
  });
  </code></pre>
  
  <p>And in the method I manipulate it</p>
  
  <pre><code>var rootDir = process.cwd().split('.meteor')[0];
  rootDir = rootDir.replace(/\\/g, "/");
  rootDir = rootDir + "private/";
  var fileName = 'settings.default.json';
  var filepath = rootDir + fileName;
  
  for (var i = 0; i &lt; obj.length; i++) {
      for (var i = 0; i &lt; values.length; i++) {
          obj[i] = values[i];
      }
  }
  
  fs.writeFileSync(filepath, JSON.stringify(obj), 'binary');
  </code></pre>
  
  <p>The problem is that it would print
  <code>["new value of hello", "new value of bye"]</code> and I, unfortunately, have no idea how to make it look like:</p>
  
  <pre><code>{
      "public": {
          "hello": "new value of hello",
          "bye": "new value of bye"
      }
  }
  </code></pre>
  
  <p>How can this be done?</p>