processJson method

Map<String, dynamic> processJson(
  1. Map<String, dynamic> jsonObject
)

Implementation

Map<String, dynamic> processJson(Map<String, dynamic> jsonObject) {
  jsonObject.forEach((key, value) {
    if (value is String) {
      // Apply regex transformation only to date-time strings
      jsonObject[key] = formatDateString(value);
    } else if (value is Map<String, dynamic>) {
      // Recursively process nested objects
      jsonObject[key] = processJson(value);
    } else if (value is List) {
      // Process lists of objects
      jsonObject[key] = value.map((item) {
        if (item is Map<String, dynamic>) {
          return processJson(item);
        } else if (item is String) {
          return formatDateString(item);
        }
        return item;
      }).toList();
    }
  });
  return jsonObject;
}