https://developer.mozilla.org/en US/docs/Web/JavaScript/Reference/Global_Objects/JSON js數據類型: js Object JSON.stringify(); JSON.parse(); ...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
js數據類型:
字元串、數字、布爾、數組、對象、Null、Undefined
js Object
var data = {
"name":"yfs",
"age":28,
"boy":true,
"language":["chinese", "english"],
"address":{
"provice":"shanxi",
"city":"xian"
}
};
JSON.stringify();
var jsonString = JSON.stringify(data);
console.log(jsonString);
console.log(typeof(jsonString));
//結果:
{"name":"yfs","age":28,"boy":true,"language":["chinese","english"],"address":{"p
rovice":"shanxi","city":"xian"}}
//類型:string
var a = '{"name":"yfs","age":28,"boy":true,"language":["chinese","english"],"address":{"p
rovice":"shanxi","city":"xian"}}';
JSON.parse();
var jsObject = JSON.parse(jsonString);
console.log(jsObject);
console.log(typeof(jsObject));
//結果:
{ name: 'yfs',
age: 28,
boy: true,
language: [ 'chinese', 'english' ],
address: { provice: 'shanxi', city: 'xian' } }
//類型:object