Flutter JSON Not Reading Correctly
this might take a while... I've been trying to get my Dart/Flutter code to return data from BlockChainTicker (Specifically I would like to see everything from the AUD line) and lea
Solution 1:
The top level of your json is a map (not a list - in json, lists are enclosed in brackets)
{
"USD" : {"15m" : 7492.85, "last" : 7492.85, "buy" : 7492.85, "sell" : 7492.85, "symbol" : "$"},
"AUD" : {"15m" : 9899.28, "last" : 9899.28, "buy" : 9899.28, "sell" : 9899.28, "symbol" : "$"},
"BRL" : {"15m" : 28214.31, "last" : 28214.31, "buy" : 28214.31, "sell" : 28214.31, "symbol" : "R$"},
So change:
print(data[1]["AUD"]);
to
print(data["AUD"]); // prints the whole AUD map
print(data['AUD']['last']); // prints the AUD 'last' double
String isoCode = 'AUD';
print('$isoCode -> ${data[isoCode]}');
Post a Comment for "Flutter JSON Not Reading Correctly"