<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test json</title>
</head>
<body>
<script type="text/javascript">
function strToJson (str)
{
return (new Function("return " + str))();
}
var str = "{'hello':'world'}";
var json = strToJson(str);
console.log(json);
console.log(typeof json);
</script>
</body>
</html>
javascript 一个简便的方法将字符串转化成json对象