Javascript中的json操作

<!doctype html>
<html>
    <head>
        <title>extjs-json</title>
        <script type="text/javascript">
    window.onload = function loadPage(){
            var obj={
                1:"first",
                "2":"second"
            };
            console.log(obj[1]);//打印

            obj.sex ="man";//添加
            delete obj.sex;//删除
            for(var c in obj){//遍历
                console.log(c+":",obj[c]);
            }
            
        } 
        </script>
    </head>
    <body>
    </body>
</html>

 

posted @ 2016-08-26 16:26  公众号java-codestack  阅读(162)  评论(0编辑  收藏  举报