We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
对于规范JSON字符串,通常采用 JSON.parse 解析即可 但对于不规范的,则可采用 eval(str) eval,jslint检测会告警 解析字符串的前提,字符串必须符合基本的对象格式要求
var str = "{"a":1,"b":2}"; // 规范JSON字符串 var str1 = "{a: 1, b: 2}"; // 不规范JSON字符串
// eval console.log(eval('(' + str+ ')')); console.log(eval('(' + str1+ ')'));
// 替代eval console.log(new Function('return ' + str)); console.log(new Function('return' + str1));
The text was updated successfully, but these errors were encountered:
No branches or pull requests
对于规范JSON字符串,通常采用 JSON.parse 解析即可
但对于不规范的,则可采用 eval(str)
eval,jslint检测会告警
解析字符串的前提,字符串必须符合基本的对象格式要求
var str = "{"a":1,"b":2}"; // 规范JSON字符串
var str1 = "{a: 1, b: 2}"; // 不规范JSON字符串
// eval
console.log(eval('(' + str+ ')'));
console.log(eval('(' + str1+ ')'));
// 替代eval
console.log(new Function('return ' + str));
console.log(new Function('return' + str1));
The text was updated successfully, but these errors were encountered: