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. python - 獲取到的數據生成新的mysql表2. javascript - js 對中文進行MD5加密和python結果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現 4046. python - (初學者)代碼運行不起來,求指導,謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無法觸發9. python的文件讀寫問題?10. 為什么python中實例檢查推薦使用isinstance而不是type?
