【发布时间】:2018-12-19 07:19:11
【问题描述】:
当前示例代码:
child: Padding(
padding: const EdgeInsets.all(14.0),
child: Table(
border: TableBorder.all(width: 1.0, color: Colors.black),
children: [
TableRow(children: [
TableCell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Text('Company Symbol'),
new Text(data['symbol'].toString()),
],
),
)
]),
TableRow(children: [
TableCell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Text('Name of Company'),
new Text(data['companyName'].toString()),
],
),
)
]),
TableRow(children: [
TableCell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Text('Exchnage'),
new Text(data['exchange'].toString()),
],
),
)
]),
TableRow(children: [
TableCell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Text('Industry'),
new Text(data['industry'].toString()),
],
),
)
])
],
),
),
),
],
),
);
}
}'
Future<Map> loadData() async {
http.Response response = await http.get(
Uri.encodeFull("https://api.iextrading.com/1.0/stock/aapl/company"),
headers: {"Accept": "application/json"});
Map data = jsonDecode(response.body);
return data;
}
我的问题是我无法检索/获取嵌套在 json/raw 视图中的 json 值。
如果我使用:https://api.iextrading.com/1.0/stock/market/batch?symbols=aapl,fb&types=quote,news,chart&range=1m&last=5
作为网址,我无法获得相同的值。
我需要什么价值观?
例子:
new Text(data['symbol'].toString()),
获取符号值:
{"quote":{"symbol":"AAPL","companyName":"Apple Inc.","primaryExchange":"Nasdaq Global Select","sector":"技术","calculationPrice":"close","open":165.42,"openTime":1545057000854,"close":163.94,"closeTime":1545080400475,"high":168.35,"low":162.73,"latestPrice": 163.94,"latestSource":"关闭","latestTime":"2018 年 12 月 17 日","latestUpdate":1545080400475,"latestVolume":42949358,"iexRealtimePrice":null,"iexRealtimeSize":null,"iexLastUpdated":null ,"delayedPrice":164.015,"delayedPriceTime":1545080393722,"extendedPrice":164.09,"extendedChange":0.15,"extendedChangePercent":0.00091,"extendedPriceTime":1545083995658,"previousClose":165.48,"change":-1.54, “更改百分比”:-
【问题讨论】:
-
如果您只想获取符号,您可以将 JSON 对象存储在变量中,然后这会给您返回符号的值:myObj.AAPL.quote.symbol(myObj 是变量您存储对象的位置)
标签: javascript dart flutter