List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
From source file:org.jboss.aerogear.simplepush.server.netty.standalone.ConfigReader.java
private static SockJsConfig parseSockJsProperties(final JsonNode json) { final JsonNode prefixNode = json.get("sockjs-prefix"); final String prefix = prefixNode != null ? prefixNode.asText() : "/simplepush"; final org.jboss.aerogear.io.netty.handler.codec.sockjs.SockJsConfig.Builder builder = SockJsConfig .withPrefix(prefix);/*from www .ja v a2s.c om*/ final JsonNode cookiesNeeded = json.get("sockjs-cookies-needed"); if (cookiesNeeded != null && cookiesNeeded.asBoolean()) { builder.cookiesNeeded(); } final JsonNode sockjsUrl = json.get("sockjs-url"); if (sockjsUrl != null) { builder.sockJsUrl(sockjsUrl.asText()); } final JsonNode sessionTimeout = json.get("sockjs-session-timeout"); if (sessionTimeout != null) { builder.sessionTimeout(sessionTimeout.asLong()); } final JsonNode heartbeatInterval = json.get("sockjs-heartbeat-interval"); if (heartbeatInterval != null) { builder.heartbeatInterval(heartbeatInterval.asLong()); } final JsonNode maxStreamingBytesSize = json.get("sockjs-max-streaming-bytes-size"); if (maxStreamingBytesSize != null) { builder.maxStreamingBytesSize(maxStreamingBytesSize.asInt()); } final JsonNode keystore = json.get("sockjs-keystore"); if (keystore != null) { builder.keyStore(keystore.asText()); } final JsonNode keystorePassword = json.get("sockjs-keystore-password"); if (keystorePassword != null) { builder.keyStorePassword(keystorePassword.asText()); } final JsonNode tls = json.get("sockjs-tls"); if (tls != null) { builder.tls(tls.asBoolean()); } final JsonNode websocketEnable = json.get("sockjs-websocket-enable"); if (websocketEnable != null && !websocketEnable.asBoolean()) { builder.disableWebSocket(); } final JsonNode websocketHeartbeatInterval = json.get("sockjs-websocket-heartbeat-interval"); if (websocketHeartbeatInterval != null) { builder.webSocketHeartbeatInterval(websocketHeartbeatInterval.asLong()); } final JsonNode websocketProtocols = json.get("sockjs-websocket-protocols"); if (websocketProtocols != null) { builder.webSocketProtocols(websocketProtocols.asText().split(",")); } return builder.build(); }
From source file:com.meetingninja.csse.database.GroupDatabaseAdapter.java
public static Group parseGroup(JsonNode groupNode, Group g) { // Group g = new Group(); String groupID = groupNode.get(Keys.Group.ID).asText(); if (groupID != null) { g.setID(groupID);/*from w w w.j a va 2 s .c o m*/ g.setGroupTitle(groupNode.get(Keys.Group.TITLE).asText()); JsonNode members = groupNode.get(Keys.Group.MEMBERS); if (members != null && members.isArray()) { for (final JsonNode memberNode : members) { User user = new User(); user.setID(memberNode.get(Keys.User.ID).asText()); g.addMember(user); } } } return g; }
From source file:io.orchestrate.client.RequestException.java
private static String getMessageFromJson(JsonNode node, String rawResponse) { if (node == null) { return rawResponse; }/*from www .ja va2s. c o m*/ if (node.has("message")) { return node.get("message").asText(); } return rawResponse; }
From source file:org.fcrepo.camel.processor.EventProcessor.java
private static Optional<String> getString(final JsonNode node, final String fieldName) { if (node.has(fieldName)) { final JsonNode field = node.get(fieldName); if (field.isTextual()) { return of(field.asText()); }//w w w . ja v a 2s . c o m } return empty(); }
From source file:com.arpnetworking.configuration.jackson.BaseJsonNodeSource.java
/** * Find the <code>JsonNode</code> if one exists from a specified root node * given a sequence of keys to look-up.//from w w w . ja v a 2 s. com * * @param node The root <code>JsonNode</code>. * @param keys The sequence of keys to search for. * @return The <code>Optional</code> <code>JsonNode</code> instance. */ protected static Optional<JsonNode> getValue(final Optional<JsonNode> node, final String... keys) { JsonNode jsonNode = node.orElse(null); for (final String key : keys) { if (jsonNode == null) { break; } jsonNode = jsonNode.get(key); } return Optional.ofNullable(jsonNode); }
From source file:controllers.user.UserAvatarApp.java
/** * ?email?id//w w w. jav a 2s .c o m * * @return */ @Transactional public static Result queryIdByEmail() { JsonNode jsonNode = getJson(); ObjectNodeResult result = new ObjectNodeResult(); Iterator<JsonNode> emails = jsonNode.get("emails").elements(); List<String> s = new ArrayList<String>(); while (emails.hasNext()) { String email = emails.next().asText(); s.add(email); } List<User> list = User.queryIdByEmail(s); ObjectNode objectNode = Json.newObject(); for (User user : list) { objectNode.put(user.email, user.id); } result.put("user", objectNode); return ok(result.getObjectNode()); }
From source file:controllers.oer.NtToEs.java
static String findParent(String jsonLd) { JsonNode value = Json.parse(jsonLd).findValue("addressCountry"); return value != null && value.isArray() /* else in context */ ? value.get(0).asText().trim() : "http://sws.geonames.org/"; }
From source file:de.qaware.cloud.deployer.commons.config.util.ContentTreeUtil.java
/** * Reads the node with the specified key in the object tree. * * @param contentObjectTree The object tree which contains the node identified by the specified key. * @param key The key which identifies the node. * @return The value of the key in form of a node. * @throws ResourceConfigException If the key isn't available in the object tree. *//*ww w.j av a2 s . c o m*/ public static JsonNode readNodeValue(JsonNode contentObjectTree, String key) throws ResourceConfigException { if (contentObjectTree.hasNonNull(key)) { return contentObjectTree.get(key); } else { throw new ResourceConfigException( COMMONS_MESSAGE_BUNDLE.getMessage("DEPLOYER_COMMONS_ERROR_READING_NODE_VALUE", key)); } }
From source file:controllers.Index.java
private static void readData(final BulkRequestBuilder bulkRequest, final BufferedReader br, final Client client, final String aIndex) throws IOException { final ObjectMapper mapper = new ObjectMapper(); String line;/*ww w . ja v a2 s . c om*/ int currentLine = 1; String organisationData = null; String[] idUriParts = null; String organisationId = null; // First line: index with id, second line: source while ((line = br.readLine()) != null) { JsonNode rootNode = mapper.readValue(line, JsonNode.class); if (currentLine % 2 != 0) { JsonNode index = rootNode.get("index"); idUriParts = index.findValue("_id").asText().split("/"); organisationId = idUriParts[idUriParts.length - 1].replace("#!", ""); } else { organisationData = line; JsonNode libType = rootNode.get("type"); if (libType == null || !libType.textValue().equals("Collection")) { bulkRequest.add(client .prepareIndex(aIndex, Application.CONFIG.getString("index.es.type"), organisationId) .setSource(organisationData)); } } currentLine++; } }
From source file:org.fcrepo.camel.processor.EventProcessor.java
private static Optional<List<String>> getValues(final JsonNode node, final String fieldName) { if (node.has(fieldName)) { final JsonNode field = node.get(fieldName); if (field.isArray()) { final List<String> elements = new ArrayList<>(); field.elements().forEachRemaining(elem -> { if (elem.isTextual()) { elements.add(elem.asText()); }/*from w ww . jav a2 s. c o m*/ }); return of(elements); } else if (field.isTextual()) { return of(singletonList(field.asText())); } } return empty(); }