a543462378 2022-07-29 11:54 采纳率: 82%
浏览 31
已结题

字符串如图所示是按照地市区分,把地市的数组合起来了,怎么把地市编号后面的数组合并成一个数组

后端接口给的字符串怎么把字符串里面的数组抽出来合并成一个数组?
字符串如图所示

img


是按照地市区分,把地市的数组合起来了,怎么把地市编号后面的数组合并成一个数组?

data: {
        '320100': [
          { 'city': '南京市', 'cityFid': '320100', 'create': null, 'fid': 'STS20220722111009371A43EE', 'list': [{ 'fid': null, 'situation': '13', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '4613', 'workStartTime': '2022-09-01', 'workType': '131' }, { 'fid': null, 'situation': '14', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '4614', 'workStartTime': '2022-09-02', 'workType': '132' }, { 'fid': null, 'situation': '15', 'stcFid': null, 'workEndTime': '2022-09-04', 'workPort': '4615', 'workStartTime': '2022-09-03', 'workType': '133' }, { 'fid': null, 'situation': '16', 'stcFid': null, 'workEndTime': '2022-09-05', 'workPort': '4616', 'workStartTime': '2022-09-04', 'workType': '134' }, { 'fid': null, 'situation': '17', 'stcFid': null, 'workEndTime': '2022-09-06', 'workPort': '4617', 'workStartTime': '2022-09-05', 'workType': '135' }, { 'fid': null, 'situation': '18', 'stcFid': null, 'workEndTime': '2022-09-07', 'workPort': '4618', 'workStartTime': '2022-09-06', 'workType': '136' }, { 'fid': null, 'situation': '19', 'stcFid': null, 'workEndTime': '2022-09-08', 'workPort': '4619', 'workStartTime': '2022-09-07', 'workType': '137' }], 'listDetailed': null, 'replacementFrequency': 5, 'shipCompanyFid': null, 'shipCompanyName': '南京有限责任公司', 'shipFid': 'WWFTSI20220616111447C25BE39F', 'shipName': 'ss002', 'shipTotal': 22.0, 'smFid': 'TASK20220610110136C4A99C0D', 'taskNumber': 7, 'washFrequency': 5 },
          { 'city': '南京市', 'cityFid': '320100', 'create': null, 'fid': 'STS20220722111009209699E2', 'list': [{ 'fid': null, 'situation': '13', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '4613', 'workStartTime': '2022-09-01', 'workType': '131' }, { 'fid': null, 'situation': '14', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '4614', 'workStartTime': '2022-09-02', 'workType': '132' }, { 'fid': null, 'situation': '15', 'stcFid': null, 'workEndTime': '2022-09-04', 'workPort': '4615', 'workStartTime': '2022-09-03', 'workType': '133' }, { 'fid': null, 'situation': '16', 'stcFid': null, 'workEndTime': '2022-09-05', 'workPort': '4616', 'workStartTime': '2022-09-04', 'workType': '134' }, { 'fid': null, 'situation': '17', 'stcFid': null, 'workEndTime': '2022-09-06', 'workPort': '4617', 'workStartTime': '2022-09-05', 'workType': '135' }, { 'fid': null, 'situation': '18', 'stcFid': null, 'workEndTime': '2022-09-07', 'workPort': '4618', 'workStartTime': '2022-09-06', 'workType': '136' }, { 'fid': null, 'situation': '19', 'stcFid': null, 'workEndTime': '2022-09-08', 'workPort': '4619', 'workStartTime': '2022-09-07', 'workType': '137' }], 'listDetailed': null, 'replacementFrequency': 6, 'shipCompanyFid': null, 'shipCompanyName': '南京有限责任公司', 'shipFid': 'WWFTSI20220616111447C25BE39F', 'shipName': 'ss002', 'shipTotal': 22.0, 'smFid': 'TASK20220610110136C4A99C0D', 'taskNumber': 7, 'washFrequency': 3 },
          { 'city': '南京市', 'cityFid': '320100', 'create': null, 'fid': 'STS20220722111010E9B59858', 'list': [{ 'fid': null, 'situation': '13', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '4613', 'workStartTime': '2022-09-01', 'workType': '131' }, { 'fid': null, 'situation': '14', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '4614', 'workStartTime': '2022-09-02', 'workType': '132' }, { 'fid': null, 'situation': '15', 'stcFid': null, 'workEndTime': '2022-09-04', 'workPort': '4615', 'workStartTime': '2022-09-03', 'workType': '133' }, { 'fid': null, 'situation': '16', 'stcFid': null, 'workEndTime': '2022-09-05', 'workPort': '4616', 'workStartTime': '2022-09-04', 'workType': '134' }, { 'fid': null, 'situation': '17', 'stcFid': null, 'workEndTime': '2022-09-06', 'workPort': '4617', 'workStartTime': '2022-09-05', 'workType': '135' }, { 'fid': null, 'situation': '18', 'stcFid': null, 'workEndTime': '2022-09-07', 'workPort': '4618', 'workStartTime': '2022-09-06', 'workType': '136' }, { 'fid': null, 'situation': '19', 'stcFid': null, 'workEndTime': '2022-09-08', 'workPort': '4619', 'workStartTime': '2022-09-07', 'workType': '137' }], 'listDetailed': null, 'replacementFrequency': 8, 'shipCompanyFid': null, 'shipCompanyName': '南京有限责任公司', 'shipFid': 'WWFTSI20220616111447C25BE39F', 'shipName': 'ss002', 'shipTotal': 22.0, 'smFid': 'TASK20220610110136C4A99C0D', 'taskNumber': 7, 'washFrequency': 3 }],
        '320200': [
          { 'city': '无锡市', 'cityFid': '320200', 'create': null, 'fid': 'STS20220727173715EA5D6FBF', 'list': [{ 'fid': null, 'situation': 'fsdfa 缺乏发送阿法第三方阿发斯蒂芬阿发斯蒂芬改阿发发多少', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '123', 'workStartTime': '2022-09-01', 'workType': '234' }, { 'fid': null, 'situation': '123432', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '@@@', 'workStartTime': '2022-09-01', 'workType': '二玩儿' }, { 'fid': null, 'situation': 'fsdfa 缺乏发送阿法第三方阿发斯蒂芬阿发斯蒂芬改阿发发多少', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '123', 'workStartTime': '2022-09-01', 'workType': '234' }, { 'fid': null, 'situation': '123432', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '@@@', 'workStartTime': '2022-09-01', 'workType': '二玩儿' }], 'listDetailed': null, 'replacementFrequency': 5, 'shipCompanyFid': null, 'shipCompanyName': '测试水路运输企业01', 'shipFid': 'WWFTSI20220609110610648DC8A8', 'shipName': '苏苏洁00111', 'shipTotal': 1000.0, 'smFid': 'TASK202207211835293B76FFE9', 'taskNumber': 10, 'washFrequency': 2 }
        ]
      },

  • 写回答

