Question: This is probably a very easy question but let's say I have a php json\_encoded javascript object of this form:

```
var js_objet = {
    "1": {
        "Users": {
            "id": "14",
            "name": "Peter"
         }, 
         "Children": [
             {
                 id: 17, 
                 name: "Paul"
             }, 
             {
                 id: 18, 
                 name: "Mathew"
             }
        ]
      }    
    }

```

What is the synthax to get the name of the child with id 18 (Mathew) for example from that Object?

Thank you

Answer: 
Here's such a custom function as mentioned earlier.

```
function getChildrenById(id){
    for (var child in js_objet[1].Children){
        if(id == js_objet[1].Children[child].id){
            return js_objet[1].Children[child].name;
        }
    }
    return false;
}

```

running `getChildrenById(18)` would return "Mathew"

Hope that helps,

R.
This really is a comment, but I don't have enough reputation (but it's relevant as I recently encountered the same issue): This would probably be easier to do if you can change the JSON format to use the ID as the key for each child object:

```
var js_objet = {
"1": {
    "Users": {
        "id": "14",
        "name": "Peter"
     }, 
     "Children": {
         "17":{ 
             "name": "Paul"
         }, 
         "18":{
             "name": "Mathew"
         }
    }
  }    
}

```

Then you can simply call it using

```
js_objet[1].Children[18].name;

```

This is assuming each ID is unique.