bhaskaran
bhaskaran

Reputation: 19

Conversion of string to array in jolt transformation

I have a input json like this:

Input:

{
     "userstatus": {
         "authtype": "S,R,T",
     }
}

Here i need to change for the key - authtype and put those values into an array .

Expected Json:

{
    "userstatus": {
        "authtype": ["S","R","T"]
    }
}

But actual Output i got like this:

{
    "authtype" : [ "S,R,T" ]
}

JOLT SPEC:

[
    {
        "operation": "shift",
        "spec": {
            "userstatus": {
                "authtype": "authtype.[]"
            }
        }
    }
]

Please help me for the above test case?

Upvotes: 1

Views: 3467

Answers (1)

Magda
Magda

Reputation: 482

Here is yours spec. You should use split function in modify operation.

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "userstatus": {
        "authtype": "=split(',',@(1,authtype))"
      }
    }
  }
]

Upvotes: 2

Related Questions