I'm using .map() to copy object fields from one JSON List to another, my issue is that the starting list I need to move the values from has spaces in the field names.
For fields with no spaces the following is working:
$scope.dataList = results.data.map(el => ({
IdApplication: el.ApplicationReference,
AccNo: el.AccountNumber
}))
The starting JSON however is taken directly from a CSV the user selects, and sadly the client won't change how they name their columns. So I need to map a JSON field called 'Application Reference'.
I've tried enclosing the field name in '' but this gives an identifier expected error on the first opening ' .
Bracket notation also doesn't work:
$scope.dataList = results.data.map(el => ({
IdApplication: el.['Application Reference'],
AccNo: el.AccountNumber
}))
This also gives an error of identifier expected on the opening [.