List of usage examples for com.fasterxml.jackson.databind JsonNode asText
public abstract String asText();
From source file:com.redhat.lightblue.query.UpdateQueryExpression.java
/** * Parses a query expression that can be used in for-each clauses *//*ww w .j a v a2 s. c o m*/ public static QueryExpression fromJson(JsonNode node) { if (node instanceof TextNode && "$all".equals(node.asText())) { return new AllMatchExpression(); } else { return QueryExpression.fromJson(node); } }
From source file:com.ibm.watson.catalyst.corpus.document.BasicDocumentFactory.java
private static List<String> getParagraphs(JsonNode aNode) { List<String> result = new ArrayList<String>(); for (JsonNode paragraph : aNode.get("paragraphs")) { result.add(paragraph.asText()); }/* ww w . ja v a2s .c o m*/ return result; }
From source file:com.redhat.lightblue.query.ForEachUpdateExpression.java
/** * Parses a foreach update expression from the given json object *//*from w w w .ja va2s . com*/ public static UpdateExpression fromJson(JsonNode node) { if (node instanceof TextNode && "$remove".equals(node.asText())) { return new RemoveElementExpression(); } else { return UpdateExpression.fromJson(node); } }
From source file:software.uncharted.util.JSONUtil.java
public static List<String> getStringList(JsonNode obj, String accessor) { ArrayNode arrayNode = getArray(obj, accessor); List<String> stringList = Lists.newArrayList(); for (JsonNode n : arrayNode) { stringList.add(n.asText()); }/*ww w . java 2 s.c o m*/ return stringList; }
From source file:com.redhat.lightblue.query.ArrayMatchExpression.java
/** * Parses an array match expression from the given json object *//*from w w w . jav a2 s . c o m*/ public static ArrayMatchExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("elemMatch"); if (x != null) { return new ArrayMatchExpression(field, QueryExpression.fromJson(x)); } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); }
From source file:org.apache.solr.kelvin.testcases.SimpleTestCase.java
public static void readStringArrayOpt(JsonNode queryNode, List<String> ret) { if (queryNode.isArray()) { for (JsonNode q : ((ArrayNode) queryNode)) { ret.add(q.asText()); }//w w w . j a v a 2 s .com } else { ret.add(queryNode.asText()); } }
From source file:com.spotify.helios.Utils.java
private static String imageInfo(final String path) { final JsonNode node; try {/*from w w w. java 2 s .c om*/ final String json = new String(Files.readAllBytes(Paths.get(path))); node = Json.readTree(json); } catch (IOException e) { throw Throwables.propagate(e); } final JsonNode imageNode = node.get("image"); return (imageNode == null || imageNode.getNodeType() != STRING) ? null : imageNode.asText(); }
From source file:com.arpnetworking.configuration.jackson.JsonNodeDirectorySourceTest.java
private static boolean arrayNodeContains(final ArrayNode arrayNode, final String value) { final Iterator<JsonNode> iterator = arrayNode.iterator(); while (iterator.hasNext()) { final JsonNode node = iterator.next(); if (node.asText().equals(value)) { return true; }/*w w w. ja va 2 s .c om*/ } return false; }
From source file:com.pros.jsontransform.expression.FunctionAbstract.java
static String transformValue(final JsonNode valueNode, final ObjectTransformer transformer) { String result = ""; if (valueNode != null) { result = valueNode.asText(); }//ww w. j ava 2 s . c o m return result; }
From source file:com.redhat.lightblue.query.BinaryRelationalExpression.java
/** * Parses a field comparison or value comparison expression from the given * json object//from ww w . ja v a 2 s.c o m */ public static BinaryRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { JsonNode x = node.get("op"); if (x != null) { BinaryComparisonOperator op = BinaryComparisonOperator.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 FieldComparisonExpression(field, op, new Path(x.asText())); } else { x = node.get("rvalue"); if (x != null) { return new ValueComparisonExpression(field, op, Value.fromJson(x)); } } } } } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); }