@Test public void evaluateComplexJsonPathQuery() throws Exception { JsonNode jsonNode = JsonService.evaluateJsonPathQuery("{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95\n" + " }\n" + " }\n" + "}", "$..book[?(@.price<10)]"); assertEquals(jsonNode.toString(), "[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}]"); }
@NotNull public static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath) { final JsonContext jsonContext = JsonUtils.getValidJsonContext(jsonObject); final JsonPath path = JsonUtils.getValidJsonPath(jsonPath); return jsonContext.read(path); }
JsonService { @NotNull public static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath) { final JsonContext jsonContext = JsonUtils.getValidJsonContext(jsonObject); final JsonPath path = JsonUtils.getValidJsonPath(jsonPath); return jsonContext.read(path); } }
JsonService { @NotNull public static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath) { final JsonContext jsonContext = JsonUtils.getValidJsonContext(jsonObject); final JsonPath path = JsonUtils.getValidJsonPath(jsonPath); return jsonContext.read(path); }  }
JsonService { @NotNull public static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath) { final JsonContext jsonContext = JsonUtils.getValidJsonContext(jsonObject); final JsonPath path = JsonUtils.getValidJsonPath(jsonPath); return jsonContext.read(path); }  @NotNull static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath); String removeEmptyElementsJson(String json); }
JsonService { @NotNull public static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath) { final JsonContext jsonContext = JsonUtils.getValidJsonContext(jsonObject); final JsonPath path = JsonUtils.getValidJsonPath(jsonPath); return jsonContext.read(path); }  @NotNull static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath); String removeEmptyElementsJson(String json);  }