SimpleArticle.fromJson constructor

SimpleArticle.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory SimpleArticle.fromJson(Map<String, dynamic> json) {
  if (json == null) return new SimpleArticle();

  List<String> authors = [];
  try {
    authors = json["authors"].map((a) => a).toList().cast<String>();
  } catch (exception) {/* ignore */}

  FeatureImage featureImage = FeatureImage();
  try {
    featureImage = FeatureImage.fromJson(json["featureImage"]);
  } catch (exception) {/* ignore */}

  return SimpleArticle(
    id: json["id"],
    title: json["title"],
    link: json["link"],
    publishedDate: json["publishedDate"],
    publishedSince: json["publishedSince"],
    teaserText: json["teaserText"],
    featureImage: featureImage,
    parentCategoryId: json["parentCategoryId"],
    parentCategory: json["parentCategory"],
    categoryId: json["categoryId"],
    category: json["category"],
    issueTitle: json["issueTitle"],
    issueTeaserText: json["issueTeaserText"],
    issueNumber: json["issueNumber"],
    volumeNumber: json["volumeNumber"],
    paragraphRawContent: json["paragraphRawContent"],
    issuePublishedDate: json["issuePublishedDate"],
    isPDFArticle: json["isPDFArticle"],
    pdfURL: json["pdfURL"],
    authors: authors,
  );
}