【发布时间】:2021-04-15 07:52:45
【问题描述】:
我得到一个 JSON 文件,其中包含一长串这样的数据。
[
[
[6.25575, 51.83439],
[6.26408, 51.83342]
],
[
[6.25575, 51.83439],
[6.26408, 51.83342]
]
]
当我写作时:
final List<List<List<double>>> data = await getJson('assets/data.json') as List<List<List<double>>>;
它给出了错误:_CastError (type 'List<dynamic>' is not a subtype of type 'List<List<List<double>>>' in type cast)。
getJson 函数:
Future<dynamic> getJson(String file) async {
final String jsonData = await rootBundle.loadString(file);
final dynamic data = await jsonDecode(jsonData);
return data;
}
如何将此列表转换为List<List<List<double>>>?
【问题讨论】: