Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I use '$' character in JOLT?

I’m trying to do some data transformation using JOLT for Apache nifi but I’m running into some problem.

The sample input is:

{
  "id": "1234"
}

The sample output is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
  "$distinct_id": "1234"
}

My JOLT Specs:

[
  {
    "operation": "shift",
    "spec": {
      "id": "$distinct_id"
    }
  }
]

But i’m getting this error

Error running the Transform.

JOLT Chainr encountered an exception constructing Transform className:com.bazaarvoice.jolt.Shiftr at index:0.

DotNotation (write key) can not contain '*' or '$' : write key: root.$distinct_id

NOTE: the ‘$’ is mandatory as it’s my payload for mixpanel

>Solution :

If your aim is to get exact JSON stated in the sample output, then you can use

[
  {
    "operation": "shift",
    "spec": {
      "id": "\\$distinct_&" // btw, & replicates the current key "id"
    }
  }
]

It has a special meaning that is returning the key’s value from the upper node.

This special character $ could be escaped through use of double backslashes.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading