namespace TrueCV.Infrastructure.Helpers;
///
/// Helper methods for processing AI/LLM JSON responses.
///
public static class JsonResponseHelper
{
///
/// Cleans a JSON response by removing markdown code block formatting.
///
public static string CleanJsonResponse(string response)
{
var trimmed = response.Trim();
// Remove markdown code blocks
if (trimmed.StartsWith("```json", StringComparison.OrdinalIgnoreCase))
{
trimmed = trimmed[7..];
}
else if (trimmed.StartsWith("```"))
{
trimmed = trimmed[3..];
}
if (trimmed.EndsWith("```"))
{
trimmed = trimmed[..^3];
}
return trimmed.Trim();
}
}