From c6967e2cfdeba8d84e5f9f91a166d3edb29cb91d Mon Sep 17 00:00:00 2001 From: ABenta Date: Tue, 19 Apr 2022 15:09:02 +0300 Subject: [PATCH 1/5] updates json path to 2.7.0 --- cs-json/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cs-json/pom.xml b/cs-json/pom.xml index 194b03b41c..811770121a 100644 --- a/cs-json/pom.xml +++ b/cs-json/pom.xml @@ -105,7 +105,7 @@ com.jayway.jsonpath json-path - 2.2.0 + 2.7.0 com.fasterxml.jackson.core From 686edf421ea713b3e54a326e5f9f024df95850b7 Mon Sep 17 00:00:00 2001 From: ABenta Date: Tue, 19 Apr 2022 17:26:09 +0300 Subject: [PATCH 2/5] updates json path to 2.7.0 changed logic for Json Context since the new library made constructors private --- .../java/io/cloudslang/content/json/utils/JsonUtils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cs-json/src/main/java/io/cloudslang/content/json/utils/JsonUtils.java b/cs-json/src/main/java/io/cloudslang/content/json/utils/JsonUtils.java index 281cc8ca63..2d1cb2514a 100644 --- a/cs-json/src/main/java/io/cloudslang/content/json/utils/JsonUtils.java +++ b/cs-json/src/main/java/io/cloudslang/content/json/utils/JsonUtils.java @@ -128,8 +128,11 @@ public static JsonContext getValidJsonContext(final String jsonObject) { final AbstractJsonProvider provider = new JacksonJsonNodeJsonProvider(objectMapper); final Configuration configuration = Configuration.defaultConfiguration() .jsonProvider(provider); - final JsonContext jsonContext = new JsonContext(configuration); - jsonContext.parse(jsonObject); + + + final JsonContext jsonContext = (JsonContext) JsonPath + .using(configuration) + .parse(jsonObject); return jsonContext; } catch (IllegalArgumentException iae) { throw hammerIllegalArgumentExceptionWithMessage(INVALID_JSONOBJECT, iae); From fe2897b2c6bc0859376db576841c0d062d24fbd0 Mon Sep 17 00:00:00 2001 From: AlexandruPresecan Date: Thu, 21 Apr 2022 16:07:11 +0300 Subject: [PATCH 3/5] oracle cloud query --- .../content/json/actions/JsonPathQuery.java | 6 +++--- .../cloudslang/content/json/services/JsonService.java | 11 +++++------ .../content/json/services/JsonServiceTest.java | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cs-json/src/main/java/io/cloudslang/content/json/actions/JsonPathQuery.java b/cs-json/src/main/java/io/cloudslang/content/json/actions/JsonPathQuery.java index b402940433..6e7e16f8a1 100644 --- a/cs-json/src/main/java/io/cloudslang/content/json/actions/JsonPathQuery.java +++ b/cs-json/src/main/java/io/cloudslang/content/json/actions/JsonPathQuery.java @@ -16,7 +16,6 @@ package io.cloudslang.content.json.actions; -import com.fasterxml.jackson.databind.JsonNode; import com.hp.oo.sdk.content.annotations.Action; import com.hp.oo.sdk.content.annotations.Output; import com.hp.oo.sdk.content.annotations.Param; @@ -28,6 +27,7 @@ import io.cloudslang.content.constants.ReturnCodes; import io.cloudslang.content.json.services.JsonService; import io.cloudslang.content.json.utils.Constants; +import io.cloudslang.content.json.utils.StringUtils; import io.cloudslang.content.utils.OutputUtilities; import java.util.Map; @@ -61,8 +61,8 @@ public Map execute( @Param(value = Constants.InputNames.JSON_OBJECT, required = true) String jsonObject, @Param(value = Constants.InputNames.JSON_PATH, required = true) String jsonPath) { try { - final JsonNode jsonNode = JsonService.evaluateJsonPathQuery(jsonObject, jsonPath); - if (!jsonNode.isNull()) { + final Object jsonNode = JsonService.evaluateJsonPathQuery(jsonObject, jsonPath); + if (!StringUtils.isEmpty(jsonNode)) { return OutputUtilities.getSuccessResultsMap(jsonNode.toString()); } return OutputUtilities.getSuccessResultsMap(NULL_STRING); diff --git a/cs-json/src/main/java/io/cloudslang/content/json/services/JsonService.java b/cs-json/src/main/java/io/cloudslang/content/json/services/JsonService.java index 15e4efde57..30ad30c750 100644 --- a/cs-json/src/main/java/io/cloudslang/content/json/services/JsonService.java +++ b/cs-json/src/main/java/io/cloudslang/content/json/services/JsonService.java @@ -17,10 +17,6 @@ package io.cloudslang.content.json.services; -import com.fasterxml.jackson.databind.JsonNode; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.InvalidJsonException; @@ -41,7 +37,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; import static io.cloudslang.content.json.utils.Constants.InputNames.EMPTY_STRING; @@ -51,7 +50,7 @@ public class JsonService { @NotNull - public static JsonNode evaluateJsonPathQuery(@Nullable final String jsonObject, @Nullable final String jsonPath) { + public static Object 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); diff --git a/cs-json/src/test/java/io/cloudslang/content/json/services/JsonServiceTest.java b/cs-json/src/test/java/io/cloudslang/content/json/services/JsonServiceTest.java index 5334ff943c..52f5a01ae1 100644 --- a/cs-json/src/test/java/io/cloudslang/content/json/services/JsonServiceTest.java +++ b/cs-json/src/test/java/io/cloudslang/content/json/services/JsonServiceTest.java @@ -202,13 +202,13 @@ public void givenJsonWithEmptyElementsThenReturnEmptyJsonString() throws RemoveE @Test public void evaluateSimpleJsonPathQuery() throws Exception { - JsonNode jsonNode = JsonService.evaluateJsonPathQuery("{'key1': 'value1','key2': 'value2', 'key3': { 'key31': 'value31'}}", "$.key3.key31"); + Object jsonNode = JsonService.evaluateJsonPathQuery("{'key1': 'value1','key2': 'value2', 'key3': { 'key31': 'value31'}}", "$.key3.key31"); assertEquals(jsonNode.toString(), "\"value31\""); } @Test public void evaluateComplexJsonPathQuery() throws Exception { - JsonNode jsonNode = JsonService.evaluateJsonPathQuery("{ \"store\": {\n" + + Object jsonNode = JsonService.evaluateJsonPathQuery("{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + From feed7ae006442f4e7e5573af655484212daf18b8 Mon Sep 17 00:00:00 2001 From: cloudslang-admin Date: Wed, 27 Apr 2022 11:48:05 +0300 Subject: [PATCH 4/5] [maven-release-plugin] prepare release cs-json-0.0.19 --- cs-json/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cs-json/pom.xml b/cs-json/pom.xml index 811770121a..6678f91a7f 100644 --- a/cs-json/pom.xml +++ b/cs-json/pom.xml @@ -21,7 +21,7 @@ io.cloudslang.content cs-json - 0.0.19-SNAPSHOT + 0.0.19 jar ${project.groupId}:${project.artifactId} @@ -39,7 +39,7 @@ scm:git:https://CloudSlang/cs-actions.git scm:git:git@github.com:CloudSlang/cs-actions.git https://github.com/CloudSlang/cs-actions.git - master + cs-json-0.0.19 From af27e307b107179cfee9a7e5fe81bfb2850e689f Mon Sep 17 00:00:00 2001 From: AlexandruPresecan Date: Wed, 27 Apr 2022 11:52:38 +0300 Subject: [PATCH 5/5] updated cs-json version --- cs-json/pom.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cs-json/pom.xml b/cs-json/pom.xml index 811770121a..baff780ccd 100644 --- a/cs-json/pom.xml +++ b/cs-json/pom.xml @@ -21,7 +21,7 @@ io.cloudslang.content cs-json - 0.0.19-SNAPSHOT + 0.0.20-SNAPSHOT jar ${project.groupId}:${project.artifactId} @@ -105,14 +105,23 @@ com.jayway.jsonpath json-path - 2.7.0 + 2.2.0 com.fasterxml.jackson.core jackson-databind + + net.minidev + json-smart + + + net.minidev + json-smart + 2.4.7 + com.google.code.gson