我得到了结果json和解析在android中。异常情况下出现一条消息:org.json.JSONException:价格没有价值org.json.JSONException:没有价值的价值
W/System.err: org.json.JSONException: No value for price
W/System.err: at org.json.JSONObject.get(JSONObject.java:389)
W/System.err: at org.json.JSONObject.getString(JSONObject.java:550)
我的Java类
JSONParser jsonParser = new JSONParser();
// tracks JSONArray
JSONArray albums = null;
// Album id
String album_id = null;
String song_id = null;
String album_name, song_name, price;
// single song JSON url
// GET parameters album, song
private static final String URL_SONG = "my url";
// ALL JSON node names
private static final String TAG_NAME = "name";
private static final String TAG_PRICE = "price";
private static final String TAG_ALBUM = "name"; // album
...
try {
JSONObject jObj = new JSONObject(json);
if(jObj != null){
song_name = jObj.getString(TAG_NAME);
album_name = jObj.getString(TAG_ALBUM);
price = jObj.getString(TAG_PRICE);
}
}
catch (JSONException e) {
e.printStackTrace();
}
我的JSON网址:
{
"id": "551"
"name": "Rent Disk"
"price": "3233333"
"album_id": "3"
"album": "Michael"
}
如何解决这个异常?非常感谢 !!
您的JSON无效 –
检查您在本网站JSON尝试: - HTTP://www.jsoneditoronline .org/ – musica