有什么办法让NSLog打印出一个完整的JSON文件。我现在说Xcode如何NSLog一个JSON
NSString *deviceInfo = [NSString stringWithFormat:@"%@ %@",
[[UIDevice currentDevice]model], [[UIDevice currentDevice]systemVersion]];
NSDictionary *json = [deviceInfo JSONValue];
NSLog(@"json file = %@", json);
而且它打印出“JSON文件=(空)”
感谢 克林顿
非常感谢你的工作。它目前正在打印出这个'{“deviceModel”:“iPod touch”,“deviceSystemVersion”:“4.3.5”},如果我想在每个硬件外部有多个块和某些东西, :{“deviceModel”:“iPod touch”}“os”:{“deviceSystemVersion”:“4.3.5”}'我该怎么做。 –
只要嵌套字典。 '[NSDictionary dictionaryWithObjectsAndKeys:someDictionary,@“someKey”,someOtherDictionary,@“someOtherKey”,零]' –
是的工作。还有一件事是。我似乎无法改变NSDictionary中的顺序。我有'NSDictionary * fullJSON = [NSDictionary dictionaryWithObjectsAndKeys:hardware,@“hw”,os,@“os”,nil];'但是它打印出了{{{“os”:{“ver”:“4.3.5” },“hw”:{“model”:“iPod touch”}}'我不认为它是必要的,但如果我能够使硬件成为第一,那将会很好。 –