为了账号安全,请及时绑定邮箱和手机立即绑定

JSON筛选, 谢谢,

/ 猿问

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": "/"
        }];


查看完整描述

2 回答

?
无尽未来

我是不是也要谢邀请,

    遍历旧的JSON然后加条件筛选就好了

查看完整回答
反对 回复 2017-06-21
?
ExiaGo

谢邀请,我也没有筛选过 json 数据,我是这样想的,先创建一个空的对象,如:

var newMenuListJSonStr = [

    {

      "title" : "",

    } 

];

然后遍历旧的 json 数据,将旧数据赋值新的空对象

newMenuListJSonStr[0].title = oldData[0].name

newMenuListJSonStr[0].title //实时监测

看看别的大神是否这样做的?请告知。

查看完整回答
反对 回复 2017-06-19

添加回答

回复

举报

0/150
提交
取消
意见反馈 邀请有奖 帮助中心 APP下载
官方微信