0

I want to mask few fields based on "Masking_col" from the input.

Below is the expected input:

{
  "IN_num": "1",
  "In_Details": "notworking",
  "customer_name": "abc",
  "customer_location": "Hyd",
  "customer_ID": "1001",
  "customer_name0": "abc",
  "Masking_col": "customer_location,customer_ID"
}

Here "Masking_col" contains "customer_location,customer_ID" these two field name, so in the output these two filed will be set to blank. Expected output will be:

{
  "IN_num": "1",
  "In_Details": "notworking",
  "customer_name": "abc",
  "customer_location": "",
  "customer_ID": "",
  "customer_name0": "abc",
  "Masking_col": "customer_location,customer_ID"
}

1 Answer 1

2

You can start with a split function within a modify transformation in order to get individual values to be evaluted lately as attribute names ( eg. "customer_location" and "customer_ID" ). Then combine their values as arrays which will have null values as the last components those will be converted to blank values within the last transformation such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "MCol": "=split(',',@(1,Masking_col))"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": "&",
      "MCol": {
        "*": {
          "*": "&"
        }
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": "=lastElement",
      "customer_location|customer_ID": ["=isNull", ""]
    }
  }
]

the demo on the site http://jolt-demo.appspot.com/ is :

enter image description here

1
  • 1
    Thank you @Barbaros, It worked like champ!
    – priyanka
    Commented Aug 29, 2023 at 5:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.