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. docker-compose中volumes的問題2. boot2docker無法啟動3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. 關于docker下的nginx壓力測試5. docker容器呢SSH為什么連不通呢?6. nignx - docker內nginx 80端口被占用7. docker安裝后出現Cannot connect to the Docker daemon.8. java - SSH框架中寫分頁時service層中不能注入分頁類9. node.js - antdesign怎么集合react-redux對input控件進行初始化賦值10. dockerfile - 為什么docker容器啟動不了?

網公網安備