Pubspec.fromJson constructor

Pubspec.fromJson(
  1. Map json, {
  2. bool lenient = false,
})

Implementation

factory Pubspec.fromJson(Map json, {bool lenient = false}) {
  if (lenient) {
    while (json.isNotEmpty) {
      // Attempting to remove top-level properties that cause parsing errors.
      try {
        return _$PubspecFromJson(json);
      } on CheckedFromJsonException catch (e) {
        if (e.map == json && json.containsKey(e.key)) {
          json = Map.from(json)..remove(e.key);
          continue;
        }
        rethrow;
      }
    }
  }

  return _$PubspecFromJson(json);
}