0

Not sure if this is possible in jolt. We are trying to extract a value whose field name is indexed by another field. Please take a look at the description below.

{
  "_src" : {
    "SomeName" : 123,
    "FName" : "SomeName"
  }
}

to

{
  "val": "123",
  "_src" : {
    "SomeName" : 123,
    "FName" : "SomeName"
  }
}

Any ideas on how approach this, or if this is even possible in JOLT? Thanks

JoaoCC
  • 624
  • 6
  • 15

1 Answers1

0

Using shift spec:

  1. Match on _src
  2. Set value using SomeName
  3. Using syntax @(1,src) which means go up 1 level and copy src, & will get the name of the current element.
[
  {
    "operation": "shift",
    "spec": {
      "_src": {
        "SomeName": "val",
        "@(1,_src)": "&"
      }
    }
  }
]
Matthew Warman
  • 3,234
  • 2
  • 23
  • 35