08-11-2023 01:37 PM
My source data looks like this. I want to rename "Emp.Type" column to "EmpType" in a single expression without impacting the other columns in json file. I don't want to use column map in mapper where we can rename the column name with individual desired column name since this pipeline is generic one which will be used across application. Single expression will help me to pass this expression at run time to get the output
Source Data
--------------------
{
"Body": "New Hire",
"CreatedById": "00553000002Ga35AAC",
"CreatedDate": "2022-10-24T17:09:24.000Z",
"empid": "1234",
"Emp.Type": "Full Time",
}
Desired Output
--------------------
{
"Body": "New Hire",
"CreatedById": "00553000002Ga35AAC",
"CreatedDate": "2022-10-24T17:09:24.000Z",
"empid": "1234",
"EmpType": "Full Time",
}
Solved! Go to Solution.
08-12-2023 09:32 AM
Hi @adityamohanty ,
Good day, you can use mapKeys or string manipulation
** only top level keyname will be updated
$.mapKeys((val,key)=> key == 'Emp.Type' ? 'EmpType' : key)
** global, replace all matching Emp.Type string to EmpType
JSON.parse(JSON.stringify($).replace(/Emp.Type/gm, m => match m {'Emp.Type'=> 'EmpType'}))
~EmEm
08-17-2023 06:24 PM
Thank You @alchemiz. It worked for me
08-12-2023 09:32 AM
Hi @adityamohanty ,
Good day, you can use mapKeys or string manipulation
** only top level keyname will be updated
$.mapKeys((val,key)=> key == 'Emp.Type' ? 'EmpType' : key)
** global, replace all matching Emp.Type string to EmpType
JSON.parse(JSON.stringify($).replace(/Emp.Type/gm, m => match m {'Emp.Type'=> 'EmpType'}))
~EmEm
08-17-2023 06:24 PM
Thank You @alchemiz. It worked for me