fromJSONArray static method

List<Subject> fromJSONArray(
  1. dynamic json, {
  2. LinkHrefNormalizer normalizeHref = linkHrefNormalizerIdentity,
})

Creates a list of Subject from its RWPM JSON representation.

The links' href and their children's will be normalized recursively using the provided normalizeHref closure. If a subject can't be parsed, a warning will be logged with warnings.

Implementation

static List<Subject> fromJSONArray(dynamic json,
    {LinkHrefNormalizer normalizeHref = linkHrefNormalizerIdentity}) {
  if (json is String || json is Map<String, dynamic>) {
    return [json]
        .map((it) => Subject.fromJson(it, normalizeHref: normalizeHref))
        .whereNotNull()
        .toList();
  } else if (json is List) {
    return json
        .map((it) => Subject.fromJson(it, normalizeHref: normalizeHref))
        .whereNotNull()
        .toList();
  }
  return [];
}