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. java固定鍵值轉換,使用枚舉實現字典?2. php自學從哪里開始?3. java - 我設置了cookie的max age,但是cookie依然在關閉游覽器后消失了4. MySQL客戶端吃掉了SQL注解?5. python小白的基礎問題 關于while循環的嵌套6. css3 - [CSS] 動畫效果 3D翻轉bug7. javascript - JS設置Video視頻對象的currentTime時出現了問題,IE,Edge,火狐,都可以設置,反而chrom卻...8. 求大神幫我看看是哪里寫錯了 感謝細心解答9. phpstady在win10上運行10. javascript - 百度echarts series數據更新問題
