2012-01-11 69 views
0

我試圖解析字符串「引號」:「」生活d直到我呼吸我的最後一次「」, 使用json解析器,但它不解析。我來了解這個問題,它由於這些雙引號「報價」:「」生活在......字符串中。JSon解析雙引號錯誤

我嘗試了這些東西:

str_response = [str_response stringByReplacingOccurrencesOfString:@ 「\'」 withString:@ 「」]; str_response = [str_response stringByReplacingOccurrencesOfString:@「」「」withString:@「」「]; str_response = [str_response stringByReplacingOccurrencesOfString:@」\「」withString:@「」];

但沒有成功,沒有什麼ALB來替換單引號 雙引號我想要的結果:「直到我呼吸我上次生活d生活」

感謝您的幫助

+0

你確定android標籤是一個好標籤嗎?你的代碼看起來像客觀的C而不是Java ... – Selvin 2012-01-11 10:14:56

回答

1
: 「引號」

是的,你的代碼是在目標C中,但是,JSON的JSON對象具有以下格式:

{「key1」:「value1」,「key2」:「value2」};

如果是字符串值。

請編輯您的代碼如下得到這樣的字符串值:

str_response = [str_response stringByReplacingOccurrencesOfString:@"\'\'" withString:@""]; str_response = [str_response stringByReplacingOccurrencesOfString:@"\"\"" withString:@""]; 

,因爲它只有這樣,才能使用JSON庫解析,但是你可以定義自己的解析器,對json的特定問題。