js jsonオブジェクトへの属性の追加、削除、変更

1544 ワード

<script type="text/javascript">
        //json  
        var json={ "firstName":"Bill" , "lastName":"Gates"};
        // json           
        json.sex="man";
        //              
        json["sex"]="man";


        //  json   firstName  
        delete json.firstName;
        //       firstName    
        delete json["firstName"];


        //  json   firstName    
        json.firstName="Thomas";
        //       firstName    
        json["firstName"]="Thomas";
    script>