- Регистрация
- 16.10.2016
- Сообщения
- 90
- Благодарностей
- 7
- Баллы
- 8
Добрый день.
Подскажите пожалуйста как найти walletId по ключу walletName в JSON
walletName = Reserve
На PHP это было вот так
Подскажите пожалуйста как найти walletId по ключу walletName в JSON
walletName = Reserve
JavaScript:
{"walletList":[{"order":2,"walletId":1357397,"accountNo":23286001357397,"walletName":"Main","balance":0.00,"balanceConverted":0,"balanceNet":0.00,"balanceAvailable":0.00,"balanceAvailableCashable":0.00,"firstFinancialTransactionDate":"2023-10-13","lastFinancialTransactionDate":"2023-10-30","balanceInLocalCurrency":null,"isDefaultWallet":true,"isAssignedToCard":true,"walletExtPreciousMetalList":null},{"order":8,"walletId":1361243,"accountNo":23301001361243,"walletName":"Reserve","balance":5759.07,"balanceConverted":0,"balanceNet":5759.07,"balanceAvailable":5759.07,"balanceAvailableCashable":5759.07,"firstFinancialTransactionDate":"2023-10-28","lastFinancialTransactionDate":"2023-10-30","balanceInLocalCurrency":null,"isDefaultWallet":false,"isAssignedToCard":false,"walletExtPreciousMetalList":null},{"order":9,"walletId":1361855,"accountNo":23303001361855,"walletName":"WalletIGti6","balance":100.00,"balanceConverted":0,"balanceNet":100.00,"balanceAvailable":100.00,"balanceAvailableCashable":100.00,"firstFinancialTransactionDate":"2023-10-30","lastFinancialTransactionDate":"2023-10-30","balanceInLocalCurrency":null,"isDefaultWallet":false,"isAssignedToCard":true,"walletExtPreciousMetalList":null}]}
PHP:
foreach ($json['walletList'] as $item) {
if ($item['walletName'] == $d['accname']) {
$walletId = $item['walletId'];
}
}