JOLT Transformation Spec - PullRequest
       8

JOLT Transformation Spec

0 голосов
/ 26 апреля 2020

Я пытаюсь написать JOLT Spe c, но застрял. Не могли бы вы мне помочь?

Ввод 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
    }
]

}

Текущая скорость c:

[

{"операция": "смещение", "spe c ": {" ": {" categoryId ": {"": {" @ 2 ":" & [] "}}}}}, {" operation ":" shift "," spe c ": {" ": {" 0 ": {" cityId ":" e & 2.cityId "," category ":" e & 2.category "," cityServiceCategoryDescription ":" 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": "е & 2.cityServiceList [& 1] .descriptio n "" ОГРАНИЧЕНО ":" e & 2.cityServiceList [& 1] .restricted "," actionId ":" e & 2.cityServiceList [& 1] .serviceAction [& 1] .actionId "," action ":" e & 2.cityServiceList [& 1] .serviceAction [& 1] .action "

        }
     }
  }

}, {" operation ":" shift "," spe c ": {" ":" cityServiceCategoryList [] "}}, {" операция ":" смещение "," spe c ": {" cityServiceCategoryList ": {" 0 ": {" cityId ":" cityId "," @ ":" cityServiceCategoryList "},"": {" @ ":" cityServiceCategoryList "}}}}, {" operation ":" remove "," spe c ": {" cityServiceCategoryList ": {" ": {" cityId ":" "}}}}} , {"операция": "смещение", "spe c": {"@ 1": "[]"}}, {"операция": "смещение", "spe c": {" ": {" cityServiceCategoryList ":" tmp. [& 1] .cityServiceCategoryList "," cityId ":" tmp. [& 1] .cityId "}}}, {" operation ":" default "," spe c " : {"tmp": [

     ]
  }

}, {"operation": "shift", "spe c": {"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
    }
]

}

...