我有一个JSON,我需要从中形成一个树形结构,我还有搜索框,我将输入一个文本,它将从json中搜索并显示列表。
我的Json
{"轮廓":" CM_MGR""资源" {" LEASE" {" ID" :" LEASE""名称":" LEASE""类型":" MODULE""儿童":{" CLINE":{"编号":" CLINE""名称":"信用卡 LINE""类型":" MENU""儿童":{" RR":{"编号&#34 ;:" RR""名称":"风险 评分及#34;"类型":" SUB_MENU"}" CMTS" {" ID":" CMTS&#34 ;,"名称":" COMMENTS""类型":" SUB_MENU""动作":4}, " FIN" {" ID":" FIN""名称":"作者""类型":" SUB_MENU""动作":5}," FA" {" ID":" FA& #34;"名称":"财务 分析""类型":" SUB_MENU""动作":16}" CCL" {" ID& #34;:" CCL""名称":" CREATE 信用 LINE""类型":" SUB_MENU""动作":5}},"动作":2},&# 34; CUST" {" ID":" CUST""名称":" CUSTOMER""类型&# 34;:" MENU""子" {" EASSET" {" ID":" EASSET&#34 ;, "名称":" EXISTING ASSET""类型":" SUB_MENU""动作":1}," MGMT" {" ID& #34;:" MGMT""名称":"管理""类型":" SUB_MENU",& #34;动作":1}," BMODEL" {" ID":" BMODEL""名称":&# 34; BUSINESS MODEL""类型":" SUB_MENU""动作":16}" DEMO" {" ID& #34;:" DEMO""名称":" DEMOGRAPHICS""类型":" SUB_MENU",& #34;子" {" IDEN" {" ID":" IDEN""名称":"鉴定 DETIALS""类型":" PAGE"}" CLASS" {" ID":" CLASS&#34 ;,"名称":"分类""类型":" PAGE"}" CPERS":{& #34; ID":" CPERS""名称":" CONTACT PERSON""类型":" PAGE"}" BDATA" {" ID":" BDATA&#34 ;,"名称":"具有基本 DATA""类型":" PAGE"}" ADDR" {" ID":" ADDR&#34 ;,"名称":" ADDRESS""类型":" PAGE"}}}}"动作" :2}," LI" {" ID":" LI""名称":" LEASE INITIATION""类型":" MENU""子" {" CF" {" ID&#34 ;:" CF""名称":" CASH FLOW""类型":" SUB_MENU""动作":4}," BASSET" {" ID& #34;:" BASSET""名称":"具有基本 ASSET 细节及#34;"类型":" SUB_MENU""动作":16}" LQ" {" ID& #34;:" LQ""名称":" LEASE QUATATION""类型":" SUB_MENU""动作":16}"乙\ u0026A" {&#34 ; ID":"乙\ u0026A""名称":" LINK BUYBACK \ u0026 ASSIGNEE""类型":" SUB_MENU""动作":16}" GUAR" {" ID& #34;:" GUAR""名称":" LINK 担保人""类型":" SUB_MENU""动作":1}," INS" {" ID& #34;:" INS""名称":" INSURANCE""类型":" SUB_MENU"}} "动作":1}," UD" {" ID":" UD""名称&#34 ;: "承销""类型":" MENU""子" {" RRCMT" {&#34 ; ID":" RRCMT""名称":"风险 评分 评论""类型":" SUB_MENU""动作":16}" CARPT" {" ID& #34;:" CARPT""名称":" CREDIT 评价 REPORT""类型":" SUB_MENU""动作":13}" CLA" {" ID& #34;:" CLA""名称":" CREDIT LINE APPROVAL","输入":" SUB_MENU"}," CMEMO":{" id":" CMEMO&# 34;,"名称":" CREDIT 批准 MEMO""类型":" SUB_MENU""动作":16}" AL" {" ID& #34;:" AL""名称":" APPROVAL LETTER""类型":" SUB_MENU"}" GRPT" {" ID":" GRPT&#34 ;,"名称":"担保人 REPORT""类型":" SUB_MENU""动作":13}" SFA" {" ID& #34;:" SFA""名称":" SUBMIT 要获得批准","键入":" SUB_MENU"}," UCL":{" id":" UCL&# 34;,"名称":" UPDATE 信用 LINE""类型":" SUB_MENU""动作&#34:4}},"动作":2}}}, " ADMIN" {" ID":" ADMIN""名称":" ADMIN""类型":" MODULE""子" {" USERS" {" ID":" USERS&#34 ;,"名称":" USERS""类型":" PAGE"}}}}}
我需要设计具有以下结构的页面。有人能帮我吗 ?我不知道该怎么做
$.each(data, function(key, val) {
/**/
if(data["resources"] != null){
// console.log(key);
if(key == "resources"){
$.each(val, function(key1, val1) {
// console.log(key1);
$.each(val1, function(key2, val2) {
if(key2 == "name"){
// console.log(key2);
// console.log(JSON.stringify(val2));
text = $('<li>'+val2+'</li>');
}if(key2 == "child"){
$.each(val2,function(key3,val3){
// alert(key3);
// alert(JSON.stringify(val3["name"]));
// console.log(val3);
text1 = $('<ul><li>'+val3["name"]+'</li>');
lastLine = text.append(text1);
lastLine.appendTo('.tbodyResource');
$.each(val3,function(key4,val4){
if(key4 == "child"){
$.each(val4,function(key5,val5){
alert(JSON.stringify(val5));
/* text2 = $('<ul><li>'+val5["name"]+'</li></ul></ul></ul></td></tr>');
lastLine = text.append(text1);
s = lastLine.append(text2);
s.appendTo('.tbodyResource');*/
});
}
});
});
}
});
});
}
}
});
我认为这是o / p,我知道我在这种方法中错了