List of usage examples for com.fasterxml.jackson.databind JsonNode get
public JsonNode get(String paramString)
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());/*from ww w .j a v a2s. com*/ } return result; }
From source file:com.pros.jsontransform.plugin.constraint.ConstraintTaxPercentRange.java
public static void validate(final JsonNode constraintNode, final JsonNode resultNode, final ObjectTransformer transformer) throws ObjectTransformerException { // expect price and tax nodes in sourceNode that is being processed JsonNode sourceNode = transformer.getSourceNode(); double price = sourceNode.get("price").asDouble(); double tax = sourceNode.get("tax").asDouble(); double percentTax = tax * 100 / price; boolean ltRangeValid = true; boolean gtRangeValid = true; JsonNode rangeNode = constraintNode.get(CONSTRAINT_NAME); if (rangeNode.isObject()) { JsonNode ltNode = rangeNode.path("$less-than"); if (!ltNode.isMissingNode()) { ltRangeValid = percentTax < ltNode.asDouble(); }/* w ww . j a va2 s . c om*/ JsonNode gtNode = rangeNode.path("$greater-than"); if (!gtNode.isMissingNode()) { gtRangeValid = percentTax > gtNode.asDouble(); } } if (ltRangeValid == false || gtRangeValid == false) { throw new ObjectTransformerException("Constraint violation [" + CONSTRAINT_NAME + "]" + " on transform node " + transformer.getTransformNodeFieldName() + " on result node " + resultNode.toString() + " " + percentTax); } }
From source file:net.sf.taverna.t2.activities.xpath.XPathUtils.java
/** * Tests validity of the configuration held. * /*from w w w . j a v a2s .c o m*/ * @return <code>true</code> if the configuration in the bean is valid; * <code>false</code> otherwise. */ public static boolean isValid(JsonNode json) { return (json.has("xpathExpression") && validateXPath(json.get("xpathExpression").textValue()) == XPATH_VALID && json.has("xpathNamespaceMap")); }
From source file:com.github.robozonky.app.runtime.LivenessCheck.java
static String read(final String json) throws IOException { final JsonNode actualObj = MAPPER.get().readTree(json); return actualObj.get("buildVersion").asText(); }
From source file:com.ibm.watson.catalyst.jumpqa.trec.TrecReader.java
private static List<String> getParagraphs(final JsonNode trecJson) { final JsonNode paragraphs = trecJson.get("paragraphs"); final List<String> result = new ArrayList<String>(); paragraphs.forEach((par) -> result.add(par.asText())); return result; }
From source file:volker.streaming.music.lastfm.LastFmTrackFactory.java
private static String getTextItem(JsonNode track, String key) { return track.get(key).get(TEXT_KEY).asText(); }
From source file:org.apache.solr.kelvin.SingletonTestRegistry.java
public static ITestCase instantiate(JsonNode conf) throws Exception { String type = "default"; if (conf.has("type")) type = conf.get("type").asText(); return (ITestCase) registry.instantiate(type); }
From source file:org.glowroot.benchmark.ResultFormatter.java
private static double getAllocatedBytes(JsonNode result) { ObjectNode secondaryMetrics = (ObjectNode) result.get("secondaryMetrics"); if (secondaryMetrics == null) { return -1; }//from www . j av a 2s . co m ObjectNode gcAllocRateNorm = (ObjectNode) secondaryMetrics.get("\u00b7gc.alloc.rate.norm"); if (gcAllocRateNorm == null) { return -1; } return gcAllocRateNorm.get("score").asDouble(); }
From source file:com.attribyte.essem.StoredGraphParser.java
/** * Parses a stored graph response.//from w w w. j a v a 2s . co m * @param esObject The ES response object. * @return The list of graphs. */ public static List<StoredGraph> parseGraphs(ObjectNode esObject) throws IOException { List<StoredGraph> graphList = Lists.newArrayListWithExpectedSize(16); JsonNode hitsObj = esObject.get("hits"); if (hitsObj != null) { JsonNode hitsArr = hitsObj.get("hits"); if (hitsArr != null) { for (JsonNode hitObj : hitsArr) { JsonNode fieldsObj = hitObj.get("fields"); if (fieldsObj != null) { graphList.add(StoredGraph.fromJSON(fieldsObj)); } } } } return graphList; }
From source file:com.htmlhifive.pitalium.it.util.ItUtils.java
/** * ?JSON???????// w w w. j av a2 s. c o m * * @param results * @param capabilities */ public static JsonNode getCurrentScreenshotResultJson(String methodName, JsonNode results, PtlCapabilities capabilities) { for (JsonNode jn : results.get("screenshotResults")) { JsonNode capabilitiesNode = jn.get("capabilities"); String platform = capabilities.getPlatform() != null ? capabilities.getPlatform().toString() : ""; if (methodName.equals(jn.get("testMethod").asText()) && capabilities.getBrowserName().equals(capabilitiesNode.get("browserName").asText())) { if (platform.equals("") || platform.endsWith(capabilitiesNode.get("platform").asText())) { JsonNode version = capabilitiesNode.get("version"); if (version == null) { if (StringUtils.isEmpty(capabilities.getVersion())) { return jn; } } else { if (version.asText().equals(capabilities.getVersion())) { return jn; } } } } } return null; }