我有一個JSON模型/ 4個對象的細節。我想要基於關鍵字的對象:月。如何獲取數組中的單個對象到JSON模型
Object
oData
details:
Array[4]
0:Object
1:Object
2:Object
3:Object
editable:false
key:"date"
removeable:false
value:"Day: TRUE, Night:False"
4:Object
editable:false
key:"month"
removeable:false
value:"August"
以下是代碼
/視圖
var viewModel = that.getView().getModel();
var viewModelData = viewModel.getData();
遍歷數組中的對象查找關鍵月份 –
使用對象很容易。檢查這個鏈接:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects –
看看這個jQuery的grep方法:http://stackoverflow.com/questions/21172289/filtering- ajson-array-using-jquery-grep –