Imran
2 years agoNew Contributor
Iterate over json document and pivot the output
I have input as below from source and target, where I need to find the difference between same columns from source (SRC) and target (TGT), and pivot the result to get the desired output as shown below
--My Input
[
{
"SRC_DATE": "2023-11-20 09:24:29.231",
"SRC_NAME": "AGENT",
"SRC_OWNER": "JHON",
"TGT_DATE": "2023-11-20 09:24:29.231",
"TGT_NAME": "AGENT",
"TGT_OWNER": "CHRIS",
"reason": "Source & Target Records Different",
"srcTable": "CLASS",
"primaryColumns": "DATE,NAME",
"nonPrimaryColumns": "OWNER",
"srcSchool": "TEST"
}
]
Desired output -
[
{
"COLUMN_NAME" : "SRC_OWNER",
"COLUMN_VALUE_SRC": "JHON",
"COLUMN_VALUE_TGT": "CHRIS",
"reason": "Source & Target Records Different",
"srcTable": "CLASS",
"primaryColumns": "DATE,NAME",
"nonPrimaryColumns": "OWNER",
"srcSchool": "TEST"
}
]