Skip to main content
learnNifi
Silver ⭐️
March 8, 2022
Solved

Jolt Transform help on json to add another array layer

I am a newbie to Nifi Jolt transform.  I've been looking through the document, but still cannot figure out how to do a simple Jolt Transform.

Input:

{"id": 123456,

"manager_id": 98765}

desired output:

{"reportTo": [{"userId": 98765}]}

 

I've got the part to change the manager_id to userId by the following Spec.  But I was stuck how to make it another layer.  Any insights/help to solve this? 

[{
"operation": "shift",
"spec": {
"manager_id": "userId"}
}
}]

araujo
araujoAnswer
Platinum ⭐️⭐️⭐️
March 8, 2022

@learnNifi ,

 

Try this one out: 

 

 

 

 

[
{
"operation": "shift",
"spec": {
"id": "&",
"manager_id": "report_to[0].id"
}
}
]

 

 

 

 

 

Cheers,

André

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.

2 replies

araujo
Platinum ⭐️⭐️⭐️
araujoAnswer
Platinum ⭐️⭐️⭐️
March 8, 2022

@learnNifi ,

 

Try this one out: 

 

 

 

 

[
{
"operation": "shift",
"spec": {
"id": "&",
"manager_id": "report_to[0].id"
}
}
]

 

 

 

 

 

Cheers,

André

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Translate
-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.
learnNifi
learnNifiAuthor
Silver ⭐️
March 9, 2022

This works perfectly!  Thank you

Translate