2条回答 默认 最新

  • 谷雨睡不醒 2022-07-29 13:16
    关注

    不知道我理解的对不对

    
    const data = {
        '320100': [
            {
                'city': '南京市', 'cityFid': '320100', 'create': null, 'fid': 'STS20220722111009371A43EE', 
                'list': [
                    { 'fid': null, 'situation': '13', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '4613', 'workStartTime': '2022-09-01', 'workType': '131' }, 
                    { 'fid': null, 'situation': '14', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '4614', 'workStartTime': '2022-09-02', 'workType': '132' }, 
                    { 'fid': null, 'situation': '15', 'stcFid': null, 'workEndTime': '2022-09-04', 'workPort': '4615', 'workStartTime': '2022-09-03', 'workType': '133' }, 
                    { 'fid': null, 'situation': '16', 'stcFid': null, 'workEndTime': '2022-09-05', 'workPort': '4616', 'workStartTime': '2022-09-04', 'workType': '134' }, 
                    {'fid': null, 'situation': '17', 'stcFid': null, 'workEndTime': '2022-09-06', 'workPort': '4617', 'workStartTime': '2022-09-05', 'workType': '135'},
                 { 'fid': null, 'situation': '18', 'stcFid': null, 'workEndTime': '2022-09-07', 'workPort': '4618', 'workStartTime': '2022-09-06', 'workType': '136' }, 
                 { 'fid': null, 'situation': '19', 'stcFid': null, 'workEndTime': '2022-09-08', 'workPort': '4619', 'workStartTime': '2022-09-07', 'workType': '137' }
                ], 
                'listDetailed': null, 'replacementFrequency': 5, 'shipCompanyFid': null, 'shipCompanyName': '南京有限责任公司', 'shipFid': 'WWFTSI20220616111447C25BE39F', 'shipName': 'ss002', 'shipTotal': 22.0, 'smFid': 'TASK20220610110136C4A99C0D', 'taskNumber': 7, 'washFrequency': 5
            },
            {
                'city': '南京市', 'cityFid': '320100', 'create': null, 'fid': 'STS20220722111009209699E2', 'list': [{ 'fid': null, 'situation': '13', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '4613', 'workStartTime': '2022-09-01', 'workType': '131' }, { 'fid': null, 'situation': '14', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '4614', 'workStartTime': '2022-09-02', 'workType': '132' }, { 'fid': null, 'situation': '15', 'stcFid': null, 'workEndTime': '2022-09-04', 'workPort': '4615', 'workStartTime': '2022-09-03', 'workType': '133' }, { 'fid': null, 'situation': '16', 'stcFid': null, 'workEndTime': '2022-09-05', 'workPort': '4616', 'workStartTime': '2022-09-04', 'workType': '134' }, {
                    'fid': null, 'situation': '17', 'stcFid': null, 'workEndTime': '2022-09-06', 'workPort': '4617', 'workStartTime': '2022-09-05', 'workType': '135'
                }, { 'fid': null, 'situation': '18', 'stcFid': null, 'workEndTime': '2022-09-07', 'workPort': '4618', 'workStartTime': '2022-09-06', 'workType': '136' }, { 'fid': null, 'situation': '19', 'stcFid': null, 'workEndTime': '2022-09-08', 'workPort': '4619', 'workStartTime': '2022-09-07', 'workType': '137' }], 'listDetailed': null, 'replacementFrequency': 6, 'shipCompanyFid': null, 'shipCompanyName': '南京有限责任公司', 'shipFid': 'WWFTSI20220616111447C25BE39F', 'shipName': 'ss002', 'shipTotal': 22.0, 'smFid': 'TASK20220610110136C4A99C0D', 'taskNumber': 7, 'washFrequency': 3
            },
            { 'city': '南京市', 'cityFid': '320100', 'create': null, 'fid': 'STS20220722111010E9B59858', 'list': [{ 'fid': null, 'situation': '13', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '4613', 'workStartTime': '2022-09-01', 'workType': '131' }, { 'fid': null, 'situation': '14', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '4614', 'workStartTime': '2022-09-02', 'workType': '132' }, { 'fid': null, 'situation': '15', 'stcFid': null, 'workEndTime': '2022-09-04', 'workPort': '4615', 'workStartTime': '2022-09-03', 'workType': '133' }, { 'fid': null, 'situation': '16', 'stcFid': null, 'workEndTime': '2022-09-05', 'workPort': '4616', 'workStartTime': '2022-09-04', 'workType': '134' }, { 'fid': null, 'situation': '17', 'stcFid': null, 'workEndTime': '2022-09-06', 'workPort': '4617', 'workStartTime': '2022-09-05', 'workType': '135' }, { 'fid': null, 'situation': '18', 'stcFid': null, 'workEndTime': '2022-09-07', 'workPort': '4618', 'workStartTime': '2022-09-06', 'workType': '136' }, { 'fid': null, 'situation': '19', 'stcFid': null, 'workEndTime': '2022-09-08', 'workPort': '4619', 'workStartTime': '2022-09-07', 'workType': '137' }], 'listDetailed': null, 'replacementFrequency': 8, 'shipCompanyFid': null, 'shipCompanyName': '南京有限责任公司', 'shipFid': 'WWFTSI20220616111447C25BE39F', 'shipName': 'ss002', 'shipTotal': 22.0, 'smFid': 'TASK20220610110136C4A99C0D', 'taskNumber': 7, 'washFrequency': 3 }],
        '320200': [
            {
                'city': '无锡市', 'cityFid': '320200', 'create': null, 'fid': 'STS20220727173715EA5D6FBF', 'list': [{ 'fid': null, 'situation': 'fsdfa 缺乏发送阿法第三方阿发斯蒂芬阿发斯蒂芬改阿发发多少', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '123', 'workStartTime': '2022-09-01', 'workType': '234' }, { 'fid': null, 'situation': '123432', 'stcFid': null, 'workEndTime': '2022-09-02', 'workPort': '@@@', 'workStartTime': '2022-09-01', 'workType': '二玩儿' }, {
                    'fid': null, 'situation': 'fsdfa 缺乏发送阿法第三方阿发斯蒂芬阿发斯蒂芬改阿发发多少', 'stcFid': null,
                    'workEndTime': '2022-09-03', 'workPort': '123', 'workStartTime': '2022-09-01', 'workType': '234'
                }, { 'fid': null, 'situation': '123432', 'stcFid': null, 'workEndTime': '2022-09-03', 'workPort': '@@@', 'workStartTime': '2022-09-01', 'workType': '二玩儿' }], 'listDetailed': null, 'replacementFrequency': 5, 'shipCompanyFid': null, 'shipCompanyName': '测试水路运输企业01', 'shipFid': 'WWFTSI20220609110610648DC8A8', 'shipName': '苏苏洁00111', 'shipTotal': 1000.0, 'smFid': 'TASK202207211835293B76FFE9', 'taskNumber': 10, 'washFrequency': 2
            }
        ]
    }
    
    const resArr = []
    for (let key in data){
        data[key].forEach(element => {
            resArr.push(element)
        });
    }
    console.log(resArr);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月6日
  • 已采纳回答 7月29日
  • 创建了问题 7月29日

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?