tryJsonDecode static method

Map<String, dynamic>? tryJsonDecode(
  1. String? value, {
  2. bool cleanInput = false,
})

Attempts to decode a JSON string to a Map.

Implementation

static Map<String, dynamic>? tryJsonDecode(String? value, {bool cleanInput = false}) {
  if (value == null || value.isEmpty) return null;
  if (cleanInput) {
    final String? cleaned = cleanJsonResponse(value);
    if (cleaned == null || cleaned.isEmpty) return null;
    return jsonDecodeToMap(cleaned);
  }
  return jsonDecodeToMap(value);
}