我從web服務的Android,org.json.JSONException:對於
"alert": {
"long_msg": "Thank you for downloading PHARMAPLUS APP, if you found our APP helpful please rate us five star on play store",
"short_msg": "Welcome to PHARMAPLUS",
"title": "Thank you"
}
得到以下JSON和我的代碼沒有價值
if (json.has("alert")) {
String alert = json.getString("alert");
String _title = json.getString(Constansts.PARSE.NOTIFICATION.TITLE);
String _shortMsg = json.getString(Constansts.PARSE.NOTIFICATION.SHORT_MSG);
String _longMsg = json.getString(Constansts.PARSE.NOTIFICATION.LONG_MSG);
常量等被定義如下
public static final String TITLE = "title";
public static final String SHORT_MSG = "short_msg";
public static final String LONG_MSG = "long_msg";
得到如下錯誤
org.json.JSONException: No value for title
爲什麼'字符串alert = json.getString(「alert」);'? –
那麼,JSON沒有「標題」的值。 「alert」鍵的對象會這樣做。 –