【发布时间】:2018-07-24 05:43:35
【问题描述】:
我有一个作为列表返回的 json。我正在尝试解析它,但我收到一个名为
的错误_InternalLinkedHashMap' 不是“List”类型的子类型 这是我的代码 -
List data = json.decode(response.body) as List;
var newsPageViewResult = data.map((i) => new NewsList.fromJson(i)).toList();
和我的 json 模型类
class NewsList {
final List<News> news;
NewsList({
this.news,
});
factory NewsList.fromJson(List<dynamic> parsedJson) {
List<News> news = new List<News>();
news = parsedJson.map((i)=>News.fromJson(i)).toList();
return new NewsList(
news: news
);
}
}
class News{
final String status;
final String type;
News({
this.status,
this.type
}) ;
factory News.fromJson(Map<String, dynamic> json){
return new News(
status: json['status'],
type: json['type'],
);
}}
also this is how json is returning
[ { “身份证”:10159, “日期”:“2018-07-23T11:34:22”, "date_gmt": "2018-07-23T11:34:22", “指导”:{ “渲染”:“http://the2is.com/?p=10159” }, “修改”:“2018-07-23T11:35:13”, “modified_gmt”:“2018-07-23T11:35:13”, “蛞蝓”:“只有 25 卢比将在儿童缺血时被移除”, “状态”:“发布”, “类型”:“发布”,....]
我已经根据 Dart 2.0 文档明确声明了传递什么类型的数据,但仍然存在错误。
【问题讨论】: