Currently I am working on a request that takes a database with the following class.
class Player(db.Model):
id = db.Column(db.Integer, primary_key=True)
# ... etc
... and then I am trying to return all players in JSON format with the following function
class Players(Resource):
def get(self):
result = Player.query.all()
return result
However so far I have not been able to get my result in JSON format. With the above code I get an error reading
Object of type Player is not JSON serializable
I have tried things like...
final_result = result.json()
return final_result
or ...
final_result = json.dump(result)
return final_result
neither of these solutions have worked for me. My end goals is to return all players in JSON format to first postman, and then my front end client when I am done with this project.