Getting Parent node from Json object with Jquery

前端 未结 2 1364
慢半拍i
慢半拍i 2021-01-03 01:04

I am trying to get parent node in json object by child it The json i am getting from client is a multilevel directory hierarchy the hierarchy is like

Root
           


        
2条回答
  •  礼貌的吻别
    2021-01-03 01:33

    To get all ocuurences

    var pars,k,v,chk;
        pars = [];
        $.each(json,function(k,v){
            chk = k;
            $.each(v,function(k,v)
                if(k === node){
                    pars.push(chk);
                }
            })
        })
    

提交回复
热议问题