我怎样才能纠正这个 Jolt 转换?

时间:2021-04-07 22:07:34

标签: arrays json jolt

这是一个需要使用 Jolt Transformation 进行转换以获得预期输出的输入。

我正在尝试为以下输入编写震动转换。 但它与预期的输出不匹配。

我的输入:

{
    "ConsolidatedList": [
        { 
            "AliasType": "AKA",
            "AliasTypeName": "AKA",
            "BusinessRegNumber": {
                "nil": null
            },
            "nil": null,
            "Country": null,
            "CountryOfBirth": "Syria",
            "CurrentOwners": {
                "nil": null
            },
            "DateListed": "2021-03-15T00:00:00",
            "DateListedDay": 15,
            "DateListedMonth": 3,
            "DateListedYear": 2021,
            "DateOfBirth": "01/09/1975",
            "DateOfBirthId": 4751,
            "DayOfBirth": 1,
            "EmailAddress": {
                "nil": null
            },
            "FCOId": "SYR0377",
            "FlagOfVessel": {
                "nil": null
            },
            "FullAddress": null,
            "FullName": " Al Shebil Luna    ",
            "FurtherIdentifiyingInformation": {
                "nil": null
            },
            "Gender": "Female",
            "GroupID": 14070,
            "GroupStatus": "Asset Freeze Targets",
            "GroupTypeDescription": "Individual",
            "GrpStatus": "A",
            "HIN": {
                "nil": null
            },
            "ID": 33233,
            "IMONumber": {
                "nil": null
            },
            "LastUpdated": "2021-03-15T00:00:00",
            "LastUpdatedDay": 15,
            "LastUpdatedMonth": 3,
            "LastUpdatedYear": 2021,
            "LengthOfVessel": {
                "nil": null
            },
            "ListingType": "UK autonomous",
            "MonthOfBirth": 9,
            "Name6": "Al Shebil",
            "NameTitle": null,
            "NationalIdNumber": {
                "nil": null
            },
            "Nationality": "Syria",
            "OrgType": {
                "nil": null
            },
            "OtherInformation": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
            "ParentCompany": {
                "nil": null
            },
            "PassportDetails": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
            "PhoneNumber": {
                "nil": null
            },
            "Position": "Media Adviser to President Assad",
            "PostCode": null,
            "PreviousFlags": {
                "nil": null
            },
            "PreviousOwners": {
                "nil": null
            },
            "RegimeName": "Syria",
            "Subsidiaries": {
                "nil": null
            },
            "TonnageOfVessel": {
                "nil": null
            },
            "TownOfBirth": "Suweida",
            "TypeOfVessel": {
                "nil": null
            },
            "UKStatementOfReasons": "Adviser to President Assad and a prominent member of his inner circle. As Media Adviser to the President she supports the Syrian regime, which relies on disinformation and a lack of media freedom to repress the civilian population. She is also associated with the Syrian regime through her role as an adviser.\n",
            "Website": {
                "nil": null
            },
            "YearBuilt": {
                "nil": null
            },
            "YearOfBirth": 1975,
            "address1": null,
            "address2": null,
            "address3": null,
            "address4": null,
            "address5": null,
            "address6": null,
            "name1": "Luna",
            "name2": null,
            "name3": null,
            "name4": null,
            "name5": null
        },
        { 
            "AliasType": "AKA",
            "AliasTypeName": "AKA",
            "BusinessRegNumber": {
                "nil": null
            },
            "nil": null,
            "Country": null,
            "CountryOfBirth": "Syria",
            "CurrentOwners": {
                "nil": null
            },
            "DateListed": "2021-03-15T00:00:00",
            "DateListedDay": 15,
            "DateListedMonth": 3,
            "DateListedYear": 2021,
            "DateOfBirth": "01/09/1975",
            "DateOfBirthId": 4751,
            "DayOfBirth": 1,
            "EmailAddress": {
                "nil": null
            },
            "FCOId": "SYR0377",
            "FlagOfVessel": {
                "nil": null
            },
            "FullAddress": null,
            "FullName": " Al Shebil Luna    ",
            "FurtherIdentifiyingInformation": {
                "nil": null
            },
            "Gender": "Female",
            "GroupID": 14070,
            "GroupStatus": "Asset Freeze Targets",
            "GroupTypeDescription": "Individual",
            "GrpStatus": "A",
            "HIN": {
                "nil": null
            },
            "ID": 33233,
            "IMONumber": {
                "nil": null
            },
            "LastUpdated": "2021-03-15T00:00:00",
            "LastUpdatedDay": 15,
            "LastUpdatedMonth": 3,
            "LastUpdatedYear": 2021,
            "LengthOfVessel": {
                "nil": null
            },
            "ListingType": "UK autonomous",
            "MonthOfBirth": 9,
            "Name6": "Al Shebil",
            "NameTitle": null,
            "NationalIdNumber": {
                "nil": null
            },
            "Nationality": "Syria",
            "OrgType": {
                "nil": null
            },
            "OtherInformation": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
            "ParentCompany": {
                "nil": null
            },
            "PassportDetails": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
            "PhoneNumber": {
                "nil": null
            },
            "Position": "Media Adviser to President Assad",
            "PostCode": null,
            "PreviousFlags": {
                "nil": null
            },
            "PreviousOwners": {
                "nil": null
            },
            "RegimeName": "Syria",
            "Subsidiaries": {
                "nil": null
            },
            "TonnageOfVessel": {
                "nil": null
            },
            "TownOfBirth": "Suweida",
            "TypeOfVessel": {
                "nil": null
            },
            "UKStatementOfReasons": "Adviser to President Assad and a prominent member of his inner circle. As Media Adviser to the President she supports the Syrian regime, which relies on disinformation and a lack of media freedom to repress the civilian population. She is also associated with the Syrian regime through her role as an adviser.\n",
            "Website": {
                "nil": null
            },
            "YearBuilt": {
                "nil": null
            },
            "YearOfBirth": 1975,
            "address1": null,
            "address2": null,
            "address3": null,
            "address4": null,
            "address5": null,
            "address6": null,
            "name1": "Hassan",
            "name2": "Muh",
            "name3": "Cane",
            "name4": null,
            "name5": null
        }
    ]
}

