<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script>
var json = {
"name":"张三",
"age":33,
"birth":"2000-05-05"
};
</script>
</head>
<body>
<p>
姓名:<input type="text" id="uname"/>
</p>
<p>
年龄:<input type="text" id="uage"/>
</p>
<p>
生日:<input type="text" id="ubirth"/>
</p>
<p>
<input type="button" value="显示数据" onclick="showinfo()"/>
</p>
<p>
<input type="button" value="获取并显示数据" onclick="readandshowinfo()"/>
</p>
<div>
{"name":"李四","age":25,"birth":"1998-06-06"}
</div>
<input type="text" size="100" id="jsonvalue"/>
</body>
<script>
function readandshowinfo() {
var info = document.getElementById('jsonvalue').value;
json = eval('('+info+')');
showinfo();
}
function showinfo(){
document.getElementById('uname').value = json.name;
document.getElementById('uage').value = json.age;
document.getElementById('ubirth').value = json.birth;
}
</script>
</html>