code: def serialize(self):
          
  
          def _serialize(value):
              if hasattr(value, 'serialize'):
                  return value.serialize()
              elif hasattr(value, 'to_dict'):
                  return value.to_dict()
              else:
                  return value
  
          return list(map(_serialize, self.items))
docs: Get the collection of items as a serialized object (ready to be json encoded).
  
          :rtype: dict or list