mapFromJson static method

Map<String, Element> mapFromJson(
  1. dynamic json
)

Implementation

static Map<String, Element> mapFromJson(dynamic json) {
  final map = <String, Element>{};
  if (json is Map && json.isNotEmpty) {
    json.cast<String, dynamic>().forEach((key, dynamic value) {
      var ctype = value['type'];
      switch (ctype) {
        case 'document':
          map[key] = Document.fromJson(value);
          break;
        case 'component':
          map[key] = Component.fromJson(value);
          break;
        case 'container':
          map[key] = Container.fromJson(value);
          break;
        case 'container-item':
          map[key] = ContainerItem.fromJson(value);
          break;
        case 'componentcontent':
          map[key] = ComponentContent.fromJson(value);
          break;
        case 'imageset':
          map[key] = Imageset.fromJson(value);
          break;
        case 'menu':
          map[key] = Menu.fromJson(value);
          break;
        case 'pagination':
          map[key] = Pagination.fromJson(value);
          break;
        default:
          map[key] = Element.fromJson(value);
      }
    });
  }
  return map;
}