0
我想通過POST將數組發送到來自我的iOS應用程序的Django Web服務,並且想知道是否有可能沒有序列化爲JSON。在不使用JSON的情況下將數組發送到Web服務
我想通過POST將數組發送到來自我的iOS應用程序的Django Web服務,並且想知道是否有可能沒有序列化爲JSON。在不使用JSON的情況下將數組發送到Web服務
雖然我沒有一個偉大的建議,作爲替代方案,爲了完整性這裏是你如何能輕鬆序列化與iOS的集成庫詞典(不需要外部的lib /工具)很短的例子:
// Dictionary convertable to JSON ?
if ([NSJSONSerialization isValidJSONObject:dict])
{
// Serialize the dictionary
json = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
// If no errors, let's view the JSON
if (json != nil && error == nil)
{
NSString *jsonString = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
NSLog(@"JSON: %@", jsonString);
}
}
這樣做的一種方法是將它作爲純文本發送,然後在接收端解析並將其再次轉換爲數組。 但是,然後任何開發人員會討厭使用它,作爲發佈者,你會討厭維護它(有一段時間)。
你必須將它序列化爲某些東西。 JSON有什麼問題? – 2014-01-25 20:42:03