List of usage examples for com.fasterxml.jackson.databind JsonNode asText
public abstract String asText();
From source file:org.jboss.aerogear.webpush.standalone.ConfigReader.java
private static WebPushServerConfig parseWebPushProperties(final JsonNode json) { final JsonNode host = json.get("host"); final JsonNode port = json.get("port"); final Builder builder = DefaultWebPushConfig.create(host.asText(), port.asInt()); final JsonNode password = json.get("password"); if (password != null) { builder.password(password.asText()); }//from w w w. j ava2 s. c om final JsonNode cert = json.get("cert"); if (cert != null) { builder.cert(cert.asText()); } final JsonNode privateKey = json.get("privateKey"); if (privateKey != null) { builder.privateKey(privateKey.asText()); } final JsonNode endpointHost = json.get("endpoint-host"); if (endpointHost != null) { builder.endpointHost(endpointHost.asText()); } final JsonNode endpointPort = json.get("endpoint-port"); if (endpointPort != null) { builder.endpointPort(endpointPort.asInt()); } final JsonNode endpointTls = json.get("endpoint-tls"); if (endpointTls != null) { builder.endpointTls(endpointTls.asBoolean()); } final JsonNode subscriptionMaxAge = json.get("subscription-max-age"); if (subscriptionMaxAge != null) { builder.subscriptionMaxAge(subscriptionMaxAge.asLong()); } return builder.build(); }
From source file:org.opendaylight.ovsdb.northbound.OvsdbRow.java
public static OvsdbRow fromJsonNode(OvsdbClient client, String dbName, JsonNode json) { JsonNode parentUuidNode = json.get(PARENTUUID); String parentUuid = null;//from w w w. ja v a 2 s . co m if (parentUuidNode != null) { parentUuid = parentUuidNode.asText(); } JsonNode parentTableNode = json.get(PARENTTABLE); String parentTable = null; if (parentTableNode != null) { parentTable = parentTableNode.asText(); } JsonNode parentColumnNode = json.get(PARENTCOLUMN); String parentColumn = null; if (parentColumnNode != null) { parentColumn = parentColumnNode.asText(); } JsonNode rowNode = json.get(ROW); if (rowNode == null) { return null; } for (Iterator<String> fieldNames = rowNode.fieldNames(); fieldNames.hasNext();) { String tableName = fieldNames.next(); Row<GenericTableSchema> row = null; try { row = getRow(client, dbName, tableName, rowNode.get(tableName)); } catch (InterruptedException | ExecutionException | IOException e) { e.printStackTrace(); return null; } return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row); } return null; }
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()); }//from w w w. j a v a2 s .c o m } return empty(); }
From source file:io.sqp.schemamatcher.typematchers.TypeMatcher.java
public static TypeMatcher createForSchema(JsonNode schema) { JsonNode typeField = schema.get("type"); if (typeField == null) { throw new InvalidSchemaException("The schema doesn't contain a type field"); }/* www.jav a2 s .c o m*/ JsonType type = JsonType.parse(typeField.asText()); switch (type) { case Integer: case Number: return new NumberTypeMatcher(type, schema); case String: return new StringTypeMatcher(schema); case Object: return new ObjectTypeMatcher(schema); case Array: return new ArrayTypeMatcher(schema); default: return new TrivialTypeMatcher(type); } }
From source file:com.squarespace.template.GeneralUtils.java
/** * Obtains the text representation of a node, converting {@code null} to * empty string.// w w w.jav a2s. c o m */ public static String eatNull(JsonNode node) { return node.isNull() ? "" : node.asText(); }
From source file:com.squarespace.template.GeneralUtils.java
public static String ifString(JsonNode node, String defaultString) { return isTruthy(node) ? node.asText() : defaultString; }
From source file:nextflow.fs.dx.api.DxEnv.java
private static String getTextValue(JsonNode jsonNode, String key) { JsonNode value = jsonNode.get(key); if (value == null) { return null; }//w w w . j a v a 2 s .c o m return value.asText(); }
From source file:com.squarespace.template.GeneralUtils.java
/** * Determines the boolean value of a node based on its type. *///from ww w . j av a2 s .c o m public static boolean isTruthy(JsonNode node) { if (node.isTextual()) { return !node.asText().equals(""); } if (node.isNumber() || node.isBoolean()) { return node.asLong() != 0; } if (node.isMissingNode() || node.isNull()) { return false; } return node.size() != 0; }
From source file:com.reprezen.swagedit.json.references.JsonReference.java
public static JsonPointer getPointer(JsonNode node) { JsonNode value = node.get(PROPERTY); if (value != null) { return createPointer(value.asText()); } else {//from w w w .ja v a 2 s . c om return createPointer(null); } }
From source file:org.apache.usergrid.android.sdk.utils.JsonUtils.java
public static UUID getUUIDProperty(Map<String, JsonNode> properties, String name) { JsonNode value = properties.get(name); if (value != null) { UUID uuid = null;// ww w . j ava 2 s . co m try { uuid = UUID.fromString(value.asText()); } catch (Exception e) { } return uuid; } return null; }