public JsonPathResult(JsonNode prefix, JsonNode suffix) { this(getPrefixParts(prefix), suffix); }
ObjectNode answerValues) { List<JsonNode> extractedList = new LinkedList<>(); if (!jpResult.isNullOrEmptySuffix()) { switch (extraction.getMethod()) { case FUNCOFSUFFIX: JsonPathUtils.computePathFunction(extraction.getFilter(), jpResult.getSuffix()); if (result != null) { if (result instanceof Integer) { JsonPathUtils.getJsonPathResults(extraction.getFilter(), jpResult.getSuffix()); for (JsonPathResult result : filterResults) { JsonNode value = (extraction.getMethod() == Method.PREFIXOFSUFFIX) ? new TextNode(result.getPrefixPart(extraction.getIndex())) : result.getSuffix(); confirmValueType(value, extraction.getSchema().getBaseType()); extractedList.add(value); String.format( "Got no results after filtering suffix values of the answer.%nFilter: %s%nJson: %s", extraction.getFilter(), jpResult.getSuffix()));
@Test public void getJsonPathResults() { String content = "{ 'a' : 'X', 'b' : 'Z' }"; String query = "$.a"; List<JsonPathResult> results = JsonPathUtils.getJsonPathResults(query, content); assertThat(results.size(), equalTo(1)); assertThat(results.get(0).getSuffix(), equalTo(new TextNode("X"))); } }
private static void extractValuesFromPrefix( String varName, JsonPathToTableExtraction extraction, JsonPathResult jpResult, ObjectNode answerValues) { if (extraction.getSchema().getType() == Type.LIST || extraction.getSchema().getType() == Type.SET) { throw new BatfishException("Prefix-based hints are incompatible with list or set types"); } answerValues.set(varName, new TextNode(jpResult.getPrefixPart(extraction.getIndex()))); }
JsonNode prefix = p.next(); JsonNode suffix = s.next(); results.add(new JsonPathResult(prefix, suffix));