compactJson function

Map<String, Object?> compactJson(
  1. Map<String, Object?> map
)

Drops null values and empty lists or maps from map, so files only carry what is set.

Implementation

Map<String, Object?> compactJson(Map<String, Object?> map) => {
  for (final e in map.entries)
    if (e.value != null &&
        !(e.value is List && (e.value as List).isEmpty) &&
        !(e.value is Map && (e.value as Map).isEmpty))
      e.key: e.value,
};