📅  最后修改于: 2022-03-11 15:02:13.387000             🧑  作者: Mango
factory YoutubeResponse.fromJSON(Map YoutubeResponseJson)
{
// Below 2 line code is parsing JSON Array of items in our JSON Object (YouttubeResponse)
var list = YoutubeResponseJson['items'] as List;
List- itemsList = list.map((i) => Item.fromJSON(i)).toList();
return new YoutubeResponse(
kind: YoutubeResponseJson['kind'],
etag: YoutubeResponseJson['etag'],
nextPageToken: YoutubeResponseJson['nextPageToken'],
regionCode: YoutubeResponseJson['regionCode'],
mPageInfo: pageInfo.fromJSON(YoutubeResponseJson['pageInfo']),
// Here we are returning parsed JSON Array.
items: itemsList);
}