object - Using lodash/underscore how can I update the value of the key -
i have convert date timestamp using date.parse().each time find key "date__c".
[ { "date__c":"07/30/2015", "end_time__c":"14:00", "start_time__c":"07:00" }, { "date__c":"07/30/2015", "end_time__c":"14:00", "start_time__c":"07:00" }, { "date__c":"07/30/2015", "end_time__c":"14:00", "start_time__c":"07:00" } ] become [ { "date__c":1438185600000, "end_time__c":"14:00", "start_time__c":"07:00" }, { "date__c":1438185600000, "end_time__c":"14:00", "start_time__c":"07:00" }, { "date__c":1438185600000, "end_time__c":"14:00", "start_time__c":"07:00" } ]
arr = [ { "date__c":"07/30/2015", "end_time__c":"14:00", "start_time__c":"07:00" }, { "date__c":"07/30/2015", "end_time__c":"14:00", "start_time__c":"07:00" }, { "date__c":"07/30/2015", "end_time__c":"14:00", "start_time__c":"07:00" } ] _.map(arr, function (a) { return _.mapvalues(a, function(v, k) { return "date__c" == k ? new date(v).valueof() : v; } ) } )
Comments
Post a Comment