I have a number of different xml formats I have to convert to a standard format. I could manually map but if I could get a programmatic solution working from a basic GUI that would save me loads of time! I'm using JS so having converted the xml to js I now have 2 js object structures. A standard target structure I want to transform data to and the provided data. I want to pick which source values get mapped to target values. What's the best way to store the object structure for the mapping. the '.' notation doesn't convert back to an object easily. is their an easier solution?
eg source
{
"Resort": {
"ResortCode": "ADH",
"ResortName": "ABU DHABI",
"CountryCode": "AE",
"ArrPoints": [
{
"ArrPoint": "AUH"
},
{
"ArrPoint": "AXH"
}
]
}
}
mappings
{ _key: 'Resort.ResortCode',
name: 'Resort.ResortName',
location: 'Resort.CountryCode'
route: 'Resort.ArrPoints.ArrPoint' }
end result
target structure and data result
{ _key: "ADH",
name: "ABU DHABI",
location: "AE",
route: ["AUH","AXH"]
}