loadRawJson static method
Raw .zfa.json map, or null when the file is absent. Throws
FeatureConfigException on malformed JSON.
Implementation
static Map<String, dynamic>? loadRawJson({String? projectRoot}) {
final file = configFileSync(projectRoot: projectRoot);
if (file == null || !file.existsSync()) return null;
try {
final decoded = const JsonDecoder().convert(file.readAsStringSync());
if (decoded is Map<String, dynamic>) return decoded;
if (decoded is Map) {
return decoded.map((k, v) => MapEntry(k.toString(), v));
}
throw FeatureConfigException(
'${file.path} must contain a JSON object at the root',
);
} on FormatException catch (e) {
throw FeatureConfigException(
'${file.path} is not valid JSON: ${e.message}',
);
}
}