2014-01-25 40 views

回答

1

雖然我沒有一個偉大的建議,作爲替代方案,爲了完整性這裏是你如何能輕鬆序列化與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); 
    } 
} 
0

這樣做的一種方法是將它作爲純文本發送,然後在接收端解析並將其再次轉換爲數組。 但是,然後任何開發人員會討厭使用它,作爲發佈者,你會討厭維護它(有一段時間)。

相關問題