我得到以下错误,当我使用的词典与对象的数组:JSON序列化不支持目标C
NSMutableDictionary *jsonDict=[[NSMutableDictionary alloc] init];
[jsonDict setObject:checkMarkPresetRecipientsArray forKey:@"Names"];
[jsonDict setObject:checkMarkDocumentGroupNameArray forKey:@"Address"];
json = [jsonDict JSONFragment];
错误:JSONFragment失败。错误跟踪是:( “错误域= org.brautaset.JSON.ErrorDomain代码= 1”JSON序列化不支持DocumentType \“UserInfo = 0xb5cc270 {NSLocalizedDescription = JSON序列化不支持DocumentType}”, “错误域= org.brautaset.JSON.ErrorDomain Code = 1 \“对象中关键DocumentType的不支持值\”UserInfo = 0xb580e60 {NSUnderlyingError = 0xb585320 \“DocumentType \不支持JSON序列化”,NSLocalizedDescription =对象中关键DocumentType的不支持值}“ )
,但没有得到同样的错误有:
NSMutableDictionary *jsonDict=[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Nitesh",@"Name", @"Balaghat",@"Address",nil];
NSString *json=[jsonDict JSONRepresentation];
NSLog(@"%@",json);
上述
给了我正确的Ĵ SON表示。
我做错了什么?任何人可以帮助我上面......
其实我的数组包含核心数据类对象,它不支持JSON表示,所以我改变了实现现在它工作正常。如果有什么方法可以在JSON中更改coredata类对象表示,请更新我。谢谢。
'不支持DocumentType的JSON序列化' – graver 2013-02-12 08:33:12
使用JSONRepresentation的JSONValue实例 – iPatel 2013-02-12 08:37:04
@graver - DocumentType是我的类对象,我在Dictionary中用键添加了它。是不是可以使用我们的类对象? – 2013-02-12 09:37:48