json static method

void json(
  1. dynamic jsonObject, [
  2. String? tag
])

JSON pretty print with enhanced styling

Implementation

static void json(dynamic jsonObject, [String? tag]) {
  if (!kDebugMode) return;
  try {
    String jsonString;
    if (jsonObject is Map || jsonObject is List) {
      jsonString = _prettyPrintJson(jsonObject);
    } else {
      jsonString = jsonObject.toString();
    }
    _logWithStyle(jsonString, 'JSON', tag ?? 'JSON');
  } catch (e) {
    _logWithStyle('Failed to format JSON: $e', 'ERROR', tag);
  }
}