javascript - javascipt json 轉數組 大神來
問題描述
[{'xc_images':'http://vrjx.zhed.com/Public/mht.jpg'},{'xc_images':'http://vrjx.zhed.com/Public/mht.jpg'},{'xc_images':'http://vrjx.zhed.com/Public/lz.jpg'}]這樣的json怎么轉化為 [’http://vrjx.zhed.com/Public/mht.jpg’, ’http://vrjx.zhed.com/Public/mht.jpg’, ’http://vrjx.zhed.com/Public/mht.jpg’]用JavaScript 怎么轉
問題解答
回答1:var arr =[{'xc_images':'http://vrjx.zhed.com/Public/mht.jpg'},{'xc_images':'http://vrjx.zhed.com/Public/mht.jpg'},{'xc_images':'http://vrjx.zhed.com/Public/lz.jpg'}];res = arr.map(function(i){return i.xc_images;})['http://vrjx.zhed.com/Public/mht.jpg', 'http://vrjx.zhed.com/Public/mht.jpg', 'http://vrjx.zhed.com/Public/lz.jpg']回答2:
jsonData.map(function (item) { return item.xc_images })回答3:
var a = [{'xc_images':'http://vrjx.zhed.com/Public/mht.jpg'},{'xc_images':'http://vrjx.zhed.com/Public/mht.jpg'},{'xc_images':'http://vrjx.zhed.com/Public/lz.jpg'}];var res = a.map(e => e.xc_images); console.log(res);
將字符串轉成對象再操作
相關文章:
1. 查詢mysql數據庫中指定表指定日期的數據?有詳細2. mysql - 怎么生成這個sql表?3. mysql儲存json錯誤4. php - 公眾號文章底部的小程序二維碼如何統計?5. mysql - 表名稱前綴到底有啥用?6. mysql - 數據庫表中,兩個表互為外鍵參考如何解決7. Navicat for mysql 中以json格式儲存的數據存在大量反斜杠,如何去除?8. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現存在即更新應該使用哪個標簽?9. mysql - 數據庫建字段,默認值空和empty string有什么區別 11010. sql語句 - 如何在mysql中批量添加用戶?
