IatResult.fromJson constructor

IatResult.fromJson(
  1. Map json
)

Implementation

factory IatResult.fromJson(Map json) {
  List<Words> words;
  if (json['ws'] == null || json['ws'] is! List) {
    words = [];
  } else {
    words = (json['ws'] as List).cast<Map>().map(Words.fromJson).toList();
  }

  List<int>? rg;
  Pgs? pgs;
  if (json['pgs'] != null) {
    pgs = Pgs.tryParse(json['pgs']);
    if (json['rg'] is List) {
      rg = (json['rg'] as List).cast<int>();
    }
  }

  return IatResult(
    sentence: json['sn'] ?? 0,
    lastSentence: json['ls'] ?? false,
    begin: json['bg'] ?? 0,
    end: json['ed'] ?? 0,
    words: words,
    pgs: pgs,
    rg: rg,
  );
}