code: def to_json_encodable(task: BaseOperator) -> dict[str, object]:
      def _task_encoder(obj):
          from airflow.models import DAG
  
          if isinstance(obj, datetime.datetime):
              return obj.isoformat()
          elif isinstance(obj, DAG):
              return {
                  "dag_id": obj.dag_id,
                  "tags": obj.tags,
                  "schedule_interval": obj.schedule_interval,
                  "timetable": obj.timetable.serialize(),
              }
          else:
              return str(obj)
  
      return json.loads(
          json.dumps(task.__dict__, default=_task_encoder)
      )
  
imports: from __future__ import annotations
  import datetime
  import json
  import logging
  import os
  from contextlib import suppress
  from functools import wraps
  from typing import TYPE_CHECKING, Any, Iterable
  from urllib.parse import parse_qsl, urlencode, urlparse, urlunparse
  import attrs
  from attrs import asdict
  from openlineage.client.utils import RedactMixin
  from airflow.compat.functools import cache
  from airflow.configuration import conf
  from airflow.providers.openlineage.plugins.facets import AirflowMappedTaskRunFacet, AirflowRunFacet
  from airflow.utils.context import AirflowContextDeprecationWarning
  from airflow.utils.log.secrets_masker import Redactable, Redacted, SecretsMasker, should_hide_value_for_key
label_desc: Use image node_id 3 for calling a global function with example usage: to_json_encodable(task) and returns: json, obj, dict, str