我有以下字符串如何從以下JSON字符串獲取字符串[]?
["[email protected]","[email protected]"]
我使用String.split(",")
得到的String []。但數組內容包括「[」和「「」的。
我需要出去引號,以獲得實際的字符串。是否有一個圖書館或方法與我能做到嗎?
目前我做的這樣的。
recipients = recipients.replace("\"", "");
recipients = recipients.replace("[", "");
recipients = recipients.replace("]", "");
String[] totalRecipients = recipients.split(",");
爲什麼不嘗試解析JSON字符串而不是試圖對其進行字符串操作?你會得到一個'List'來解析那個可以很容易地轉換爲一個字符串數組的JSON字符串。 –
SudoRahul
2014-09-03 08:59:40