1.2.3.4.JSON 與物件實體
JSON: JavaScript Object Notation
object literal的子集合, 屬性一定要包在雙引號中
網路傳輸資料時的格式
var objectLiteral = {
firstname : 'Mary',
isAProgramer: true
}
//物件轉為JSON字串
console.log(JSON.stringify(objectLiteral))
//JSON
var JsonValue = JSON.parse('{
"firstname" : 'Mary',
"isAProgramer": true
}');
//JSON字串轉為物件
console.log(JsonValue)
Last updated
Was this helpful?