cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

To replace more than one character in string by looking up another field value

RaymanPrince
New Contributor II

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โ€
}
]

5 REPLIES 5

parthiban_jks
New Contributor II

Hi @Cele Thank you so much for the kind and detailed explanation, Really much helpful.

Thanks again for the support.

Regards,
Parthiban S