/** * get json content of page * * @return json * @since 0.5.0 */ public Json getJson() { if (json == null) { json = new Json(rawText); } return json; }
@Override public List<String> process(File inItem) { List<String> outItems = null; try { BufferedReader in = new BufferedReader( new FileReader(inItem) ); String s; in.readLine();//pass first line s = in.readLine(); if (s != null) { Json json = new Json(s); outItems = json.jsonPath("$.data[*].[*]").all(); } in.close(); } catch (IOException e) { e.printStackTrace(); } return outItems; } }
@Override public List<String> process(File inItem) { String s = readFollowees(inItem); if (!StringUtils.isEmpty(s)) { Json json = new Json(s); List<String> tokens = json.jsonPath("$.data[*].url_token").all(); tokens.forEach(urlTokens::add); } return null; }
@Override public List<Document> process(File inItem) { String s = readMember(inItem); List<Document> documents = null; if (!StringUtils.isEmpty(s)) { documents = new ArrayList<>(1); Json json = new Json(s); String id = json.jsonPath("$.id").get(); if (!duplicateRemover.isDuplicate(id)) { documents.add(new Document(id, s)); } } return documents; }
@Override public List<Document> process(File inItem) { String s = MemberURLTokenGenerator.readFollowees(inItem); List<Document> documents = null; if (!StringUtils.isEmpty(s)) { documents = new ArrayList<>(20); Json json = new Json(s); List<String> users = json.jsonPath("$.data[*].[*]").all(); List<String> ids = json.jsonPath("$.data[*].id").all(); int i = 0; for (String id : ids) { if (!duplicateRemover.isDuplicate(id)) { documents.add(new Document(id, users.get(i))); } i++; } } return documents; }
/** * remove padding for JSONP * @param padding padding * @return json after padding removed */ public Json removePadding(String padding) { String text = getFirstSourceText(); XTokenQueue tokenQueue = new XTokenQueue(text); tokenQueue.consumeWhitespace(); tokenQueue.consume(padding); tokenQueue.consumeWhitespace(); String chompBalanced = tokenQueue.chompBalancedNotInQuotes('(', ')'); return new Json(chompBalanced); }
/** * get json content of page * * @return json * @since 0.5.0 */ public Json getJson() { if (json == null) { json = new Json(rawText); } return json; }
/** * remove padding for JSONP * @param padding padding * @return json after padding removed */ public Json removePadding(String padding) { String text = getFirstSourceText(); XTokenQueue tokenQueue = new XTokenQueue(text); tokenQueue.consumeWhitespace(); tokenQueue.consume(padding); tokenQueue.consumeWhitespace(); String chompBalanced = tokenQueue.chompBalancedNotInQuotes('(', ')'); return new Json(chompBalanced); }