【发布时间】:2019-09-02 05:45:32
【问题描述】:
我在颤振中遇到了一个奇怪的错误。我正在使用可序列化的 json。
这是我的代码
class DivMatches{
final List<Match> matches;
DivMatches(this.matches);
factory DivMatches.fromJson(Map<String, dynamic> json) =>
_$DivMatchesFromJson(json);
Map<String, dynamic> toJson() => _$DivMatchesToJson(this);
}
我的 web api 发送这样的数据
[
[
{..},
{..},
{..},
{..}
],
[...],
[...],
[...],
[...],
[...],
[...]
]
它是数组的数组。
产生错误的代码是
data = body.map((el) => DivMatches.fromJson(el)).toList();
它给出的错误
Exception has occurred.
_TypeError (type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>')
JSON 数据 这是json数据格式的截图
【问题讨论】: