0

I have a list of JSON objects, converted from the result of a SQL query. The JSON looks like this:

[ {
        "CREATE_DATE_TIME" : "2018-02-04 11:00:03.0",
        "EXTERNAL_ID" : "1111",
        "CERT_NUMBER" : "123",
        "DESCRIPTION" : "DESC 1",
        "SOURCE_SYSTEM" : "WOULDIWAS"
    }, {
        "CREATE_DATE_TIME" : "2018-03-01 11:25:03.0",
        "EXTERNAL_ID" : "2222",
        "CERT_NUMBER" : "456",
        "DESCRIPTION" : "DESC 2",
        "SOURCE_SYSTEM" : "SHOOKSPEARE"
    }, 
    ... 
]

The output after JSON transform should be something like this:

{
    "Jobs": [
        {
            "Notification": {
                "ActivityDate" : "2018-02-04 11:00:03.0",
                "ExternalId" : "1111",
                "CertNum" : "123",
                "Description" : "DESC 1",
                "SourceSystem" : "WOULDIWAS",
                "RecordType" : "Task Notification"
            }, {
            "Notification": {   
                "ActivityDate" : "2018-03-01 11:25:03.0",
                "ExternalId" : "2222",
                "CertNum" : "456",
                "Description" : "DESC 2",
                "SourceSystem" : "SHOOKSPEARE",
                "RecordType" : "Task Notification"
            }, 
        ... 
    ]
}

(The RecordType is a literal string, not derived from the input JSON)

Each row / entry (JSON object enclosed in {}) in the input JSON is guaranteed to be unique but there is no key here that would indicate that. The row / entry in the input should correspond 1-1 to { Notification: {...} } in the output. How should I construct my Jolt Spec to do this?

oikonomiyaki
  • 7,691
  • 15
  • 62
  • 101

1 Answers1

1

Not to sound offending or anything, but you should've posted what you've already tried. Anyway here's the spec to get your intended output format

[ { "operation": "shift", "spec": { "*": "Jobs[].Notification" } } ]

I would suggest you try out renaming the fields yourself, because practicing JOLT is the best way to learn

If you still need help, I'll complete the answer for you.

Here's a few reading material Documentation, the Slide deck. And you can learn a lot from the issues page where Milo Simpson has already solved queries for most of your questions.

noskillnoob
  • 121
  • 1
  • 9