简体   繁体   中英

Jolt transformation spec for the key Value pair after modifying values

This is the input

"header": {
        "FOO": "VALUE1",
        "BAR": "VALUE2",
      }

Expected Output

 {
      "Random_VALUE1": "Random_VALUE1"
     } 

SO the output needs a key which is a combination of one of the key's value and some String, and the output should contain this output as key and value

This is how far I have reached

{
     "operation": "modify-default-beta",
     "spec": {
       "*": {
         "e": "=concat('RANDOM_',@(1,FOO))",
         "r": "=concat('RANDOM_',@(1,FOO))"
       }
     }
   },
   {
     "operation": "modify-overwrite-beta",
     "spec": {
       "*": {
         "&e": "[&2].@e",
         "&r": "[&2].@r"
       }
     }
    }

The spec is throwing error OVERWRITR cannot have AmpPathElement RHS I am not sure what is wrong with the approach I am using and what should be the spec for the output

Not sure if this is what you meant, but there goes a try;)

Input :

{
  "header": {
    "FOO": "VALUE1",
    "BAR": "VALUE2"
  }
}

Spec :

[
  {
    "operation": "modify-default-beta",
    "spec": {
      "*": {
        "e": "=concat('RANDOM_',@(1,FOO))",
        "r": "=concat('RANDOM_',@(1,BAR))"
      }
    }
   },
  {
    "operation": "shift",
    "spec": {
      "*": {
        "e": ".@(1,e)",
        "r": ".@(1,r)"
      }
    }
   }
]

Output :

{
  "RANDOM_VALUE1" : "RANDOM_VALUE1",
  "RANDOM_VALUE2" : "RANDOM_VALUE2"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM