String cleanJson(String maybeInvalidJson) {
if (maybeInvalidJson.contains('```')) {
final withoutLeading = maybeInvalidJson.split('```json').last;
final withoutTrailing = withoutLeading.split('```').first;
return withoutTrailing;
}
return maybeInvalidJson;