code: def default(self, obj):
          
          if hasattr(obj, 'to_python'):
              return obj.to_python()
          return super(CLIJSONEncoder, self).default(obj)
docs: Encode object if it implements to_python().