Skip to content

Commit

Permalink
feature: prepare 1.0.13-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
kalencaya committed Apr 26, 2024
1 parent df43daf commit 0210272
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions milky-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-properties</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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())
Expand Down Expand Up @@ -145,6 +144,15 @@ public static Map<String, Object> 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;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.13.1</version>
<version>2.13.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down

0 comments on commit 0210272

Please sign in to comment.