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!

regex on keys jolt

avatar
New Contributor

Hi, 

 

I'd like to catch any key that match a certain reg ex in jolt. The purpose is to clean and order keys into the proper name. An example worth thoushand words: 

possible inputs:

{

"my_id":234535,

"my company sa": "whatever value",

"my comp RH": "whatever value",

...

}

{

"my_id":234536,

"my_comp_sa" : "whatever value",

"DRH" : "whatever value"

...

}

 

output:

{

"my_id":234535,

"my_company_sa": "whatever value",

"my_company_rh" : "whatever value"

}

2 REPLIES 2

avatar
Super Guru

Hi,

I'm not sure if you can use Regex in jolt transformation,  but you can use wildcard (*) instead. Keep in mind even with Regex you still need to find the common denominator for each attribute to be able to match, so wildcard should suffice. To use the wildcard you can apply something like this to your spec:

 

[
  {
    "operation": "shift",
    "spec": {
      "my_id": "my_id",
      "my*company*sa": "my_company_sa",
      "*RH": "my_company_rh"
    }
  }
]

 Hope that helps, if it does please accept solution.

Thanks

avatar
New Contributor

Actually, it looks like this kind of regEx does not work. Though my question. I'm using Nifi 11.4... 

Thank you for your feedback 🙂