Skip to main content
meandeavour
Silver ⭐️
September 12, 2022
Question

regex on keys jolt

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

SAMSAL
Platinum ⭐️⭐️⭐️
September 12, 2022

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

Translate
meandeavour
Silver ⭐️
September 14, 2022

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 🙂 

Translate