To replace more than one character in string by looking up another field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 10:29 AM
I have a business requirement, where we have below JSON in that, have to update object’s field called TRANSLATION_ID by looking up another fields called VARIABLE_ID and VARIABLE_VALUE. Here if both VARIABLE_ID and VARIABLE_VALUE are not null then replace TRANSLATION_ID (say [A] to be replaceed with value in the variable value) with corresponding values present in VARIABLE_VALUE.
Note: Here currently we have max of 2 replacement values in VARIABLE_VALUE but we expect it can be more than 10.
Input json :
[
{
“PHRASE_SEQ”: 629,
“PHRASE_ID”: “[Drug Name]”,
“PLACEMENT”: “12”,
“TRANSLATION_ID”: “[Drug Name]”,
“VARIABLE_ID”: “Drug Name”,
“VARIABLE_VALUE”: “str456”
},
{
“PHRASE_SEQ”: 630,
“PHRASE_ID”: “Store at [A]°C to [B]°C”,
“PLACEMENT”: “13”,
“TRANSLATION_ID”: “Store at [A]°C to [B]°C”,
“VARIABLE_ID”: “A,B”,
“VARIABLE_VALUE”: “2,8”
}
]
Expected output would be:
[
{
“PHRASE_SEQ”: 629,
“PHRASE_ID”: “[Drug Name]”,
“PLACEMENT”: “12”,
“TRANSLATION_ID”: “str456”,
“VARIABLE_ID”: “Drug Name”,
“VARIABLE_VALUE”: “str456”
},
{
“PHRASE_SEQ”: 630,
“PHRASE_ID”: “Store at [A]°C to [B]°C”,
“PLACEMENT”: “13”,
“TRANSLATION_ID”: “Store at 2°C to 8°C”,
“VARIABLE_ID”: “A,B”,
“VARIABLE_VALUE”: “2,8”
}
]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2022 06:07 AM
Hi @Cele Thank you so much for the kind and detailed explanation, Really much helpful.
Thanks again for the support.
Regards,
Parthiban S
![](/skins/images/A5F8D4F9CE9DD11234D129690E6DC828/responsive_peak/images/icon_anonymous_message.png)