我得到以下錯誤,當我使用的詞典與對象的數組: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