parseResponse static method
Parses the raw response and determines if it's a JSON object, JSON array, or raw string.
Implementation
static dynamic parseResponse(String rawResponse) {
try {
final decoded = jsonDecode(rawResponse);
if (decoded is Map<String, dynamic> || decoded is List<dynamic>) {
return decoded; // Return as JSON object or array
}
} catch (e) {
// If JSON parsing fails, return the raw string
}
return rawResponse; // Return as raw text if not JSON
}