0
我一直在試圖使用jsonkit的對象來進行字符串轉換。我的SerializedClasses幫助器將NSMutableArray CellList轉換爲JSONString(ssd日誌)。這完美。然後我把結果字符串放到字典中,然後嘗試獲取jsonstring字典(ssd2 log)。代碼和輸出如下。JSString條出現對象
-(NSDictionary*)toDictionary{
NSString *myCellListString = [SerializedClassesHelper cellListToString:cellList];
NSLog(@"ssd:%@",myCellListString);
NSDictionary *myDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
[[NSString alloc] initWithFormat:@"%@",myCellListString],@"cellList",
[[NSString alloc] initWithFormat:@"%d",weaponType],@"weaponType",
nil];
for (NSString *eachString in myDictionary) {
[eachString release];
}
NSLog(@"ssd2:%@",[myDictionary JSONString]);
return myDictionary;
}
輸出:
ssd:[{"col":"4","row":"2"},{"col":"4","row":"2"}]
ssd2:{"weaponType":"0","cellList":"[{\"col\":\"4\",\"row\":\"2\"},{\"col\":\"4\",\"row\":\"2\"}]"}
爲什麼所有的側隙出現在cellList字符串的中間?