How to convert string to object in Angularjs [duplicate]
问题 This question already has answers here : Parse JSON in JavaScript? [duplicate] (16 answers) Closed 3 years ago . I have a string like : $scope.text = '"{\"firstName\":\"John\",\"age\":454 }"'; and I want to convert to js object: $scope.tmp = {"firstName":"John","age":454 }; Note: JSON.parse() doesn't work!! It's my sample in codepen 回答1: You can do it with angular.fromJson() in your sample, it would have been $scope.tmp = angular.fromJson($scope.text); The difference between JSON.Parse() and