将领域结果映射到JSON标准格式

时间:2016-10-20 21:26:54

标签: ios json swift realm

如何继续将领域结果映射到JSON格式。 这是我的Realm对象类。

class OrderItemList: Object {

dynamic var dateCreated = NSDate()
let orderItems = List<OrderItem>()
}

class OrderItem: Object {

dynamic var name = " "
dynamic var amount = 0
dynamic var internalUnique = Int()
dynamic var isCompleted = false
}

我想映射保存的数据的结果并将其发送到如下的API:

let orderRequestUserValues  = [  "ClientID": "TEST",
                                     "UserName": "sysadmin",
                                     "Password": "123456",
                                     "ModuleID": "StockProcessing",
                                     "FunctionID": "SetStockOrder",
                                     "TransmissionFlags": 32,
                                     "TransmissionMethod": 5,
                                     "RequestParameters":
                                     [
                                        "OrderType": 1,
                                        "Notes": "John Is Reordering",
                                        "ListofStockItemOrderData":  //Here is where the mapped JSON will be
                                                            ]

        ]

Via Alamofire:

manager.request(.POST, url, parameters: orderRequestUserValues)

1 个答案:

答案 0 :(得分:1)

您可以将以下函数添加到document.getElementById() ,以将其OrderItemList列表转换为JSON字符串:

orderItems