ImplementedClass.fromJson constructor

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

Implementation

factory ImplementedClass.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    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');
    }
    return ImplementedClass(offset, length);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'ImplementedClass', json);
  }
}