我使用JSON.h
將我的字符串解析爲對象。總是工作正常,但今天,發生此錯誤,同時嘗試解析功能[strJSON JSONValue]
:-JSONValue失敗。錯誤跟蹤:SBJsonParser中的BUG
「錯誤域= org.brautaset.JSON.ErrorDomain碼= 10 \」 垃圾後JSON \ 「的UserInfo = {0xd3076b0 = NSLocalizedDescription JSON後垃圾}」
所以當我調試知道發生什麼事,我把一個斷點功能- (id)fragmentWithString:(id)repr
和我的代碼,在此行中輸入:
// We found some valid JSON. But did it also contain something else?
if (![self scanIsAtEnd]) {
[self addErrorWithCode:ETRAILGARBAGE description:@"Garbage after JSON"];
return nil;
}
,並返回我的錯誤,我想。這是什麼意思?爲什麼當我評論這行代碼時:
if (![self scanIsAtEnd]) {
[self addErrorWithCode:ETRAILGARBAGE description:@"Garbage after JSON"];
return nil;
}
爲什麼我的代碼在註釋行時工作正常?
抱歉格式=/ – 2013-03-01 20:58:30
該錯誤是因爲@「JSON後的垃圾」。你應該檢查你傳遞給它的json。 – iDev 2013-03-01 21:04:22
@ACB謝謝你... json錯了;在末尾 – 2013-03-04 13:50:17