**I think I am facing problem on passing GET request to youtube for JSON list
**public class GetYouTubeUserVideosTask implements Runnable {
public static final String LIBRARY = "Library";
private final Handler replyTo;
private final String username;
public HttpUriRequest request;
public GetYouTubeUserVideosTask(Handler replyTo, String username) {
this.replyTo = replyTo;
this.username = username;
}
@Override
public void run() {
try {
HttpClient client = new DefaultHttpClient();
HttpUriRequest request = new HttpGet("https://gdata.youtube.com/feeds/api/videos?author=" +username+"PL25zD6TOnoFVKHbBRCaUfkgS00d1It2h9");
HttpResponse response = null;
response = client.execute(request);
String jsonString = StreamUtils.convertToString(response.getEntity().getContent());
JSONObject json = new JSONObject(jsonString);
JSONObject response1 = json.getJSONObject("response");
JSONArray jsonArray = response1.getJSONArray("items");
List<Video> videos = new ArrayList<Video>();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String title = jsonObject.getString("title");
Log.i("...........",title);
String url;
try {
url = jsonObject.getJSONObject("player").getString("mobile");
} catch (JSONException ignore) {
url = jsonObject.getJSONObject("player").getString("default");
}
String thumbUrl = jsonObject.getJSONObject("thumbnail").getString("sqDefault");
videos.add(new Video(title, url, thumbUrl));
}
Library lib = new Library(username, videos);
Bundle data = new Bundle();
data.putSerializable(LIBRARY, lib);
Message msg = Message.obtain();
msg.setData(data);
replyTo.sendMessage(msg);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
} catch (JSONException e2) {
e2.printStackTrace();
}
I am new to android and I am trying to parse JSON but getting type mismatch error. please help me out.
I don't know where I am getting wrong. My logcat is
11-12 07:45:59.953 27498-28258/com.example.titus.abc W/System.err: org.json.JSONException: Value (JSONObject.java:159) 11-12 07:45:59.953 27498-28258/com.example.titus.abc W/System.err: at org.json.JSONObject.(JSONObject.java:172) 11-12 07:45:59.953 27498-28258/com.example.titus.abc W/System.err: at com.example.titus.abc.GetYouTubeUserVideosTask.run(GetYouTubeUserVideosTask.java:48)