내가 안드로이드에서 발리슛 URL로 연결 오전 :org.json.JSONException : 값 ... - 발리?
private void connectToUrl(String url) {
JsonArrayRequest req = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
JSONObject jsonObj = null;
try {
jsonObj = new JSONObject(response.toString());
JSONArray contacts = jsonObj.getJSONArray("d");
for (int i = 0; i < contacts.length(); i++) {
try {
JSONObject object = response.getJSONObject(i);
Log.i("VALUEDSSDDD", object.getString("urlpic"));
} catch (JSONException e) {
e.printStackTrace();
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Custom Log Error", "Error: " + error.getMessage());
Log.i("ERRRROOORR",error.getMessage()+"");
}
});
// Adding request to request queue
AppController.getInstance().addToRequestQueue(req, tag_json_arry);
req.setRetryPolicy(new DefaultRetryPolicy(
30000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
}
을하지만 url
에 연결할 때 나에게 오류 얻을 :
{
"d": [{
"apiCurrentUserID": 0,
"apiCurrentUserName": null,
"urlpic": "http://Image.jpg",
"Title": "Jim",
"FileMusicUrl": "http://video.mp4",
"StringDuration": "05':07''",
"ViewCount": 57,
"DownloadCount": 56,
"uploadDate": "/Date(1473550560)/",
"MusicID": 192727,
"UserID": 0,
"Summary": "Some text",
"OrderView": null,
"ShowDate": "/Date(1473550500)/",
"FileSize": "19.15 MB",
"RatePlus": null,
"RateDash": null,
"ChannelID": 0,
"ChannelName": null,
"CurrentChannelID": 0,
"CurrentChannelName": null,
"isFollowed": false,
"profileImgUserSend": null,
"isDisliked": false,
"isLiked": false,
"isLatered": false,
"isFavorited": false,
"apiCategories": null,
"apiTags": [{
"tageID": "438232",
"titleTag": "book"
}, {
"tageID": "411557",
"titleTag": "sounds"
}, {
"tageID": "365984",
"titleTag": "map"
}]
}],
"RowwCount": 0
}
I : 여기
org.json.JSONException: Value .....
내 json
입니다 json
에서 url
까지 올라갑니다.
는 편집 :
나는 내 코드를 편집 :
private void connectToUrl(String url) {
requestQueue = Volley.newRequestQueue(this);
JsonObjectRequest obreq = new JsonObjectRequest(Request.Method.DEPRECATED_GET_OR_POST, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
JSONObject jsonObj = null;
try {
jsonObj = new JSONObject(response.toString());
JSONObject contacts = jsonObj.getJSONObject("d");
try {
Log.i("VALUEDSSDDD", contacts.getString("urlpic"));
} catch (JSONException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Volley", "Error " + error.getMessage());
}
}
);
requestQueue.add(obreq);
}
그러나 나에게 오류 얻을 : 마지막 코드에서
null
을 나에게 돈을 초래하지만,이 코드에 표시 어떤 결과도 없습니다.
포스트의 완전한 오류 로그 –