Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.89 KB | None | 0 0
  1. [ { "url": "https://api.github.com/gists/10232136", "forks_url": "https://api.github.com/gists/10232136/forks", "commits_url": "https://api.github.com/gists/10232136/commits", "id": "10232136", "git_pull_url": "https://gist.github.com/10232136.git", "git_push_url": "https://gist.github.com/10232136.git", "html_url": "https://gist.github.com/10232136", "files": { "gulpfile-viget-pattern.js": { "filename": "gulpfile-viget-pattern.js", "type": "application/javascript", "language": "JavaScript", "raw_url": "https://gist.githubusercontent.com/andrewmartin/10232136/raw/72c67881fe717ecf35dd2a0f4524fca989b9b643/gulpfile-viget-pattern.js", "size": 426 } }, "public": true, "created_at": "2014-04-09T06:34:16Z", "updated_at": "2014-04-09T06:34:16Z", "description": "gulpfile-viget-pattern-test.js", "comments": 0, "user": { "login": "andrewmartin", "id": 273842, "avatar_url": "https://avatars.githubusercontent.com/u/273842?", "gravatar_id": "3377b3e694bdacac127ca9ee6c871c52", "url": "https://api.github.com/users/andrewmartin", "html_url": "https://github.com/andrewmartin", "followers_url": "https://api.github.com/users/andrewmartin/followers", "following_url": "https://api.github.com/users/andrewmartin/following{/other_user}", "gists_url": "https://api.github.com/users/andrewmartin/gists{/gist_id}", "starred_url": "https://api.github.com/users/andrewmartin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/andrewmartin/subscriptions", "organizations_url": "https://api.github.com/users/andrewmartin/orgs", "repos_url": "https://api.github.com/users/andrewmartin/repos", "events_url": "https://api.github.com/users/andrewmartin/events{/privacy}", "received_events_url": "https://api.github.com/users/andrewmartin/received_events", "type": "User", "site_admin": false }, "comments_url": "https://api.github.com/gists/10232136/comments" }, { "url": "https://api.github.com/gists/10232076", "forks_url": "https://api.github.com/gists/10232076/forks", "commits_url": "https://api.github.com/gists/10232076/commits", "id": "10232076", "git_pull_url": "https://gist.github.com/10232076.git", "git_push_url": "https://gist.github.com/10232076.git", "html_url": "https://gist.github.com/10232076", "files": { "ScrollableGridView.java": { "filename": "ScrollableGridView.java", "type": "text/plain", "language": "Java", "raw_url": "https://gist.githubusercontent.com/kumarvmsathish/10232076/raw/490b09b86dc7d154d12dd754a1cb0ac47276343c/ScrollableGridView.java", "size": 1399 } }, "public": true, "created_at": "2014-04-09T06:33:20Z", "updated_at": "2014-04-09T06:33:20Z", "description": null, "comments": 0, "user": { "login": "kumarvmsathish", "id": 5295401, "avatar_url": "https://avatars.githubusercontent.com/u/5295401?", "gravatar_id": "d85ebb855467b4c0aa03d4b394a3396f", "url": "https://api.github.com/users/kumarvmsathish", "html_url": "https://github.com/kumarvmsathish", "followers_url": "https://api.github.com/users/kumarvmsathish/followers", "following_url": "https://api.github.com/users/kumarvmsathish/following{/other_user}", "gists_url": "https://api.github.com/users/kumarvmsathish/gists{/gist_id}", "starred_url": "https://api.github.com/users/kumarvmsathish/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kumarvmsathish/subscriptions", "organizations_url": "https://api.github.com/users/kumarvmsathish/orgs", "repos_url": "https://api.github.com/users/kumarvmsathish/repos", "events_url": "https://api.github.com/users/kumarvmsathish/events{/privacy}", "received_events_url": "https://api.github.com/users/kumarvmsathish/received_events", "type": "User", "site_admin": false }, "comments_url": "https://api.github.com/gists/10232076/comments" }, { "url": "https://api.github.com/gists/10232038", "forks_url": "https://api.github.com/gists/10232038/forks", "commits_url": "https://api.github.com/gists/10232038/commits", "id": "10232038", "git_pull_url": "https://gist.github.com/10232038.git", "git_push_url": "https://gist.github.com/10232038.git", "html_url": "https://gist.github.com/10232038", "files": { "osx_oracle_client.md": { "filename": "osx_oracle_client.md", "type": "text/plain", "language": "Markdown", "raw_url": "https://gist.githubusercontent.com/usutani/10232038/raw/fc7616e65fbddf52e3735016fb86ba79d6e7e06f/osx_oracle_client.md", "size": 172 } }, "public": true, "created_at": "2014-04-09T06:32:46Z", "updated_at": "2014-04-09T06:34:55Z", "description": "OS X Mavericks に Oracle Client をインストール", "comments": 1, "user": { "login": "usutani", "id": 56579, "avatar_url": "https://avatars.githubusercontent.com/u/56579?", "gravatar_id": "c702d3fad57bde7ba189eec1b4c593e3", "url": "https://api.github.com/users/usutani", "html_url": "https://github.com/usutani", "followers_url": "https://api.github.com/users/usutani/followers", "following_url": "https://api.github.com/users/usutani/following{/other_user}", "gists_url": "https://api.github.com/users/usutani/gists{/gist_id}", "starred_url": "https://api.github.com/users/usutani/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/usutani/subscriptions", "organizations_url": "https://api.github.com/users/usutani/orgs", "repos_url": "https://api.github.com/users/usutani/repos", "events_url": "https://api.github.com/users/usutani/events{/privacy}", "received_events_url": "https://api.github.com/users/usutani/received_events", "type": "User", "site_admin": false }, "comments_url": "https://api.github.com/gists/10232038/comments" },
  2. }
  3. ]
  4.  
  5. String user;
  6. JSONArray data = json.getJSONArray(YOUR_ARRAY); //json is JSONObject
  7. JSONObject object = data.getJSONObject(0);
  8. user = object.getString("user");
  9.  
  10. int arrayLength = json.length();
  11.  
  12. for(int i=0;i<arrayLength;i++){
  13.  
  14. // Get the single object in the array
  15. JSONObject singleObject = json.getJSONObject(i);
  16.  
  17. if (singleObject.has("user")) {
  18.  
  19. JSONObject userObject = singleObject.getJSONObject("user");
  20. // TODO: retrieve user jsonobjects data
  21. }
  22. }
  23.  
  24. JSONArray jsonarray = new JSONArray(response);
  25.  
  26. for (int i=0; i < jsonarray.length(); i++){
  27. JSONObject jsob = jsonarray.getJSONObject(i);
  28. String url = jsob.getString("url");
  29. //same for remaining like url,forks_url etc.,
  30. JSONObject files_obj = jsob.getJSONObject("files").getJSONObject("gulpfile-viget-pattern.js");
  31. String type = files_obj.getString("type");
  32. //same for remaining like type,language etc.,
  33. JSONObject user_obj = jsob.getJSONObject("user");
  34. String login = user_obj.getString("login");
  35. //same for remaining like login,url etc.,
  36. }
  37.  
  38. JSONArray jarray = new JSONArray(Your_Response);
  39.  
  40. for (int i=0; i < jarray.length(); i++){
  41. JSONObject jb= jarray.getJSONObject(i);
  42. String url = jb.optString("url");
  43.  
  44. JSONObject other_jb= jb.getJSONObject("files").getJSONObject("gulpfile-viget-pattern.js");
  45. String type = other_jb.optString("type");
  46.  
  47. JSONObject jsonObject_of_user = jb.getJSONObject("user");
  48. String user_login = jsonObject_of_user.optString("login");
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement