JOLT转换规范

时间:2020-04-26 13:40:11

标签: jolt

我正在尝试编写JOLT规范,但是卡住了。你能帮我吗?

输入JSON:

{
"content": [
    {
        "cityId": 4,
        "serviceId": 8,
        "service": "Library",
        "cityServiceDescription": "Use many advantages.",
        "RESTRICTED": true,
        "category": "Library",
        "cityServiceCategoryDescription": "Use many advantages.",
        "categoryId": 4,
        "actionId": null,
        "action": null         
    },
    {
        "cityId": 4,
        "serviceId": 20,
        "service": "Public Transport",
        "cityServiceDescription": "How to buy",
        "RESTRICTED": false,
        "category": "Transport",
        "cityServiceCategoryDescription": "With the public.",
        "categoryId": 11,
        "actionId": 1,
        "action": "2"      
    },
    {
        "cityId": 4,
        "serviceId": 21,
        "service": "Citizen-Participation",
        "cityServiceDescription": "Shape!",
        "RESTRICTED": false,
        "category": "Participation-Portal",
        "cityServiceCategoryDescription": "Your engagement.",
        "categoryId": 12,
        "actionId": 3,
        "action": "1"       
    },
    {
        "cityId": 4,
        "serviceId": 21,
        "service": "Citizen-Participation",
        "cityServiceDescription": "Shape!",
        "RESTRICTED": false,
        "category": "Participation-Portal",
        "cityServiceCategoryDescription": "Your engagement.",
        "categoryId": 12,
        "actionId": 5,
        "action": "1"
    },
    {
        "cityId": 4,
        "serviceId": 21,
        "service": "Citizen-Participation",
        "cityServiceDescription": "Shape!",
        "RESTRICTED": false,
        "category": "Participation-Portal",
        "cityServiceCategoryDescription": "Your engagement.",
        "categoryId": 12,
        "actionId": 7,
        "action": "1"
    },
    {
        "cityId": 4,
        "serviceId": 21,
        "service": "Citizen-Participation",
        "cityServiceDescription": "Shape!"
        "RESTRICTED": false,
        "category": "Participation-Portal",
        "cityServiceCategoryDescription": "Your engagement.",
        "categoryId": 12,
        "actionId": 9,
        "action": "1"
    }
]

}

预期的输出JSON:

{
"content": [
    {
        "cityServiceCategoryList": [
            {
                "categoryId": "4",
                "category": "Library",
                "description": "Use many advantages",
                "cityServiceList": [
                    {
                        "serviceId": 8,
                        "service": "Library",
                        "description": "Use many advantages.",
                        "restricted": true,
                        "serviceAction": []
                    }
                ]
            },
            {
                "categoryId": "11",
                "category": "Transport",
                "description": "With the public.",
                "cityServiceList": [
                    {
                        "serviceId": 20,
                        "service": "Public Transport",
                        "description": "How to buy",
                        "restricted": false,
                        "serviceAction": [
                            {
                                "actionId": 1,
                                "action": "2"                 

                            }
                        ]
                    }
                ]
            },
            {
                "categoryId": "12",
                "category": "Participation-Portal",
                "description": "Your engagement.",
                "cityServiceList": [
                    {
                        "serviceId": 21,
                        "service": "Citizen-Participation",
                        "description": "Shape!",
                        "restricted": false,
                        "serviceAction": [
                            {
                                "actionId": 3,
                                "action": "1"
                            },
                            {
                                "actionId": 5,
                                "action": "1"
                            },
                            {
                                "actionId": 7,
                                "action": "1"
                            },
                            {
                                "actionId": 9,
                                "action": "1"
                            }
                        ]
                    }
                ]
            }
        ],
        "cityId": 4
    }
]

}

当前规范:

