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!

Jolt Spec for populating field based on value of another field

avatar
Explorer

I want to populate my target JSON with a field based on value of another field.

e.g.

Input JSON:
[

{
"examUrl": "https://exam.test.com/page/1473161074",
"urlTypeName": "Spring URL"
},

{
"examUrl": "https://exam.test.com/page/12423222",
"urlTypeName": "Java URL"
},

]

 

Expected Output:

{

"ExamDashBoardURL" : "https://exam.test.com/page/1473161074"

}

In the above example, I will populate ExamDashBoardURL only if urlTypeName is "Spring URL".

Can anyone please help me on this.

Thanks and Regards,

Biswa

 

 

1 ACCEPTED SOLUTION

avatar
Explorer

I found out the solution. It may be helpful for someone.

If anyone has better spec, please let me know

[
{
"operation": "shift",
"spec": {
"*": {
"urlTypeId": {
"1": {
"@2": "domoDashboardLink"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"domoDashboardLink": {
"examUrl": "&1"
}
}
}
]

View solution in original post

2 REPLIES 2

avatar
Explorer

I found out the solution. It may be helpful for someone.

If anyone has better spec, please let me know

[
{
"operation": "shift",
"spec": {
"*": {
"urlTypeId": {
"1": {
"@2": "domoDashboardLink"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"domoDashboardLink": {
"examUrl": "&1"
}
}
}
]

avatar
Expert Contributor

Hi @Biswa,

Please look at the below spec:

[
{
"operation": "shift",
"spec": {
"*": {
"urlTypeName": {
"Spring URL": {
"@(2,examUrl)": "ExamDashBoardURL[]"
}
}
}
}
}
]

Output will be:

{
"ExamDashBoardURL" : [ "https://exam.test.com/page/1473161074" ]
}

Tell me if this is ok.