I'm new with Flask, and I'm having some problem trying to return an object which contains another object instance as field, like the follows:
class Park(object):
park_id = 0
address = ""
services = []
position = None
def __init__(self, park_id, address, services, latitude, longitude):
self.park_id = park_id
self.address = address
self.services = services
self.position = Point(latitude, longitude)
where the Point class is simply the follow:
class Point(object):
latitude = None
longitude = None
def __init__(self, latitude, longitude):
self.latitude = latitude
self.longitude = longitude
when I try to return a Park instance
@app.route('/')
def test():
park = Park(....)
return jsonify(park])
I obtain this error: TypeError: Object of type 'Park' is not JSON serializable
.