Skip to main content
Biswa
Gold ⭐️
Feb 19, 2020 8:56 AM UTC
Solved

Jolt Spec for populating field based on value of another field

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

 

 

Biswa
BiswaAnswer
Gold ⭐️
Feb 25, 2020 1:26 PM UTC

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"
}
}
}
]

2 replies

Biswa
BiswaAuthorAnswer
Gold ⭐️
Feb 25, 2020 1:26 PM UTC

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"
}
}
}
]

Translate
PVVK
Gold ⭐️
Sep 30, 2020 6:03 PM UTC

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.

Translate