下記2つのJSON(object)について、"key"をもとに結合し、新しいJSON(object)を作成したいです。
具体的なJavaScriptコードを教えてほしいです。
JSON
1[ 2 { 3 "id": "1", 4 "title": "Lorem", 5 "comment": "Lorem Ipsum is simply dummy text of the....", 6 "key": "thumbnail_1" 7 8 }, 9 { 10 "id": "2", 11 "title": "Ipsum", 12 "comment": "It is a long established fact that ....", 13 "key": "thumbnail_2" 14 15 } 16 17]
JSON
1[ 2 { 3 "id": "1", 4 "key": "thumbnail_1", 5 "thumbnailname": "Lorem_1", 6 "thumb_src": "Lorem_1.jpg" 7 8 }, 9 { 10 "id": "2", 11 "key": "thumbnail_1", 12 "thumbnailname": "Lorem_2", 13 "thumb_src": "Lorem_2.jpg" 14 15 }, 16 { 17 "id": "3", 18 "key": "thumbnail_2", 19 "thumb_src": "Ipsum_1.jpg" 20 21 }, 22 { 23 "id": "4", 24 "key": "thumbnail_2", 25 "thumb_src": "Ipsum_2.jpg" 26 27 } 28 29]
新しいJSON(object)の完成形は、こちらになります。
JSON
1[ 2 { 3 "id": "1", 4 "title": "Lorem", 5 "comment": "Lorem Ipsum is simply dummy text of the....", 6 "key": "thumbnail_1" 7 "thumb_src": 8 { 9 "Lorem_1.jpg", 10 "Lorem_2.jpg" 11 } 12 13 }, 14 { 15 "id": "2", 16 "title": "Ipsum", 17 "comment": "It is a long established fact that ....", 18 "key": "thumbnail" 19 "thumb_src": 20 { 21 "Ipsum_1.jpg", 22 "Ipsum_2.jpg" 23 } 24 25 26 } 27 28]
回答1件
あなたの回答
tips
プレビュー