extJS----json字符串和json对象

<!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=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="ext-all.css" />

<script type="text/javascript" src="ext-base.js"></script>
<script type="text/javascript" src="ext-all.js"></script>
<script type="text/javascript" src="json.js"></script>
<script type="text/javascript" src="Charts.js"></script>
<script type="text/javascript">
/*注意js脚本文件的引入顺序*/

Ext.onReady(function(){

Ext.MessageBox.alert("订单","放放风");

});
var jsonstr = '{"people":[{"id":"123"},{"id":"124"}]}';//json字符串

 alert(JSON.parse(jsonstr).people[1].id);
alert(JSON.stringify(jsonstr))

//showJSON();
function showJSON() {       
    
var user =     //json对象   
    {        
        "username":"andy",       
        "age":20,       
        "info": { "tel": "123456", "cellphone": "98765"},       
        "address":       
            [       
                {"city":"beijing","postcode":"222333"},       
                {"city":"newyork","postcode":"555666"}       
            ]       
    }       
   
    alert(user.username);       
    alert(user.age);       
    alert(user.info.cellphone);       
    alert(user.address[0].city);       
    alert(user.address[0].postcode);       
}     


</script>

</head>

<body>
</body>
</html>

 

 

posted @ 2013-05-22 12:51  jshen  阅读(416)  评论(0编辑  收藏  举报