第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 key:value 從 json 對象中獲取項目

使用 key:value 從 json 對象中獲取項目

慕運維8079593 2021-06-15 17:32:52
我想知道我們是否可以通過提供鍵值對從 json 中獲取一個項目。例如。我有一個像下面這樣的 json 對象[{id: "864", text: "[145-028] ", name: "145028", type: null, description: ""},{id: "593", text: "[111-111] ", name: "111111", type: null, description: ""},{id: "616", text: "[330-00D] ", name: "33000D", type: null, description: ""},{id: "595", text: "[124-964] ", name: "124964", type: null, description: ""},{id: "597", text: "[476-978] ", name: "476978", type: null, description: ""},{id: "131", text: "[142-222] ", name: "142222", type: null, description: ""},{id: "132", text: "[149-603] ", name: "149603", type: null, description: ""},{id: "603", text: "[778-498] ", name: "778498", type: null, description: ""}]如何通過 id 獲取單個項目864,以便獲取特定項目的名稱、類型和描述。任何幫助將不勝感激
查看完整描述

2 回答

?
呼如林

TA貢獻1798條經(jīng)驗 獲得超3個贊

我提議:


const MyData = [{ 0: {id: "864", text: "[145-028] ", name: "145028", type: null, description: ""}

                , 1: {id: "593", text: "[111-111] ", name: "111111", type: null, description: ""} 

                , 2: {id: "616", text: "[330-00D] ", name: "33000D", type: null, description: ""} 

                , 3: {id: "595", text: "[124-964] ", name: "124964", type: null, description: ""} 

                , 4: {id: "597", text: "[476-978] ", name: "476978", type: null, description: ""} 

                , 5: {id: "131", text: "[142-222] ", name: "142222", type: null, description: ""} 

                , 6: {id: "132", text: "[149-603] ", name: "149603", type: null, description: ""} 

                , 7: {id: "603", text: "[778-498] ", name: "778498", type: null, description: ""} 

                }];


function MyDataGetVal(x_ID) {

  return Object.values(MyData[0]).find(E=>E.id===x_ID )|| null;

}



let E_864 = MyDataGetVal('864')

  , E_132 = MyDataGetVal('132')

  , E_XXX = MyDataGetVal('XXX')

;


console.log ('E_864 = ',  JSON.stringify(E_864))


console.log ('E_132 = ',  JSON.stringify(E_132))


console.log ('E_XXX = ',  JSON.stringify(E_XXX))


查看完整回答
反對 回復 2021-06-24
  • 2 回答
  • 0 關注
  • 147 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號