Created
July 3, 2014 19:37
-
-
Save DV8FromTheWorld/03dda571e112ee4f3fd5 to your computer and use it in GitHub Desktop.
getId and getLink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Uses Regex on the provided JSON String to find the 'link' tag. | |
| * | |
| * @param jsonResponse | |
| * The JSON response from Imgur. | |
| * @return | |
| * The link to the image. | |
| */ | |
| private String getLink(String jsonResponse) | |
| { | |
| Pattern pattern = Pattern.compile("link\":\"(.*?)\""); | |
| Matcher matcher = pattern.matcher(jsonResponse); | |
| matcher.find(); | |
| return matcher.group().replace("link\":\"", "").replace("\"", "").replace("\\/", "/"); | |
| } | |
| /** | |
| * Uses Regex on the provided JSON String to find the 'id' tag. | |
| * | |
| * @param jsonResponse | |
| * The JSON response from Imgur. | |
| * @return | |
| * The id of the image or album. | |
| */ | |
| private String getId(String jsonResponse) | |
| { | |
| Pattern pattern = Pattern.compile("id\":\"(.*?)\""); | |
| Matcher matcher = pattern.matcher(jsonResponse); | |
| matcher.find(); | |
| return matcher.group().replace("id\":\"", "").replace("\"", ""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment