Parser function to convert a Dart object to a JSON map.
typedef ToJson<T> = Map<String, Object?> Function(T);