我需要使用Underscore.js
过滤上面的JSON如何仅返回“余额”与0
不同的项目
{
Currency: 'BCC',
Balance: 0,
Available: 0,
Pending: 0,
CryptoAddress: null
}, {
Currency: 'BLOCK',
Balance: 0,
Available: 0,
Pending: 0,
CryptoAddress: 'Bd24akqYDG97k6xmUqsnxAtrBRoXeffQhx'
}, {
Currency: 'BTC',
Balance: 0.00153928,
Available: 0.00153928,
Pending: 0,
CryptoAddress: '1BgWkjF1mwe1MZoCvxMmfSJ6fppNMD5GSx'
}, {
Currency: 'BTG',
Balance: 2e-8,
Available: 2e-8,
Pending: 0,
CryptoAddress: null
}
答案 0 :(得分:1)
试试这个:
_.filter(yourList, function(obj){
return obj.Balance !== 0
})
答案 1 :(得分:1)
这是一个codepen示例:
https://codepen.io/anon/pen/EbMRKY?editors=1111
let filtered = _.filter(transactions, (transaction) => {
return transaction.Balance !== 0;
})