1. 程式人生 > >第二次理解json

第二次理解json

fin name str2 tom 數組 ole ddr 格式 cnblogs

// js對象和json 的區別

    var friend ={
        firstname:‘zhang‘,
        lastname:‘cl‘,
        address:null,
        // address:‘‘,
        // address:undefined,
    };
    // 
    var str = ‘{"name":"alan"}‘;

    // json 格式對象
    var json ={
        "name":"alan",
        "age":"23",
        "gender":"female",

    };
    
// json 格式數組 var arr =[ { "name":"alan", "age":"23", "gender":"female", }, { "name":"kitty", "age":"23", "gender":"female", }, { "name":"tom", "age":"23", "gender":"male", } ] var json2 = JSON.parse(str);
// json 格式的對象 // var str = JSON.stringify(friend); var str2 = ‘{"firstname":"zhang","lastname":"cl","address":null}‘; var json3 = {"firstname":"zhang","lastname":"cl","address":null} // console.log(str); console.log(typeof(json3));

第二次理解json