From 021027259ddd5599c28f6c8606eb6d008459d58b Mon Sep 17 00:00:00 2001 From: wangqi <1942460489@qq.com> Date: Fri, 26 Apr 2024 22:15:12 +0800 Subject: [PATCH] feature: prepare 1.0.13-SNAPSHOT --- milky-common/pom.xml | 4 ++++ .../cn/sliew/milky/common/util/JacksonUtil.java | 16 ++++++++++++---- pom.xml | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/milky-common/pom.xml b/milky-common/pom.xml index 9c9128a..9809320 100644 --- a/milky-common/pom.xml +++ b/milky-common/pom.xml @@ -39,6 +39,10 @@ com.fasterxml.jackson.datatype jackson-datatype-jdk8 + + com.fasterxml.jackson.dataformat + jackson-dataformat-properties + com.google.guava diff --git a/milky-common/src/main/java/cn/sliew/milky/common/util/JacksonUtil.java b/milky-common/src/main/java/cn/sliew/milky/common/util/JacksonUtil.java index d960c2a..9a002cf 100644 --- a/milky-common/src/main/java/cn/sliew/milky/common/util/JacksonUtil.java +++ b/milky-common/src/main/java/cn/sliew/milky/common/util/JacksonUtil.java @@ -13,14 +13,12 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.type.CollectionType; +import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; /** * jackson utility class. @@ -30,6 +28,7 @@ public class JacksonUtil { private static final Logger log = LoggerFactory.getLogger(JacksonUtil.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + private static final JavaPropsMapper PROPS_MAPPER = new JavaPropsMapper(); static { OBJECT_MAPPER.registerModule(new JavaTimeModule()) @@ -145,6 +144,15 @@ public static Map toMap(JsonNode jsonNode) { }); } + public static Properties toProps(String json) { + try { + return PROPS_MAPPER.writeValueAsProperties(json); + } catch (IOException e) { + Rethrower.throwAs(e); + return null; + } + } + public static boolean checkJsonValid(String json) { if (StringUtils.isBlank(json)) { return false; diff --git a/pom.xml b/pom.xml index cf5e729..1658126 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,7 @@ com.fasterxml.jackson jackson-bom - 2.13.1 + 2.13.5 pom import