I need to extract the email address from value where "name":"username" from this JSON using JOLT:
I thought it would be
customer:{
"*":{
"name"{
"username":"email.@(2,value)
}
}
}
Input
{
"customer": [
{
"name": "title",
"value": "Mr"
},
{
"name": "address",
"value": "park road"
},
{
"name": "username",
"value": "[email protected]"
}
]
}
Expected Output
{
"email":"[email protected]
}
CodePudding user response:
Just worked it out:
customer:{
"*":{
"name"{
"username":
"@(2,value)":"email"
}
}
}
CodePudding user response:
I think you need a spec containing such a conditional
[
{
"operation": "shift",
"spec": {
"*": { // represents the array
"*": { // represents the indexes of the array
"name": {
// in order to pick the desired condition
"username": {
// go 2 levels up and grab the value of "value" key
// as roaming within each objects of the main array(customer)
// [eg. reaching the level of the indexes of the array]
"@(2,value)": "email" //rename the key as desired
}
}
}
}
}
}
]