I need to convert xml to json but not the issue is xml is inside Json element . Is there any way we can do this in AWS lambda function in python ? The XML structure can change also ,I mean elements of xml can change also .
{
"data": {
"ID": "1234",
"DETAILS": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><testCasePayload><testId>1234</testId><status>COMPLETED</status><progressState>ONGOING</progressState><noOfNewSles>5</noOfNewSles><noOfSales>0</noOfSales><noOfAutoSales>0</noOfAutoSales><DealerTypes>WATCHLIST</DealerTypes></testCasePayload>",
},
"metadata": {
"timestamp": "2021-04-23T11:59:43.259184Z",
"record-type": "data",
"operation": "load",
"partition-key-type": "primary-key",
"schema-name": "app",
"table-name": "app_event"
}
}
Expected Output is below In that only DETAILS part which was xml is converted to json
{
"data":{
"ID":"1234",
"DETAILS":{
"testCasePayload":{
"testId":"1234",
"status":"COMPLETED"
"progressState":"ONGOING",
"noOfAutoSales":"1",
"noOfNewSles":"1",
"noOfSales":"0",
"DealerTypes":"WATCHLIST",
}
}
},
"metadata":{
"timestamp":"2021-04-23T11:59:43.259184Z",
"record-type":"data",
"operation":"load",
"partition-key-type":"primary-key",
"schema-name":"app",
"table-name":"app_event"
}
}