PostfixTemplateDescriptor.fromJson constructor

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

Implementation

factory PostfixTemplateDescriptor.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    String name;
    if (json.containsKey('name')) {
      name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'name');
    }
    String key;
    if (json.containsKey('key')) {
      key = jsonDecoder.decodeString('$jsonPath.key', json['key']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'key');
    }
    String example;
    if (json.containsKey('example')) {
      example =
          jsonDecoder.decodeString('$jsonPath.example', json['example']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'example');
    }
    return PostfixTemplateDescriptor(name, key, example);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'PostfixTemplateDescriptor', json);
  }
}