title: How do I return single object with JSON in Python with Flask
body: <p>I have the below code which is trying to return an object back to JSON. I'm trying to return back the MenuItem object to the caller</p>
  
  <pre><code>#Make JSON API
  @app.route('/restaurant/&lt;int:restaurant_id&gt;/menu/&lt;int:menu_id&gt;/JSON')
  def restaurantMenuJSONONE(restaurant_id,menu_id):
      item = session.query(MenuItem).filter_by(id = menu_id).one()
      return jsonify(MenuItems=item)
  </code></pre>
  
  <p>Error I'm getting:</p>
  
  <pre><code>TypeError: &lt;database_setup.MenuItem object at 0xb6071d8c&gt; is not JSON serializable
  </code></pre>
  
  <p>database_setup.py snips</p>
  
  <pre><code>class MenuItem(Base):
      __tablename__ = 'menu_item'
  
      name = Column(String(80), nullable=False)
      id = Column(Integer, primary_key=True)
      description = Column(String(250))
      price = Column(String(8))
      course = Column(String(250))
      restaurant_id = Column(Integer, ForeignKey('restaurant.id'))
      restaurant = relationship(Restaurant)
  
  #JSON
      @property
      def serialize(self):
          #return object
          return {
              'name' : self.name,
              'description' : self.description,
              'id' : self.id,
              'price' : self.price,
              'course' : self.course,
          }
  </code></pre>