Accessing nested JavaScript objects with string key
<p>I have a data structure like this :</p>

<pre><code>var someObject = {
    'part1' : {
        'name': 'Part 1',
        'size': '20',
        'qty' : '50'
    },
    'part2' : {
        'name': 'Part 2',
        'size': '15',
        'qty' : '60'
    },
    'part3' : [
        {
            'name': 'Part 3A',
            'size': '10',
            'qty' : '20'
        }, {
            'name': 'Part 3B',
            'size': '5',
            'qty' : '20'
        }, {
            'name': 'Part 3C',
            'size': '7.5',
            'qty' : '20'
        }
    ]
};
</code></pre>

<p>And I would like to access the data using these variable :</p>

<pre><code>var part1name = "part1.name";
var part2quantity = "part2.qty";
var part3name1 = "part3[0].name";
</code></pre>

<p>part1name should be filled with someObject.part1.name 's value, which is "Part 1". Same thing with part2quantity which filled with 60.</p>

<p>Is there anyway to achieve this with either pure javascript or JQuery?</p>

<p>Thanks in advance.</p>
