Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Starting with NiFi JOLT Transformations: create a list with a JSON inside

avatar
New Contributor

I'm stating with Jolt Transformation Processor in NiFi and I so far to understand the Jolt logic.

 

I want to apply a simple transformation to insert a provided JSON into a list.

 

provided JSON:

{
   Label1:Value1,
   Label2:Value2
}

 

expected result:

{

GeneralLabel:[

                   {
                      Label1:Value1,
                      Label2:Value2
                   }

                  ]

}

 

Any clue about how to do it? In working with shift operation but without results.

1 ACCEPTED SOLUTION

avatar
Super Guru

Hi,

 

First of all make sure that the provided json is in valid format . What you provided in your example doesnt have double quotes surrounding the key\value as in

{
"Label1": "Value1",
"Label2": "Value2"
}

 

Assuming thejson is valid , you can use the following jolt spec to produce expected output:

 

[
  {
    "operation": "shift",
    "spec": {
      "*": "GeneralLabel[#].&"
    }
  }
]

 

To learn more about jolt transformation please refer to :

https://jolt-demo.appspot.com/#inception

https://intercom.help/godigibee/en/articles/4044359-transformer-getting-to-know-jolt

 

If that helps please accept solution.

Thanks

 

 

View solution in original post

2 REPLIES 2

avatar
Super Guru

Hi,

 

First of all make sure that the provided json is in valid format . What you provided in your example doesnt have double quotes surrounding the key\value as in

{
"Label1": "Value1",
"Label2": "Value2"
}

 

Assuming thejson is valid , you can use the following jolt spec to produce expected output:

 

[
  {
    "operation": "shift",
    "spec": {
      "*": "GeneralLabel[#].&"
    }
  }
]

 

To learn more about jolt transformation please refer to :

https://jolt-demo.appspot.com/#inception

https://intercom.help/godigibee/en/articles/4044359-transformer-getting-to-know-jolt

 

If that helps please accept solution.

Thanks

 

 

avatar
New Contributor

Thank you very much SAMSAL, I apreciate it, specially the references you provide.