JSON Keys to be converted to lowercase programmatically.
In the following angularjs code, $scope.productsNew contains json array whose keys are not in lowercase, they are like Id, Sku, Description I need them to be like id, sku,description
I need to change them to lowercase in angularjs, could you help me in this.
function storeController($scope,$http) { function onUserComplete(response) { $scope.productsNew = [{ Id: 3, Sku: 'APL', Name: 'Apple', Description: 'Eat one every day to keep the doctor away!', Price: 20 }, { Id: 4, Sku: 'BAN', Name: 'Banana', Description: 'These are rich in Potassium and easy to peel.', Price: 40 }]; }; function onError(reason) { $scope.error = "Could not fetch the Products"; }; $http.get("http://localhost:60128/Products-Service/Products") .then(onUserComplete, onError);}
I would guess, they are that way for a good reason. Using your own modified keys may later collide when your objects may contain both keys in different cases.
Otherwise, I'm using _.map() in such cases.
Dinesh Kumar
ASKER
If you can provide _.map() example that fits good in my scenario
Otherwise, I'm using _.map() in such cases.