json_model icon indicating copy to clipboard operation
json_model copied to clipboard

type 'String' is not a subtype of type 'Map<String, dynamic>' in type cast问题处理

Open duoduoxi opened this issue 4 years ago • 0 comments

希望作者有时间能处理下

"relist":"$[]Zdata",

上面的代码生成下面的代码

..relist = (json['relist'] as List) ?.map((e) => e == null ? null : Zdata.fromJson(e as Map<String, dynamic>)) ?.toList()

报错: type 'String' is not a subtype of type 'Map<String, dynamic>' in type cast

把生成的代码改成:

..relist = (json['relist'] as List) ?.map((e) => e == null ? null : Zdata.fromJson(jsonDecode(e) as Map<String, dynamic>)) ?.toList()

问题解决。

感谢提供好工具

duoduoxi avatar Oct 20 '20 11:10 duoduoxi