预期的输出是 -

{
    "Count": "2", // Counter for the number of records
    "LastUpdated": "08/03/2020 12:00:00",
    "RecordType": [
        "Entity",
        "Individual",
        "Vessel"
    ],
    "Pages": "1",
    "Records": [
        {
            "_id": "1", // Counter 
            "AdditionalInformation": "Other Information: (UK Sanctions List Ref):AQD0081 (UN Ref):QDe.014 (Further Identifiying Information):Headed by Abdelmalek Droukdel (QDi.232).Zone of operation includes  Algeria and parts of Mali, Mauritania, Niger, Tunisia and Morocco.Review pursuant to Security Council resolution 1822 (2008) was concluded on 21 Jun.2010.INTERPOL-UN Security Council Special Notice web link: https://www.interpol.int/en/notice/search/une/5278467; Listed On: 10/10/2001; Last Updated: 12/31/2020; Group ID: 7247",
            "RecordType": "Entity",
            "Names": [
                {
                    "_id": "1", //counter 
                    "OtherName": "THE ORGANIZATION OF AL-QAIDA IN THE ISLAMIC MAGHREB",
                    "UnparsedName": "",
                    "FirstName": "",
                    "LastName": "",
                    "NameType": "Primary"
                },
                {
                    "_id": "2",
                    "OtherName": "AL QAIDA AU MAGHREB ISLAMIQUE (AQMI)",
                    "UnparsedName": "",
                    "FirstName": "",
                    "LastName": "",
                    "NameType": "Alias"
                },
                {
                    "_id": "3",
                    "OtherName": "AQIM",
                    "UnparsedName": "",
                    "FirstName": "",
                    "LastName": "",
                    "NameType": "Alias"
                },
                {
                    "_id": "4",
                    "OtherName": "LE GROUPE SALAFISTE POUR LA PREDICATION ET LE COMBAT (GSPC)",
                    "UnparsedName": "",
                    "FirstName": "",
                    "LastName": "",
                    "NameType": "Formerly Known As"
                },
                {
                    "_id": "5",
                    "OtherName": "SALAFIST GROUP FOR CALL AND COMBAT",
                    "UnparsedName": "",
                    "FirstName": "",
                    "LastName": "",
                    "NameType": "Formerly Known As"
                }
            ],
            "Addresses": [
                {
                    "_id": "1",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Algeria",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "2",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Mali",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "3",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Mauritania",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "4",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Morocco",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "5",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Niger",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "6",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Tunisia",
                        "RelationType": "Address"
                    }
                }
            ],
            "Sanctions": [
                {
                    "_id": "1",
                    "Sanction": "HM Treasury Al-Qaida Sanction",
                    "ExpirationDate": "",
                    "SanctionDate": ""
                }
            ]
        },
        {
            "_id": "2",
            "AdditionalInformation": "Other Information: (UK Sanctions List Ref):AFG0110 (UN Ref): TAi.142 (Further Identifiying Information):Review pursuant to Security Council resolution 1822 (2008) was concluded on 29 Jul. 2010. INTERPOL-UN Security Council Special Notice web link: https://www.interpol.int/en/How-we-work/Notices/View-UN-Notices-Individuals click here.; Listed On: 02/23/2001; Last Updated: 2/1/2021; Group ID: 6895",
            "RecordType": "Person",
            "Names": [
                {
                    "_id": "1",
                    "OtherName": "",
                    "UnparsedName": "",
                    "FirstName": "Abdul Hai Hazem",
                    "LastName": "ABDUL QADER",
                    "NameType": "Primary"
                },
                {
                    "_id": "2",
                    "OtherName": "",
                    "UnparsedName": "",
                    "FirstName": "Abdul Hai",
                    "LastName": "HAZEM",
                    "NameType": "Alias"
                }
            ],
            "Identifiers": [
                {
                    "_id": "1",
                    "IDValue": "1971",
                    "IDType": "Date Of Birth"
                },
                {
                    "_id": "2",
                    "IDValue": "Pashawal Yargatoo village, Andar District, Ghazni Province, Afghanistan",
                    "IDType": "Place Of Birth"
                },
                {
                    "_id": "3",
                    "IDValue": "D 0001203 (Afghan)",
                    "IDType": "Passport"
                }
            ],
            "Addresses": [
                {
                    "_id": "1",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "Kabul Province",
                    "Country": {
                        "Name": "Afghanistan",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "2",
                    "PostalCode": "",
                    "Street": "",
                    "City": "Kabul City",
                    "StateProvince": "Kabul Province",
                    "Country": {
                        "Name": "",
                        "RelationType": "Address"
                    }
                },
                {
                    "_id": "3",
                    "PostalCode": "",
                    "Street": "",
                    "City": "",
                    "StateProvince": "",
                    "Country": {
                        "Name": "Afghan",
                        "RelationType": "Nationality"
                    }
                }
            ],
            "Sanctions": [
                {
                    "_id": "1",
                    "Sanction": "HM Treasury Afghanistan Sanction",
                    "ExpirationDate": "",
                    "SanctionDate": ""
                }
            ]
        }
    ]
}

我的规格是 -

[
    {
        "operation" : "shift",
        "spec": {
            "ConsolidatedList": {
                "*": {
                    "GroupTypeDescription": "RecordType",
                    "LastUpdated": "LastUpdated",
                    "UKStatementOfReasons": "Records.AdditionalInformation",
                    "Name6": "Records.Names.[&1].Other Name",
                    "name3": "Records.Names.[&1].UnparsedName",
                    "name1": "Records.Names.[&1].FirstName",
                    "name2": "Records.Names.[&1].LastName",
                    "AliasType": "Records.Names.[&1].NameType",
                    "PostCode": "Records.Address.[&1].PostalCode",
                    "address2": "Records.Address.[&1].Street",
                    "address6": "Records.Address.[&1].City",
                    "Country": "Records.Address.[&1].StateProvince",
                    "CountryOfBirth": "Records.Address.[&1].Country.Name"
                    }
                }
            }
    },
    {
        "operation": "modify-overwrite-beta",
        "spec" : {
            "Count": "size(1,Records)",
            "Pages": "1"
            }
        }
]

规范未按预期输出转换。

0 个答案:

没有答案