//1.json的正常对象的格式(无序)
var obj = { "name" : "zhangsan" , "age" : 20 }
console.log(typeof obj);
console.log(obj.name);
//2.json的函数对象的格式(无序)
var obj01 = { "speak" : function(){
alert("hello")
}}
console.log(typeof obj01);
console.log(obj01.speak());
//json的数组格式
//1.存储字符串的数组
var arr = [ "zhangsan" , "Lisi" , "wangwu" ]
console.log(arr[2]);
//2.存储对象的数组
var arr01 = [obj,{ "name" : "lisi" , "age" : 22 },{ "name" : "wangwu" , "age" : 25 }]
console.log(arr01[2].name)
//将json对象转换为字符串
function jsonObj2Str(){
var obj = { "name" : "zhaoliu" , "age" : 18 }
var str = JSON.stringify(obj)
console.log(typeof str)
console.log(str)
}
//将JSON格式的字符串转换为json对象
function str2Jsonobj(){
var str = '{ "name" : "qianyi" , "age" : 20 }'
var obj = JSON.parse(str)
console.log(typeof obj)
console.log(obj)
}