js改变数组对象属性名

27 篇文章 0 订阅
        let data= [
          {
            id: "22",
            name: "全部",
            rtsp: null,
            status: null,
            videos: [
              {
                id: "2",
                name: "区域一(在线1/总数4)",
                rtsp: null,
                status: null,
                videos: [
                  // {
                  //     id: "cee0a8b3-2f8c-492b-901b-ba45f43d0514",
                  //     name: "101",
                  //     rtsp: "rtsp://10.15.123.101:8555/MainStream",
                  //     status: 1,
                  //     videos: null
                  // }
                ]
              },
              {
                id: "1",
                name: "走廊2(在线1/总数4)",
                rtsp: null,
                status: null,
                videos: [
                  {
                    id: "03288196-25d4-497a-9dfd-5fdf5bb4f968",
                    name: "宇视96-01",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "0328196-25d4-497a-9dfd-5fdf5bb4f968",
                    name: "宇视96-02",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "0325d4-497a-9dfd-5fdf5bb4f968",
                    name: "宇视96-03",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "-497a-9dfd-5fdf5bb4f968",
                    name: "宇视96-04",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "0322-25d4-497a-9dfd-5fdf5bb4f968",
                    name: "宇视96-05",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "0322-25d4-497a-9f5bb4f968",
                    name: "宇视96-06",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "032b4f968",
                    name: "宇视96-07",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.96:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "1637069316",
                    name: "大华197-08",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.197:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "163706ba-4654-4854-9c05-2f39c17d9316",
                    name: "大华197-09",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.197:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "1611ba-4654-4854-9c05-2f39c17d9316",
                    name: "大华197-10",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.197:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "2e7034bf-179c-4621-a462-c7adf0a6ee7f",
                    name: "海康196-11",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.196:554",
                    status: 1
                  },
                  {
                    id: "2e70c-4621-a462-c7adf0a6ee7f",
                    name: "海康196-12",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.196:554",
                    status: 1
                  },
                  {
                    id: "2edf0a6ee7f",
                    name: "海康196-13",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.196:554",
                    status: 1
                  },
                  {
                    id: "975e44a8-0301-4b12-9aa3-37b323a62321",
                    name: "海康109-14",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.88:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "b81f78fd-b4c2-4b4b-bdbb-094f053bbe7f",
                    name: "大华88-15",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.88:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "b81hgfb4b-bdbb-094f053bbe7f",
                    name: "大华88-16",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.88:554",
                    status: 1,
                    videos: null
                  },
                  {
                    id: "b81f780b4b-bdbb-094f053bbe7f",
                    name: "大华88-17",
                    rtsp: "rtsp://admin:nuctech123@10.15.123.88:554",
                    status: 1,
                    videos: null
                  }
                ]
              }
            ]
          }
        ];


  let getDatas = JSON.parse(
        JSON.stringify(data)
          .replace(/list/g, "videos")
          .replace(/deviceName/g, "name")
          .replace(/areaName/g, "name")
          .replace(/deviceStatus/g, "status")
      );

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值