title: <Object id> is not JSON serializable
body: <p>i'm creating an API in python + Flask + marshmallow.
  Here's the class + the first function (i don't already use the others )</p>
  
  <pre><code>import datetime
  from marshmallow import Schema, fields, ValidationError, pre_load
  from flask import Flask, jsonify
  from flask_marshmallow import Marshmallow
  from flask_sqlalchemy import SQLAlchemy
  from flask import request
  import os
  
  
  app = Flask(__name__)
  basedir = os.path.abspath(os.path.dirname(__file__))
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'User.sqlite')
  # Order matters: Initialize SQLAlchemy before Marshmallow
  db = SQLAlchemy(app)
  ma = Marshmallow(app)
  
  
  
  
  
  class User(db.Model):
      userid = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(30))
      badgenum = db.Column(db.String(30))
      mail = db.Column(db.String(30))
      status = db.Column(db.String(30))
      admin = db.Column(db.String(30))
  
      def __init__(self, userid, name, badgenum, mail, status, admin):
          self.userid = userid
          self.name = name
          self.badgenum = badgenum
          self.mail = mail
          self.status = status
          self.admin = admin
  
  
  class UserSchema(ma.Schema):
      class Meta:
          fields = ('userid', 'name', 'badgenum', 'mail', 'status', 'admin')
  
  
  user_schema = UserSchema()
  users_schema = UserSchema(many=True)
  
  
  @app.route("/User", methods=["POST"])
  def add_User():
      userid = request.json['userid']
      name = request.json['name']
      badgenum = request.json['badgenum']
      mail = request.json['mail']
      status = request.json['status']
      admin = request.json['admin']
  
  
      new_user = User(userid, name, badgenum, mail, status, admin)
  
      db.session.add(new_user)
      db.session.commit()
  
      return jsonify(new_user)
  </code></pre>
  
  <p>I tested the function add_User using Postman with this json request :</p>
  
  <pre><code>{
  
      "userid" : 1,
      "name" : "name1",
      "badgenum" : "66897",
      "mail" : "ghh@orange.fr",
      "status" : "on",
      "admin" : "f"
  
  }
  </code></pre>
  
  <p>and i got this error:</p>
  
  <pre><code>TypeError: &lt;User 145&gt; is not JSON serializable
  </code></pre>