code: def as_array(obj):
      
      if hasattr(obj, "to_array"):
          return obj.to_array()
      elif isinstance(obj, (list, tuple)):
          return [as_array(x) for x in obj]
      elif isinstance(obj, dict):
          return {key:as_array(obj[key]) for key in obj.keys()}
      else:
          _json_dumps(obj)  # raises error if is wrong json
          return obj
docs: Creates an json-like representation of a variable, supporting types with a `.to_array()` function.
  
      :rtype: dict|list|str|int|float|bool|None