|
18 | 18 | import com.fasterxml.jackson.core.JsonParser; |
19 | 19 | import com.fasterxml.jackson.databind.DeserializationContext; |
20 | 20 | import com.fasterxml.jackson.databind.JsonNode; |
21 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
22 | 21 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer; |
23 | | -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
24 | 22 | import io.serverlessworkflow.api.interfaces.WorkflowPropertySource; |
25 | 23 | import io.serverlessworkflow.api.utils.Utils; |
26 | 24 | import io.serverlessworkflow.api.workflow.Constants; |
27 | 25 | import java.io.IOException; |
28 | | -import org.json.JSONObject; |
29 | 26 | import org.slf4j.Logger; |
30 | 27 | import org.slf4j.LoggerFactory; |
31 | 28 |
|
@@ -63,21 +60,8 @@ public Constants deserialize(JsonParser jp, DeserializationContext ctxt) throws |
63 | 60 | } else { |
64 | 61 | String constantsFileDef = node.asText(); |
65 | 62 | String constantsFileSrc = Utils.getResourceFileAsString(constantsFileDef); |
66 | | - JsonNode constantsRefNode; |
67 | | - ObjectMapper jsonWriter = new ObjectMapper(); |
68 | 63 | if (constantsFileSrc != null && constantsFileSrc.trim().length() > 0) { |
69 | | - // if its a yaml def convert to json first |
70 | | - if (!constantsFileSrc.trim().startsWith("{")) { |
71 | | - // convert yaml to json to validate |
72 | | - ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); |
73 | | - Object obj = yamlReader.readValue(constantsFileSrc, Object.class); |
74 | | - |
75 | | - constantsRefNode = |
76 | | - jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString()); |
77 | | - } else { |
78 | | - constantsRefNode = jsonWriter.readTree(new JSONObject(constantsFileSrc).toString()); |
79 | | - } |
80 | | - |
| 64 | + JsonNode constantsRefNode = Utils.getNode(constantsFileSrc); |
81 | 65 | JsonNode refConstants = constantsRefNode.get("constants"); |
82 | 66 | if (refConstants != null) { |
83 | 67 | constantsDefinition = refConstants; |
|
0 commit comments