In my angularjs apps, I usually parse a JSON string by using angular.fromJson
, like so:
var myObject=angular.fromJSON(jsonString);
However, it seems that I would obtain the same result by using $scope.$eval
:
var myObject=$scope.$eval(jsonString);
Or by using vanilla javaScript, like so:
var myObject=JSON.parse(jsonString);
Is there any particular reason to use
angular.fromJSON
rather thanJSON.parse
?Is there any possible issue when using
$scope.$eval
to parse a JSON string?