I have a JSON Array of objects like:
$scope.people = [
{id: 1, forename: 'Bob', surname: 'Bobbington', DOB: '01/01/1990', address: '123 Fake St'},
{id: 2, forename: 'Bill', surname: 'Billster', DOB: '01/12/1999', address: '56 Road'},
{id: 3, forename: 'Sally', surname: 'Bobbington', DOB: '15/04/1987', address: '123 Fake St'},
{id: 4, forename: 'Flerp', surname: 'Derp', DOB: '01/09/1991', address: '34 Derpington'}
];
but I need to extract a single record (and specific fields) to its own list based on a value, in this case the id.
I've used .map before, but that will make a new array of all records but lets me specify field, I'm not aware of a way I can filter at this point
specificFields = RawData.map(function (el) {
return ({
surname: el['surname'].replace(/ /g, ''),
DOB: el['DOB'].replace(/ /g, '')
})
})
I'm not sure how to extract one record based on a single value, as in my case the id will always be unique, but if its not how would a process expecting 1 record handle it when I need it as a single list not an array.