List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static PosterType parsePosterType(JsonNode rootNode) { JsonNode node = rootNode.get("poster"); if (node != null) { String href = getValueAsString(node.get("href")); if (href != null) { PosterType posterType = new PosterType(); posterType.setHref(href);//from www.j a v a 2s . c o m return posterType; } } return null; }
From source file:com.github.fge.jsonpatch.diff.JsonDiff.java
private static void computeObject(final Map<JsonPointer, JsonNode> ret, final JsonPointer pointer, final JsonNode source, final JsonNode target) { final Iterator<String> firstFields = source.fieldNames(); String name;//from w w w. jav a 2 s . co m while (firstFields.hasNext()) { name = firstFields.next(); if (!target.has(name)) continue; computeUnchanged(ret, pointer.append(name), source.get(name), target.get(name)); } }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseSeasonList(List<Season> seasons, JsonNode rootNode) { JsonNode node = rootNode.get("season"); if (node != null && (node.size() > 0)) { for (int i = 0; i < node.size(); i++) { JsonNode seasonNode = node.get(i); Season season = new Season(); season.setCode(getValueAsInt(seasonNode.get("code"))); season.setSeasonNumber(getValueAsInt(seasonNode.get("seasonNumber"))); season.setYearStart(getValueAsString(seasonNode.get("yearStart"))); season.setYearEnd(getValueAsString(seasonNode.get("yearEnd"))); seasons.add(season);//from w ww .ja va 2s . c o m } } }
From source file:com.cyphermessenger.client.SyncRequest.java
public static void userLogout(CypherSession session) throws IOException, APIErrorException { HttpURLConnection conn = doRequest("logout", session, null); if (conn.getResponseCode() != 200) { throw new IOException("Server error"); }/* w w w . j a va 2 s.c om*/ InputStream in = conn.getInputStream(); JsonNode node = MAPPER.readTree(in); conn.disconnect(); int statusCode = node.get("status").asInt(); if (statusCode != StatusCode.OK) { throw new APIErrorException(statusCode); } }
From source file:com.cyphermessenger.client.SyncRequest.java
public static PullResults pullContacts(CypherSession session, Boolean since, Long time) throws IOException, APIErrorException { JsonNode node = pullUpdate(session, null, "contacts", since, time); int statusCode = node.get("status").asInt(); if (statusCode == StatusCode.OK) { ArrayList<CypherContact> array = handleContactNode(node); return new PullResults(null, array, null, node.get("notifiedUntil").asLong()); } else {//from www .jav a 2 s . c o m throw new APIErrorException(statusCode); } }
From source file:com.cyphermessenger.client.SyncRequest.java
public static PullResults pullKeys(CypherSession session, CypherUser contact, Boolean since, Long time) throws IOException, APIErrorException { JsonNode node = pullUpdate(session, contact, "keys", since, time); int statusCode = node.get("status").asInt(); if (statusCode == StatusCode.OK) { return new PullResults(null, null, handleKeyNode(node, contact == null ? session.getUser().getLocalPassword() : null), node.get("notifiedUntil").asLong()); } else {/*w w w. j a v a 2s. c o m*/ throw new APIErrorException(statusCode); } }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static void parseEpisodeList(List<Episode> episodes, JsonNode rootNode) { JsonNode node = rootNode.get("episode"); if (node != null && (node.size() > 0)) { for (int i = 0; i < node.size(); i++) { JsonNode episodeNode = node.get(i); Episode episode = new Episode(); episode.setCode(getValueAsInt(episodeNode.get("code"))); episode.setTitle(getValueAsString(episodeNode.get("title"))); episode.setOriginalTitle(getValueAsString(episodeNode.get("originalTitle"))); episode.setEpisodeNumberSeries(getValueAsInt(episodeNode.get("episodeNumberSeries"))); episode.setEpisodeNumberSeason(getValueAsInt(episodeNode.get("episodeNumberSeason"))); episode.setSynopsis(getValueAsString(episodeNode.get("synopsis"))); episodes.add(episode);//from w w w . j av a 2s .c om } } }
From source file:com.cyphermessenger.client.SyncRequest.java
public static PullResults pullMessages(CypherSession session, CypherUser contact, Boolean since, Long time) throws IOException, APIErrorException { JsonNode node = pullUpdate(session, contact, "messages", since, time); int statusCode = node.get("status").asInt(); if (statusCode == StatusCode.OK) { ArrayList<CypherMessage> array = handleMessageNode(node, session.getUser().getKey(), contact.getKey()); return new PullResults(array, null, null, node.get("notifiedUntil").asLong()); } else {//w ww . j a v a2 s . c o m throw new APIErrorException(statusCode); } }
From source file:com.cyphermessenger.client.SyncRequest.java
public static PullResults pullAll(CypherSession session, CypherUser contact, Boolean since, Long time) throws IOException, APIErrorException { JsonNode node = pullUpdate(session, contact, "all", since, time); int statusCode = node.get("status").asInt(); if (statusCode == StatusCode.OK) { ArrayList<ECKey> keysArray = handleKeyNode(node, contact == null ? session.getUser().getLocalPassword() : null); ArrayList<CypherContact> contactsArray = handleContactNode(node); ArrayList<CypherMessage> messagesArray = handleMessageNode(node, session.getUser().getKey(), contact != null ? contact.getKey() : null); long notifiedUntil = node.get("notifiedUntil").asLong(); return new PullResults(messagesArray, contactsArray, keysArray, notifiedUntil); } else {/*from w w w . j a v a 2s. c om*/ throw new APIErrorException(statusCode); } }
From source file:com.tda.sitefilm.allocine.JSONAllocineAPIHelper.java
private static Statistics parseStatistics(JsonNode rootNode) { JsonNode node = rootNode.get("statistics"); if (node != null) { JsonNode ratingNode = node.get("rating"); if (ratingNode != null && (ratingNode.size() > 0)) { Statistics statistics = new Statistics(); for (int i = 0; i < ratingNode.size(); i++) { node = ratingNode.get(i); RatingType ratingType = new RatingType(); ratingType.setNote(getValueAsFloat(node.get("note"))); ratingType.setValue(getValueAsInt(node.get("$"))); if (statistics.getRatingStats() == null) statistics.setRatingStats(new RatingStatsType()); statistics.getRatingStats().getRating().add(ratingType); }//w ww. jav a 2s . co m return statistics; } } return null; }