skip to Main Content

I have an attribute "TEST" storing a JSON object, I tried this JOLT but I’m getting

"Unable to marshal json to an object"

error

TEST:

[
  {
    "ORDER_DATE": "2022-04-11",
    "TIME_STAMP": "1667543037000"
  },
  {
    "ORDER_DATE": "2022-05-05",
    "TIME_STAMP": "1651741666000"
  }
]

JOLT Transformation :

[
  {
    "operation": "shift",
    "spec": {
      "TIMESTAMP": "timeStamp"
    }
  },
  {
    "operation": "default",
    "spec": {
      "product": "Billing Account CMT Update",
      "team": "${TEST}"
    }
  }
]

Expected Output :

{
  "product": "Billing Account CMT Update",
  "team": [
    {
      "ORDER_DATE": "2022-04-11",
      "TIME_STAMP": "1667543037000"
    },
    {
      "ORDER_DATE": "2022-05-05",
      "TIME_STAMP": "1651741666000"
    }
  ]
}

Edit 1: It can probably be possible with ReplaceText processor but I want pure JOLT solution

2

Answers


  1. Is this what you mean?

    [
      {
        "operation": "shift",
        "spec": {
          "*": "team[]"
        }
      },
      {
        "operation": "default",
        "spec": {
          "product": "Billing Account CMT Update"
        }
      }
    ]
    
    Login or Signup to reply.
  2. Most probably you get that error due to the fact that the

    com.fasterxml.jackson.core.JsonParseException

    is raised, cause the attribute must be passed as a string while the JSON value contains some unquoted characters.

    In that case, you might convert

    the part "team":"${TEST}" to "team":"${TEST:escapeJson()}"

    in order to get rid of the issue.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search