javascript - javascipt json 轉(zhuǎn)數(shù)組 大神來
問題描述
[{'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怎么轉(zhuǎn)化為 [’http://vrjx.zhed.com/Public/mht.jpg’, ’http://vrjx.zhed.com/Public/mht.jpg’, ’http://vrjx.zhed.com/Public/mht.jpg’]用JavaScript 怎么轉(zhuǎn)
問題解答
回答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);
將字符串轉(zhuǎn)成對(duì)象再操作
相關(guān)文章:
1. JavaScript將.apply()與'new'運(yùn)算符配合使用這可能嗎?2. angular.js - webpack build后的angularjs路由跳轉(zhuǎn)問題3. java - Activity中的成員變量被賦值之后,Activity被回收的時(shí)候內(nèi)存才會(huì)被釋放嗎4. java - web項(xiàng)目中,用戶登陸信息存儲(chǔ)在session中好 還是cookie中好,取決于什么?5. 為什么 必須在<ul> 下建立 <li> 在建<a>?6. 請(qǐng)求一個(gè)數(shù)據(jù)返回內(nèi)容為空或者錯(cuò)誤如何再次請(qǐng)求幾次7. 老師,flex-shrink: 1; 按視頻操作,不會(huì)自動(dòng)縮放8. 為什么bindClass訪問不了的?9. Discuz! Q 有人用過嗎?10. 我寫的哪里有錯(cuò)?請(qǐng)大神幫忙查看一下。
