I have a class and array in a loop. I'm filling the object and appending it to the array. How do I pass array data to web side through JSON? I have an error that says JSON is not serializable. How can I serialize to a JSON?
class myclass(object):
def __init__(self,vehicle,mng01):
self.vehicle = vehicle
self.vehicle = vehicle
#--Main function--
@subApp.route('/jsontry', method=['POST'])
def data():
for x in list:
vehicle_sum.append(myclass( x,str(mng01))
return json.dumps({'success':'1','vehicle':vehicle_sum})
{'success':'1','vehicle':vehicle_sum}withvehicle_sumbeing a standard python array, it works. Please provide more details regarding the error and the objects you use :)myclass. This will not work out of the box. See my answer below :)self.vehicle = vehiclestatements inmyclass.__init__()?