猿问
下载APP

JSON筛选, 谢谢,

  //这是新菜单  从下面的旧菜单筛选出来的 请问怎么做成这样

         //新菜单从旧菜单筛选出来的
    var newMenuListJSonStr = [
        {
            "title": "实时监测",
            "icon": "new/t-1",
            "spread": true,
            "children": [{
                "title": "用能分布可视化",
                "iconCls": "thirdLevelMenu/57",
                "href": "energyMonitor/energyDistributionVisual"
            }, {
                "title": "变配电监测",
                "icon": "thirdLevelMenu/56",
                "href": "energyMonitor/byqSVGMonitor"
            }]
        }
    ];

    //旧菜单
        
         var oldData = [{
            "iconCls": "new/t-1",
            "id": "4754406",
            "name": "实时监测",
            "pid": "0",
            "subFunctionMenuList": [
                [{
                    "iconCls": "c_sbjb",
                    "id": "4754407",
                    "name": "能耗可视化管理",
                    "pid": "4754406",
                    "subFunctionMenuList": [
                        [{
                            "iconCls": "thirdLevelMenu/57",
                            "id": "4754408",
                            "name": "用能分布可视化",
                            "pid": "4754407",
                            "subFunctionMenuList": [
                                [

                                ]
                            ],
                            "url": "energyMonitor/energyDistributionVisual"
                        }, {
                            "iconCls": "thirdLevelMenu/56",
                            "id": "4754467",
                            "name": "变配电监测",
                            "pid": "4754407",
                            "subFunctionMenuList": [
                                [

                                ]
                            ],
                            "url": "energyMonitor/byqSVGMonitor"
                        }]
                    ],
                    "url": "energyMonitor"
                }]
            ],
            "url": "/"
        }];


SuperManSuperWorld
浏览 1861回答 2
2回答

无尽未来

我是不是也要谢邀请,    遍历旧的JSON然后加条件筛选就好了

ExiaGo

谢邀请,我也没有筛选过 json 数据,我是这样想的,先创建一个空的对象,如:var newMenuListJSonStr = [    {      "title" : "",    } ];然后遍历旧的 json 数据,将旧数据赋值新的空对象newMenuListJSonStr[0].title = oldData[0].namenewMenuListJSonStr[0].title //实时监测看看别的大神是否这样做的?请告知。
打开App,查看更多内容
随时随地看视频慕课网APP
我要回答