Annotation.fromJson constructor

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

Implementation

factory Annotation.fromJson(Map<String, dynamic> json) {
  switch (json['type']) {
    case 'file_citation':
      return FileCitation(
        fileId: json['file_id'] as String,
        index: json['index'] as int,
      );
    case 'url_citation':
      return UrlCitation(
        startIndex: json['start_index'] as int,
        endIndex: json['end_index'] as int,
        title: json['title'] as String,
        url: json['url'] as String,
      );
    case 'container_file_citation':
      return ContainerFileCitation(
        containerId: json['container_id'] as String,
        fileId: json['file_id'] as String,
        startIndex: json['start_index'] as int,
        endIndex: json['end_index'] as int,
      );
    case 'file_path':
      return FilePath(
        fileId: json['file_id'] as String,
        index: json['index'] as int,
      );
    default:
      return OtherAnnotation(json);
  }
}