我有一個從領域結果創建的[NSDictionary]()
。 我的主要目標是將此[NSDictionary]()
解析爲JSON,然後通過Alamofire將其發送到API,但通過這些數據我必須發送用戶密碼和詳細信息。作爲JSON發送[NSDictionary]()到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": //<--[NSDictionary]() data has to come here
]
]
有了這個orderRequestUserValues
我送[NSDictionary]()
爲「ListofStockItemOrderData」這可以從評論中可以看出。
我很新,所以請不要嘲笑我。 我想知道如何將此orderRequestUserValues
和[NSDictionary]()
轉換爲我可以通過Alamofire發送的JSON。 的JSON接收必須是這樣的終端產品:
EXTRA信息 這是我如何轉換我的境界存儲的數據的NSDictionary
extension Object {
func toDictionary() -> NSDictionary {
let properties = self.objectSchema.properties.map { $0.name }
let dictionary = self.dictionaryWithValuesForKeys(properties)
let mutabledic = NSMutableDictionary()
mutabledic.setValuesForKeysWithDictionary(dictionary)
for prop in self.objectSchema.properties as [Property]! {
// find lists
if let nestedObject = self[prop.name] as? Object {
mutabledic.setValue(nestedObject.toDictionary(), forKey: prop.name)
} else if let nestedListObject = self[prop.name] as? ListBase {
var objects = [AnyObject]()
for index in 0..<nestedListObject._rlmArray.count {
let object = nestedListObject._rlmArray[index] as AnyObject
objects.append(object.toDictionary())
}
mutabledic.setObject(objects, forKey: prop.name)
}}
return mutabledic }}
請幫助。 預先感謝您。
我已經有一個[NSDictionary]()爲「ListofStockI temOrderData「這是我的領域數據。我將如何加入這3本字典? –
這是Objective c? –
是的不幸。我沒有很快的經驗。 –