List of usage examples for com.fasterxml.jackson.databind JsonNode asText
public abstract String asText();
From source file:com.redhat.lightblue.query.ArrayContainsExpression.java
/** * Parses an ArrayContainsExpression from a JSON object node. *//*from w w w . j av a2 s .c o m*/ public static ArrayContainsExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("contains"); if (x != null) { ContainsOperator op = ContainsOperator.fromString(x.asText()); if (op != null) { x = node.get("values"); if (x instanceof ArrayNode) { ArrayList<Value> values = new ArrayList<>(((ArrayNode) x).size()); for (Iterator<JsonNode> itr = ((ArrayNode) x).elements(); itr.hasNext();) { values.add(Value.fromJson(itr.next())); } return new ArrayContainsExpression(field, op, values); } } } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); }
From source file:services.TodoService.java
public static String delete(String accessToken, String username, Long id) { WSRequestHolder req = WS.url(OAUTH_RESOURCE_SERVER_URL + "/rest/todos/" + id + "/delete"); req.setHeader("Authorization", "Bearer " + accessToken); Promise<String> jsonPromise = req.post("").map(new Function<WSResponse, String>() { public String apply(WSResponse response) { JsonNode json = response.asJson(); return json.asText(); }/* w w w .j a va2 s .co m*/ }); return jsonPromise.get(5000); }
From source file:com.smartsheet.tin.filters.common.JsonFilterTools.java
public static String fetchChildString(JsonNode parent, String node_name, boolean required) throws JsonFilterException { String result = null;/* w ww . j a va2 s. c o m*/ try { JsonNode child = fetchChildByName(parent, node_name, "string"); result = child.asText(); } catch (JsonFilterException e) { if (required) { throw e; } } return result; }
From source file:org.jboss.aerogear.sync.server.netty.ConfigReader.java
private static StandaloneConfig parseProperties(final JsonNode json) { final Builder b = StandaloneConfig.host(json.get("host").asText()); b.port(json.get("port").asInt()); final JsonNode gcm = json.get("gcm"); if (gcm != null) { final JsonNode enabled = gcm.get("enabled"); if (enabled != null && enabled.asBoolean()) { b.gcmEnabled();/*w w w.j a v a 2 s. com*/ } final JsonNode gcmHost = gcm.get("host"); if (gcmHost != null) { b.gcmHost(gcmHost.asText()); } final JsonNode gcmPort = gcm.get("port"); if (gcmPort != null) { b.gcmPort(gcmPort.asInt()); } final JsonNode gcmSenderId = gcm.get("senderId"); if (gcmSenderId != null) { b.gcmSenderId(gcmSenderId.asLong()); } final JsonNode gcmApiKey = gcm.get("apiKey"); if (gcmApiKey != null) { b.gcmApiKey(gcmApiKey.asText()); } } return b.build(); }
From source file:com.redhat.lightblue.query.NaryFieldRelationalExpression.java
/** * Parses an n-ary relational expression from the given json object *//*from ww w. java2 s .c o m*/ public static NaryFieldRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { NaryRelationalOperator op = NaryRelationalOperator.fromString(x.asText()); if (op != null) { x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("rfield"); if (x != null) { return new NaryFieldRelationalExpression(field, op, new Path(x.asText())); } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); }
From source file:com.squarespace.template.plugins.platform.PlatformUtils.java
public static void makeSocialButton(JsonNode website, JsonNode item, boolean inline, StringBuilder buf) { JsonNode options = website.path("shareButtonOptions"); if (website.isMissingNode() || options.isMissingNode() || options.size() == 0) { return;/*w w w.j a v a 2 s .c o m*/ } JsonNode node = GeneralUtils.getFirstMatchingNode(item, "systemDataId", "mainImageId"); String imageId = node.asText(); node = item.path("assetUrl"); String assetUrl = node.asText(); if (node.isMissingNode()) { node = item.path("mainImage").path("assetUrl"); assetUrl = node.asText(); } String style = (inline) ? "inline-style" : "button-style"; if (inline) { buf.append("<span "); } else { buf.append("<div "); } buf.append("class=\"squarespace-social-buttons "); buf.append(style); buf.append("\" data-system-data-id=\""); buf.append(imageId); buf.append("\" data-asset-url=\""); buf.append(assetUrl); buf.append("\" data-record-type=\""); buf.append(item.path("recordType").asText()); buf.append("\" data-full-url=\""); buf.append(item.path("fullUrl").asText()); buf.append("\" data-title=\""); PluginUtils.escapeHtmlAttribute(item.path("title").asText(), buf); buf.append("\">"); if (inline) { buf.append("</span>"); } else { buf.append("</div>"); } }
From source file:com.redhat.lightblue.query.RegexMatchExpression.java
public static RegexMatchExpression fromJson(ObjectNode node) { JsonNode x = node.get("field"); if (x != null) { Path field = new Path(x.asText()); x = node.get("regex"); if (x != null) { String regex = x.asText(); return new RegexMatchExpression(field, regex, asBoolean(node.get("caseInsensitive")), asBoolean(node.get("multiline")), asBoolean(node.get("extended")), asBoolean(node.get("dotall"))); }/*from ww w. j a v a2 s.c o m*/ } throw Error.get(QueryConstants.ERR_INVALID_REGEX_EXPRESSION, node.toString()); }
From source file:de.thingweb.typesystem.TypeSystemChecker.java
public static boolean isJsonSchemaType(JsonNode type) { boolean isJsonSchema = false; // TODO use JSON schema parser if (type != null && type.getNodeType() == JsonNodeType.OBJECT) { JsonNode value = type.findValue("type"); if (value != null) { isJsonSchema = JSON_SCHEMA_PRIMITIVE_TYPES.contains(value.asText()); }/*from ww w.jav a2 s. c o m*/ } return isJsonSchema; }
From source file:org.apache.usergrid.java.client.utils.JsonUtils.java
@Nullable public static String getStringProperty(@NotNull final Map<String, JsonNode> properties, @NotNull final String name) { JsonNode value = properties.get(name); if (value != null) { return value.asText(); }//from w w w. j a v a 2s .co m return null; }
From source file:com.redhat.smonkey.Utils.java
public static String asString(JsonNode value, String def) { return value == null ? def : value.asText(); }