org.simantics.scl.osgi;bundle-version="1.0.4",
org.jdom2;bundle-version="2.0.6",
org.junit;bundle-version="4.12.0";resolution:=optional,
- com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.2"
+ com.fasterxml.jackson.core.jackson-core;bundle-version="2.8.2",
+ com.fasterxml.jackson.core.jackson-databind
Bundle-ClassPath: .
--- /dev/null
+import "StandardLibrary"
+import "Data/Writer"
+import "JavaBuiltin" as Java
+import "Data/Json"
+
+importJava "com.fasterxml.jackson.databind.JsonNode" where
+ data JsonNode
+
+importJava "org.simantics.scl.data.xml.JsonNodeHelper" where
+ @private
+ @JavaName toJsonString
+ jsonNodeToString :: JsonNode -> String
+ @private
+ @JavaName fromJsonString
+ stringToJsonNode :: String -> JsonNode
+
+jsonNodeToJson :: JsonNode -> Json
+jsonNodeToJson node = fromJsonString (jsonNodeToString node)
+
+jsonToJsonNode :: Json -> JsonNode
+jsonToJsonNode json = stringToJsonNode (toJsonString json)
+
+
\ No newline at end of file
--- /dev/null
+package org.simantics.scl.data.xml;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+public class JsonNodeHelper {
+
+ private static final ObjectMapper SORTED_MAPPER = new ObjectMapper();
+
+ static {
+ SORTED_MAPPER.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
+ }
+
+ public static String toJsonString(JsonNode node) throws JsonProcessingException {
+ final Object obj = SORTED_MAPPER.treeToValue(node, Object.class);
+ final String json = SORTED_MAPPER.writeValueAsString(obj);
+ return json;
+ }
+
+ public static JsonNode fromJsonString(String s) throws JsonProcessingException, IOException {
+ return SORTED_MAPPER.readTree(s);
+ }
+
+}
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="com.fasterxml.jackson.core.jackson-annotations"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="com.fasterxml.jackson.core.jackson-databind"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>