refactor(angular.toJson): use charAt instead of regexp