title: Convert string with dot notation to JSON
body: <p>Given a string as dot notation, how would I create an object from that string (checking for already existing properties): eg</p>
  
  <pre><code>var obj = {};
  stringToObj('a.b', 'value1', obj);
  stringToObj('a.b.c', 'value2', obj);
  </code></pre>
  
  <p>would produce </p>
  
  <pre><code>{
     "a": {
      "b": {
          "_x": "value1",
          "c": {
              "_x": "value2"
          }
      }
      }
   }
  </code></pre>
  
  <p>I've looked at <a href="https://stackoverflow.com/questions/6393943/convert-javascript-string-in-dot-notation-into-an-object-reference">this question</a> and <a href="https://stackoverflow.com/questions/11109768/converting-dot-notation-to-json">this one</a> but neither seems to be sufficient for what Im doing.</p>
  
  <p>Any thoughts? </p>