Access a predefined child object from its parent object with a string
<p>I have a javascript object that has been returned from a Database.</p>

<p>I want to build a function that, if passed a parent object and a string, can return a child from the parent with the same name as the string.  </p>

<p>the following code obviously does not work, but gives the idea:</p>

<pre><code>function filter (object,  text) {  
return object.Text  
}
</code></pre>

<p>such that </p>

<pre><code>var object = {
    "prop1": 1,
    "prop2": 
        {
            "ChildProp1": 1,
            "ChildProp2": 2,
        }
}
var text = "prop2"

var ChildObject = filter(object, text)

//expected content of ChildObject = {
//            "ChildProp1": 1,
//            "ChildProp2": 2,
//        }
</code></pre>
