โ06-20-2022 04:27 AM
Hello Experts,
I have a requirement where I need to change the value of one single key in an object.
INPUT:
[
{
"soapenv:Envelope": {
"@xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
"@xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"soapenv:Body": {
"ns1:MT_SWE_FI_PEGA_ABAON": {
"@xmlns:ns1": "http://xyz.com",
"SYSTEMID": "AB1",
"CLIENT": "090",
"INPUT": {
"S_BUKRS": "00",
"S_ANLN1": "12345678",
"S_ANLN2": "0000",
"S_ZUGDT": "2022-06-20",
"ERLBT": "100"
}
}
}
}
}
]
Here I just need to change key โCLIENTโ to โCLIENTIDโ.
Thanks in Advance
Solved! Go to Solution.
โ06-20-2022 05:09 AM
you should use the function mapKeys in a mapper snap to get the key value and rename it.
Inside the mapper snap you should use this expression:
$[โsoapenv:Envelopeโ][โsoapenv:Bodyโ][โns1:MT_SWE_FI_PEGA_ABAONโ].mapKeys((value, key) => key == โCLIENTโ ? โCLIENTIDโ : key)
This expression will first check every key if it equals the value โCLIENTโ and if true it will rename it to whatever you want to rename it to. If false the key name is not changed
And give as target path the path of the original one until the object that contains CLIENT
$[โsoapenv:Envelopeโ][โsoapenv:Bodyโ][โns1:MT_SWE_FI_PEGA_ABAONโ]
The result:
Regards
Jens
โ06-20-2022 05:09 AM
you should use the function mapKeys in a mapper snap to get the key value and rename it.
Inside the mapper snap you should use this expression:
$[โsoapenv:Envelopeโ][โsoapenv:Bodyโ][โns1:MT_SWE_FI_PEGA_ABAONโ].mapKeys((value, key) => key == โCLIENTโ ? โCLIENTIDโ : key)
This expression will first check every key if it equals the value โCLIENTโ and if true it will rename it to whatever you want to rename it to. If false the key name is not changed
And give as target path the path of the original one until the object that contains CLIENT
$[โsoapenv:Envelopeโ][โsoapenv:Bodyโ][โns1:MT_SWE_FI_PEGA_ABAONโ]
The result:
Regards
Jens
โ06-20-2022 05:55 AM
Thanks Jens. It worked