Closed MrZeeee closed 6 years ago
If x is the array of EVObjects, then you can just use:
request.httpBody = x.toJsonData()
but available suggestions of xcode is toJsonString() or toDictionaryArray()
and xcode says value of type [EVObject] has no member 'toJsonData'
if i want to explain more :
class MobileProduct :EVObject { public var ProductId : Int = 0 public var ServiceId : Int = 0 public var Name : String = "" public var Ownerid : Int = 0 public var CreationDate : String = "" public var PersianCreationDate : String = "" public var IsTemplate : Bool = false public var abrType : String = "" public var TagName : String = "" public var ThumbnailUrl : String = "" public var MinPage : Int = 0 public var MaxPage : Int = 0 public var MobileProductPages:[MobileProductsPage_New] = [] }
and my x variable is [MobileProduct]
Ah, you are right... I was sure it was there... I now added a helper function for this. That will be in the next version. For now you could just use:
request.httpBody = x.toJsonString().data(using: .utf8)
thank you
i have array of EVObjects:
request.httpBody = try JSONSerialization.data(withJSONObject: x, options: [])
but this line crash with treminating with uncaught exception how can i post body of type [EVOBject]?