[

{ “ operation”:“ shift”, “规格”:{ “ ”:{ “ categoryId”:{ “ ”:{ “ @ 2”:“&[]” } } } } }, { “ operation”:“ shift”, “规格”:{ “ ”:{ “ 0”:{ “ cityId”:“ e&2.cityId”, “ category”:“ e&2.category”, “ cityServiceCategoryDe​​scription”:“ e&2.description”, “ serviceId”:“ e&2.cityServiceList [&1] .serviceId”, “ service”:“ e&2.cityServiceList [&1] .service”, “ cityServiceDescription”:“ e&2.cityServiceList [&1] .description”, “ RESTRICTED”:“ e&2.cityServiceList [&1] .restricted”, “ actionId”:“ e&2.cityServiceList [&1] .serviceAction [&1] .actionId”, “ action”:“ e&2.cityServiceList [&1] .serviceAction [&1] .action”
}, “ $”:“ e&1.categoryId”, “
”:{ “ serviceId”:“ e&2.cityServiceList [&1] .serviceId”, “ service”:“ e&2.cityServiceList [&1] .service”, “ cityServiceDescription”:“ e&2.cityServiceList [&1] .description” “ RESTRICTED”:“ e&2.cityServiceList [&1] .restricted”, “ actionId”:“ e&2.cityServiceList [&1] .serviceAction [&1] .actionId”, “ action”:“ e&2.cityServiceList [&1] .serviceAction [&1] .action”

        }
     }
  }

}, { “ operation”:“ shift”, “规格”:{ “ ”:“ cityServiceCategoryList []” } }, { “ operation”:“ shift”, “规格”:{ “ cityServiceCategoryList”:{ “ 0”:{ “ cityId”:“ cityId”, “ @”:“ cityServiceCategoryList” }, “ ”:{ “ @”:“ cityServiceCategoryList” } } } }, { “ operation”:“删除”, “规格”:{ “ cityServiceCategoryList”:{ “ ”:{ “ cityId”:“” } } } }, { “ operation”:“ shift”, “规格”:{ “ @ 1”:“ []” } }, { “ operation”:“ shift”, “规格”:{ “ ”:{ “ cityServiceCategoryList”:“ tmp。[&1] .cityServiceCategoryList”, “ cityId”:“ tmp。[&1] .cityId” } } }, { “ operation”:“默认”, “规格”:{ “ tmp”:[

     ]
  }

}, { “ operation”:“ shift”, “规格”:{ “ tmp”:[ ” ] } }

]

当前输出JSON:

{
"content": [
    {
        "cityServiceCategoryList": [
            {
                "categoryId": "4",
                "category": "Library",
                "description": "Use many advantages",
                "cityServiceList": [
                    {
                        "serviceId": 8,
                        "service": "Library",
                        "description": "Use many advantages",
                        "restricted": true,
                        "serviceAction": [
                            {
                                "actionId": null,
                                "action": null                                  
                            }
                        ]
                    }
                ]
            },
            {
                "categoryId": "11",
                "category": "Transport",
                "description": "With the ys.",
                "cityServiceList": [
                    {
                        "serviceId": 20,
                        "service": "Public Transport",
                        "description": "How to buy rt buying ",
                        "restricted": false,
                        "serviceAction": [
                            {
                                "actionId": 1,
                                "action": "2"                               
                            }
                        ]
                    }
                ]
            },
            {
                "categoryId": "12",
                "description": "Your engagement.",
                "cityServiceList": [
                    {
                        "serviceId": 21,
                        "service": "Citizen-Participation",
                        "description": "Shape!",
                        "restricted": false,
                        "serviceAction": [
                            {
                                "actionId": 3,
                                "action": "1"                                  
                            }
                        ]
                    },
                    {
                        "serviceId": 21,
                        "service": "Citizen-Participation",
                        "description": "Shape!",
                        "restricted": false,
                        "serviceAction": [
                            null,
                            {
                                "actionId": 5,
                                "action": "1"                                
                            }
                        ]
                    },
                    {
                        "serviceId": 21,
                        "service": "Citizen-Participation",
                        "description": "Shape!",
                        "restricted": false,
                        "serviceAction": [
                            null,
                            null,
                            {
                                "actionId": 7,
                                "action": "1"                                  
                            }
                        ]
                    },
                    {
                        "serviceId": 21,
                        "service": "Citizen-Participation",
                        "description": "Shape!",
                        "restricted": false,
                        "serviceAction": [
                            null,
                            null,
                            null,
                            {
                                "actionId": 9,
                                "action": "1"                                   
                            }
                        ]
                    }
                ]
            }
        ],
        "cityId": 4
    }
]

}

0 个答案:

没有答案