How I need to post the request:
How it looks in the database:
Hello, I am working on a food app, I need to send the order details to the database. To do that, I have created a data type like
class orderModel : NSObject {
var menu_name : String = ""
var quantity : Int = 0
var price : Double = 0.0
var menu_id : String = ""
init?(menu_name : String,menu_id : String, price : Double, quantity : Int) {
guard !menu_id.isEmpty else{
return nil
}
self.menu_name = menu_name
self.menu_id = menu_id
self.price = price
self.quantity = quantity
}
}
this. I'm then placing the order with,
let parameters : Parameters = [
"custid" : defaults.object(forKey: "userid")!,
"carttotal" : Int(totalPrice),
"cartitems" : ordersArray,
"deliverytime" : timeSlot,
"custaddress" : custAdd!,
"areacode" : defaults.object(forKey: "areaCode")!
]
Alamofire.request(orderPlaceURL, method: .post, parameters: parameters).responseJSON { response in
print((response.result.value)!)
}
totalPrice = 0.0
ordersArray.removeAll()
The posted data should look like the first image, but when it's entered into the database, it shows like the second image. Instead of the array elements, just the word "Array". Can anyone please suggest me what to do?