code: def config_to_json(cls, config_obj):
      json_result = {}
      if not hasattr(cls, "_fields"):
          raise Exception(f"{cls} is not a valid config class")
      for field, f_cls in cls.__annotations__.items():
          value = getattr(config_obj, field)
          json_result[field] = _value_to_json(f_cls, value)
      return json_result
  
imports: from enum import Enum
  from typing import Dict, List, Tuple, Union
label_desc: Use image node_id 5 for calling a global function with example usage: config_to_json(cls, config_obj) and returns: json_result