1
比方說,我從服務器獲取對象的有沒有什麼辦法在JavaScript中將大對象轉換爲小對象?
`A = {
"kind": "books#volume",
"id": "8Q1wW6Us-O0C",
"etag": "k2MS/7WPcsY",
"selfLink": "https://www.googleapis.com/books/v1/volumes/8Q1wW6Us-O0C",
"volumeInfo": {
"title": "Years with Frank Lloyd Wright",
"subtitle": "Apprentice to Genius",
"authors": [
"Edgar Tafel"
],
"publisher": "Courier Corporation",
"publishedDate": "1979",
"description": "This insightful memoir by a former apprentice presents a revealing portrait of the great American architect, providing illuminating anecdotes about Wright's Prairie home and Oak Park periods, and much more.",
"industryIdentifiers": [
{
"type": "ISBN_10",
"identifier": "0486248011"
},
{
"type": "ISBN_13",
"identifier": "9780486248011"
}
],
"readingModes": {
"text": false,
"image": true
},
"pageCount": 228,
"printType": "BOOK",
"categories": [
"Architecture"
],
"averageRating": 3.5,
"ratingsCount": 2,
"maturityRating": "NOT_MATURE",
"allowAnonLogging": false,
"contentVersion": "1.1.1.0.preview.1",
"imageLinks": {
"smallThumbnail": "http://books.google.ru/books/content?id=8Q1wW6Us-O0C&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api",
"thumbnail": "http://books.google.ru/books/content?id=8Q1wW6Us-O0C&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api"
},
"previewLink": "http://books.google.ru/books?id=8Q1wW6Us-O0C&printsec=frontcover&hl=&source=gbs_api",
"infoLink": "http://books.google.ru/books?id=8Q1wW6Us-O0C&hl=&source=gbs_api",
"canonicalVolumeLink": "http://books.google.ru/books/about/Years_with_Frank_Lloyd_Wright.html?hl=&id=8Q1wW6Us-O0C"
},
}
是否有任何的JavaScript快速的方法來創建這個基礎上選擇的特性另一個對象?
B = {"id": "8Q1wW6Us-O0C",
"title": "Years with Frank Lloyd Wright",
"publishedDate": "1979",
"pageCount": 228,
and some other properties}
不讀這個:我被要求添加一些細節,但我想這已經足夠了。
謝謝,我加上一個從@NinaScholz你的答案! – boooni