如何转换json对象?
我也试过以下。你如何让JS认为一个字符串是JSON?
$scope.getEval = function (str) {
return eval(str);
};
try {
s = $scope.getEval("\nexports = { emptyFunction: function() { \n exit(); }, getUserName: function() { if (!variable.global_name) { exit(changeFlowAndStep('get_user_name', 0, {global_first_time_done: false}, true)); } else { exit({variable:{global_first_time_done: true}}); } }}")
for (var i in s) {
s[i] = s[i].toString();
}
$scope.s = s;
console.log($scope.s)
} catch (e) {
console.log(e);
}
是'出口= {emptyFunction:函数()...'你想从json转换为对象的字符串? – Adder