@Test public void testParse() throws IOException, ParseException { InputStream resource = GalleryPageApiParserTest.class.getResourceAsStream("GalleryPageApiParserTest.json"); BufferedSource source = Okio.buffer(Okio.source(resource)); String body = source.readUtf8(); GalleryPageApiParser.Result result = GalleryPageApiParser.parse(body); assertEquals("http: assertEquals("15151-430636", result.skipHathKey); assertEquals("https: }
public static Result parse(String body) throws ParseException { try { Matcher m; Result result = new Result(); JSONObject jo = new JSONObject(body); if (jo.has("error")) { throw new ParseException(jo.getString("error"), body); } String i3 = jo.getString("i3"); m = PATTERN_IMAGE_URL.matcher(i3); if (m.find()) { result.imageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i6 = jo.getString("i6"); m = PATTERN_SKIP_HATH_KEY.matcher(i6); if (m.find()) { result.skipHathKey = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i7 = jo.getString("i7"); m = PATTERN_ORIGIN_IMAGE_URL.matcher(i7); if (m.find()) { result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2)); } if (!TextUtils.isEmpty(result.imageUrl)) { return result; } else { throw new ParseException("Parse image url and skip hath key error", body); } } catch (JSONException e) { throw new ParseException("Can't parse json", body, e); } }
GalleryPageApiParser { public static Result parse(String body) throws ParseException { try { Matcher m; Result result = new Result(); JSONObject jo = new JSONObject(body); if (jo.has("error")) { throw new ParseException(jo.getString("error"), body); } String i3 = jo.getString("i3"); m = PATTERN_IMAGE_URL.matcher(i3); if (m.find()) { result.imageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i6 = jo.getString("i6"); m = PATTERN_SKIP_HATH_KEY.matcher(i6); if (m.find()) { result.skipHathKey = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i7 = jo.getString("i7"); m = PATTERN_ORIGIN_IMAGE_URL.matcher(i7); if (m.find()) { result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2)); } if (!TextUtils.isEmpty(result.imageUrl)) { return result; } else { throw new ParseException("Parse image url and skip hath key error", body); } } catch (JSONException e) { throw new ParseException("Can't parse json", body, e); } } }
GalleryPageApiParser { public static Result parse(String body) throws ParseException { try { Matcher m; Result result = new Result(); JSONObject jo = new JSONObject(body); if (jo.has("error")) { throw new ParseException(jo.getString("error"), body); } String i3 = jo.getString("i3"); m = PATTERN_IMAGE_URL.matcher(i3); if (m.find()) { result.imageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i6 = jo.getString("i6"); m = PATTERN_SKIP_HATH_KEY.matcher(i6); if (m.find()) { result.skipHathKey = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i7 = jo.getString("i7"); m = PATTERN_ORIGIN_IMAGE_URL.matcher(i7); if (m.find()) { result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2)); } if (!TextUtils.isEmpty(result.imageUrl)) { return result; } else { throw new ParseException("Parse image url and skip hath key error", body); } } catch (JSONException e) { throw new ParseException("Can't parse json", body, e); } }  }
GalleryPageApiParser { public static Result parse(String body) throws ParseException { try { Matcher m; Result result = new Result(); JSONObject jo = new JSONObject(body); if (jo.has("error")) { throw new ParseException(jo.getString("error"), body); } String i3 = jo.getString("i3"); m = PATTERN_IMAGE_URL.matcher(i3); if (m.find()) { result.imageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i6 = jo.getString("i6"); m = PATTERN_SKIP_HATH_KEY.matcher(i6); if (m.find()) { result.skipHathKey = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i7 = jo.getString("i7"); m = PATTERN_ORIGIN_IMAGE_URL.matcher(i7); if (m.find()) { result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2)); } if (!TextUtils.isEmpty(result.imageUrl)) { return result; } else { throw new ParseException("Parse image url and skip hath key error", body); } } catch (JSONException e) { throw new ParseException("Can't parse json", body, e); } }  static Result parse(String body); }
GalleryPageApiParser { public static Result parse(String body) throws ParseException { try { Matcher m; Result result = new Result(); JSONObject jo = new JSONObject(body); if (jo.has("error")) { throw new ParseException(jo.getString("error"), body); } String i3 = jo.getString("i3"); m = PATTERN_IMAGE_URL.matcher(i3); if (m.find()) { result.imageUrl = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i6 = jo.getString("i6"); m = PATTERN_SKIP_HATH_KEY.matcher(i6); if (m.find()) { result.skipHathKey = StringUtils.unescapeXml(StringUtils.trim(m.group(1))); } String i7 = jo.getString("i7"); m = PATTERN_ORIGIN_IMAGE_URL.matcher(i7); if (m.find()) { result.originImageUrl = StringUtils.unescapeXml(m.group(1)) + "fullimg.php" + StringUtils.unescapeXml(m.group(2)); } if (!TextUtils.isEmpty(result.imageUrl)) { return result; } else { throw new ParseException("Parse image url and skip hath key error", body); } } catch (JSONException e) { throw new ParseException("Can't parse json", body, e); } }  static Result parse(String body);  }