我一直在尝试使用 jsonkit 进行对象到字符串的转换。我的 SerializedClasses 助手将 NSMutableArray CellList 转换为 JSONString(ssd 日志)。这很完美。然后我将生成的字符串放入字典中,然后尝试获取 jsonstring 字典(ssd2 日志)。代码和输出如下。
-(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 字符串的中间?