这是我的代码
我在JSON
中收到b.start_time
无序列化错误。
def rooms():
rooms = Room.query.all()
formatted_rooms = []
for r in rooms:
book = Booking.query.filter_by(room_id=r.id).all()
formatted_rooms.append( {
'name' : r.name,
'floor': r.floor, 'location': r.location,
'city' : r.city, 'capacity' : r.capacity,
'credits' : r.credits, 'amenities' : r.amenities ,
'room_id' : r.id,
'booking_details': { (b.start_time)
for b in book }
} )
return json.dumps(formatted_rooms) , 200, {'Content-Type':'application/json'}
答案 0 :(得分:0)
set
不是JSON数据类型
更改此
'booking_details': { (b.start_time) for b in book }
到列表
'booking_details': [ (b.start_time) for b in book ]