Convert a string key in a JSON object to a child object? <p>I've looped through an document.form.element the names are constructed into an array name like so:</p> <h2>Current output</h2> <p>Some of the names of they keys are like so in JSON:</p> <pre><code>{ data[name]: "foo", data[address]: "baz drive", data[city]: "Dallas", data[state]: "Texas", data[phone]: "555-1212" } </code></pre> <h2>Desired output</h2> <p>Is there a way to convert it to this with Pure JavaScript (and without frameworks like jQuery) without using <code>eval</code>?:</p> <pre><code>{ data: { name: "foo", address: "baz drive", city: "Dallas", state: "Texas", phone: "555-1212" } } </code></pre> <h3>What have i tried so far</h3> <pre><code>&lt;script type="javascript"&gt; var o = { data[name]: "foo", data[address]: "baz drive", data[city]: "Dallas", data[state]: "Texas", data[phone]: "555-1212" } var temp = []; for (key in o) { temp[JSON.parse(key)] = o; } &lt;/script&gt; </code></pre> <p>Fiddle is here: <a href="http://jsfiddle.net/chrisjlee/medbzv9a/" rel="nofollow">http://jsfiddle.net/chrisjlee/medbzv9a/</a></p> <p>Or is this not totally possible?</p>