I have the following JSON :
{
"Content": [
{
"CandidateFirstName": "Nagu",
"Applications": {
"ApplicationId": "456",
"Sarasa": "test"
}
},
{
"CandidateFirstName": "Deleted",
"Applications": {
"ApplicationId": "123",
"Sarasa": "test2"
}
}
]
}
and I’d like to have the following output:
[
{
"FirstName": "Nagu",
"ApplicationsId": "456",
"Sarasa": "test"
},
{
"FirstName": "Deleted",
"ApplicationsId": "123",
"Sarasa": "test2"
}
]
I’m close with the following jolt, but I’m not being able to remove the object "Applications":
[
{
"operation": "shift",
"spec": {
"Content": {
"*": {
"CandidateFirstName": "[&1].FirstName",
"Applications": "[&1].Applications"
}
}
}
}
]
Do you know how to achieve this?
Thanks in advance!
3
Answers
You can use two consecutive shift transformation specs
or use a single spec such as
where
[#2]
, as having a # wildcard and nested within square brackets and staying on the right-hand-side, represents traversing one colon(:
), and one opening curly brace{
those makes 2 in order to reach the level of the indexes of theContent
array to grab them.Yet, there’s another method as follows :
where
[&2]
on the RHS represents traversing two opening curly braces in contrast to the[#2]
You can use this short and concise spec:
Yes, you were quite close. You have to just add one more level of nested section for Applications section