decode static method
Decodes a profile from the JSON text of a declaration.
Throws ProjectOperationProfileFormatException when the declaration is refused. Nothing is repaired and nothing is defaulted beyond the fields the evidence shape itself may omit.
Implementation
static ProjectOperationProfile decode(String text) {
final Object? decoded;
try {
decoded = jsonDecode(text);
} on FormatException catch (error) {
throw ProjectOperationProfileFormatException(
'project_operation_profile_not_json',
'the declaration is not JSON: ${error.message}',
);
}
if (decoded is! Map<String, dynamic>) {
throw const ProjectOperationProfileFormatException(
'project_operation_profile_not_object',
'the declaration must be a JSON object',
);
}
return _profile(decoded);
}