a543462378
2022-06-16 16:16
采纳率: 92%
浏览 41
已结题

后端返回的数组,如何拆分

后端返回的数据,现在要把每一条listDetailed里面的数据和外面的合并。listDetailed里面有几条就生成几条新数据。
就是把下面的数据

{
                "shipFid":"船舶编号",
                "shipName":"船舶名称",
                "shipCompanyFid":"船公司编号",
                "shipCompanyName":"船公司名称",
                "shipTotal":10.2,
                "replacementFrequency":10,
                "washFrequency":11,
                "taskNumber":12,
                "listDetailed":[
                    {
                        "workStartTime":"2022-06-16",
                        "workEndTime":"2022-06-20",
                        "workPort":"装卸作业码头",
                        "workType":"主要货中",
                        "situation":"洗舱情况",
                    },
                    {
                        "workStartTime":"2022-06-16",
                        "workEndTime":"2022-06-20",
                        "workPort":"装卸作业码头1",
                        "workType":"主要货中1",
                        "situation":"洗舱情况1",
                    }
                ]
            },{
                "shipFid":"船舶编号",
                "shipName":"船舶名称",
                "shipCompanyFid":"船公司编号",
                "shipCompanyName":"船公司名称",
                "shipTotal":10.2,
                "replacementFrequency":10,
                "washFrequency":11,
                "taskNumber":12,
                "listDetailed":[
                    {
                        "workStartTime":"2022-06-16",
                        "workEndTime":"2022-06-20",
                        "workPort":"装卸作业码头",
                        "workType":"主要货中",
                        "situation":"洗舱情况",
                    },
                    {
                        "workStartTime":"2022-06-16",
                        "workEndTime":"2022-06-20",
                        "workPort":"装卸作业码头1",
                        "workType":"主要货中1",
                        "situation":"洗舱情况1",
                    },
                    {
                        "workStartTime":"2022-06-16",
                        "workEndTime":"2022-06-20",
                        "workPort":"装卸作业码头1",
                        "workType":"主要货中1",
                        "situation":"洗舱情况1",
                    }
                ]
            },

变成这种格式

{
    "shipFid":"船舶编号",
    "shipName":"船舶名称",
    "shipCompanyFid":"船公司编号",
    "shipCompanyName":"船公司名称",
    "shipTotal":10.2,
    "replacementFrequency":10,
    "washFrequency":11,
    "taskNumber":12,
    "workStartTime":"2022-06-16",
    "workEndTime":"2022-06-20",
    "workPort":"装卸作业码头",
    "workType":"主要货中",
    "situation":"洗舱情况",
},{
    "shipFid":"船舶编号",
    "shipName":"船舶名称",
    "shipCompanyFid":"船公司编号",
    "shipCompanyName":"船公司名称",
    "shipTotal":10.2,
    "replacementFrequency":10,
    "washFrequency":11,
    "taskNumber":12,
    "workStartTime":"2022-06-16",
    "workEndTime":"2022-06-20",
    "workPort":"装卸作业码头",
    "workType":"主要货中",
    "situation":"洗舱情况",
},{
    "shipFid":"船舶编号",
    "shipName":"船舶名称",
    "shipCompanyFid":"船公司编号",
    "shipCompanyName":"船公司名称",
    "shipTotal":10.2,
    "replacementFrequency":10,
    "washFrequency":11,
    "taskNumber":12,
    "workStartTime":"2022-06-16",
    "workEndTime":"2022-06-20",
    "workPort":"装卸作业码头",
    "workType":"主要货中",
    "situation":"洗舱情况",
},{
    "shipFid":"船舶编号",
    "shipName":"船舶名称",
    "shipCompanyFid":"船公司编号",
    "shipCompanyName":"船公司名称",
    "shipTotal":10.2,
    "replacementFrequency":10,
    "washFrequency":11,
    "taskNumber":12,
    "workStartTime":"2022-06-16",
    "workEndTime":"2022-06-20",
    "workPort":"装卸作业码头",
    "workType":"主要货中",
    "situation":"洗舱情况",
},

1条回答 默认 最新

相关推荐 更多相似问题