Outline.fromJson constructor

Outline.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory Outline.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    Element element;
    if (json.containsKey('element')) {
      element =
          Element.fromJson(jsonDecoder, '$jsonPath.element', json['element']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'element');
    }
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    int length;
    if (json.containsKey('length')) {
      length = jsonDecoder.decodeInt('$jsonPath.length', json['length']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'length');
    }
    int codeOffset;
    if (json.containsKey('codeOffset')) {
      codeOffset =
          jsonDecoder.decodeInt('$jsonPath.codeOffset', json['codeOffset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'codeOffset');
    }
    int codeLength;
    if (json.containsKey('codeLength')) {
      codeLength =
          jsonDecoder.decodeInt('$jsonPath.codeLength', json['codeLength']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'codeLength');
    }
    List<Outline>? children;
    if (json.containsKey('children')) {
      children = jsonDecoder.decodeList(
          '$jsonPath.children',
          json['children'],
          (String jsonPath, Object? json) =>
              Outline.fromJson(jsonDecoder, jsonPath, json));
    }
    return Outline(element, offset, length, codeOffset, codeLength,
        children: children);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'Outline', json);
  }
}