adrianvlupu
11/20/2013 - 5:41 PM

ObjectSearch.js

function scan(obj, search, from)
{
    var k;
    if (obj instanceof Object) {
        for (k in obj){
            //console.log('object ', obj, k);    
            if (obj.hasOwnProperty(k)){
                if(k.toString().indexOf(search)!=-1){
                    console.log('found string as prop ', k, obj);
                }else{
                    if(!from) from=obj;
                    scan(obj[k], search, from);  
                }
            }                
        }
    } else {
        if(obj!=null && obj.toString().indexOf(search)!=-1){
            console.log('found string as value ', obj, from);
        }
    };
};