Skip to content

Instantly share code, notes, and snippets.

@ekopradesga
Last active January 19, 2022 10:11
Show Gist options
  • Save ekopradesga/2b71eb828a548541d854ca7d069798ec to your computer and use it in GitHub Desktop.
Save ekopradesga/2b71eb828a548541d854ca7d069798ec to your computer and use it in GitHub Desktop.
Search JSON
import 'dart:convert';
void main() {
String jsonStr = '[{"asset":"BTC","free":0,"locked":0},{"asset":"LTC","free":0,"locked":0},{"asset":"ETH","free":0,"locked":0},{"asset":"NEO","free":0,"locked":0},{"asset":"BNB","free":0.75884444,"locked":0},{"asset":"QTUM","free":0,"locked":0},{"asset":"EOS","free":0,"locked":0},{"asset":"SNT","free":0,"locked":0},{"asset":"BNT","free":0,"locked":0},{"asset":"GAS","free":0,"locked":0},{"asset":"BCC","free":0,"locked":0},{"asset":"USDT","free":1633.6586226,"locked":0},{"asset":"HSR","free":0,"locked":0},{"asset":"OAX","free":0,"locked":0},{"asset":"DNT","free":0,"locked":0},{"asset":"MCO","free":0,"locked":0},{"asset":"ICN","free":0,"locked":0},{"asset":"ZRX","free":0,"locked":0},{"asset":"OMG","free":0,"locked":0}]';
List<Map<String, dynamic>> data = jsonDecode(jsonStr);
Map<String, dynamic> dt = data.firstWhere((dat) => dat['asset'] == 'USDT');
print(dt['free']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment