<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>看看</title>
</head><body>
<script type="text/javascript">
var json={"memo":"{\"\\u57ce\\u5e02\":\"\\u5317\\u4eac\",\"\\u8054\\u7cfb\\u7535\\u8bdd\":\"999\",\"\\u5730\\u5740\":\"\\u8bf4\\u8bf4\\u51e0\\u53f7\\u653e\\u5047\\u554a\",\"\\u90ae\\u7bb1\":\"[email protected]\",\"\\u7b80\\u4ecb\":\"\\u8bf4\\u8bf4\\u51e0\\u53f7\\u653e\\u5047\\u554a\",\"\\u7ecf\\u8425\\u8303\\u56f4\":\"\\u5a5a\\u5e86\"}","name":"\u5a5a\u793c\u7eaa","user_id":24,"logo_path":"merchant_logo/101376049270.jpg","license_path":"image_license/101376049270.jpg","city":"\u5317\u4eac","email":"[email protected]","pid":1};
json.memo=eval('('+json.memo+')');
alert(json.memo['简介']);alert(JSON.stringify(json.memo));
</script>
</body>
</html>
如何显示json全部内容,就是全部解码。再问下\"\\u57ce\\u5e02\"这几个\分别代表什么?看着很糊涂
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>看看</title>
</head><body>
<script type="text/javascript">
var json={"memo":"{\"\\u57ce\\u5e02\":\"\\u5317\\u4eac\",\"\\u8054\\u7cfb\\u7535\\u8bdd\":\"999\",\"\\u5730\\u5740\":\"\\u8bf4\\u8bf4\\u51e0\\u53f7\\u653e\\u5047\\u554a\",\"\\u90ae\\u7bb1\":\"[email protected]\",\"\\u7b80\\u4ecb\":\"\\u8bf4\\u8bf4\\u51e0\\u53f7\\u653e\\u5047\\u554a\",\"\\u7ecf\\u8425\\u8303\\u56f4\":\"\\u5a5a\\u5e86\"}","name":"\u5a5a\u793c\u7eaa","user_id":24,"logo_path":"merchant_logo/101376049270.jpg","license_path":"image_license/101376049270.jpg","city":"\u5317\u4eac","email":"[email protected]","pid":1};
json.memo=eval('('+json.memo+')');
alert(json.memo['简介']);alert(JSON.stringify(json.memo));
</script>
</body>
</html>
如何显示json全部内容,就是全部解码。再问下\"\\u57ce\\u5e02\"这几个\分别代表什么?看着很糊涂
\是转码用的
\"表示双引号 \\表示一个\ \u表示编码方式是Unicode这样的话\"\\u57ce\\u5e02\"其实就是"\u57ce\u5e02"
对照Unicode码查看下就知道了
麻烦告知下,为什么改成这样就不能用了?
alert(json.memo);
前提是你的浏览器支持window.JSON。你可以alert(window.JSON)试一下。如果不支持,需要用其他方法或者自己写个JSON系列化方法