Class JsonUtil


  • public class JsonUtil
    extends Object
    • Method Detail

      • nullSafeSet

        public static void nullSafeSet​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                       com.fasterxml.jackson.databind.node.ObjectNode jsonNode,
                                       String fieldName,
                                       Object value)
      • nullSafeSetIfNotSet

        public static void nullSafeSetIfNotSet​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                               com.fasterxml.jackson.databind.node.ObjectNode jsonNode,
                                               String fieldName,
                                               Object value)
      • nullSafeGetDate

        public static String nullSafeGetDate​(Date date)
      • convertToArrayNode

        public static com.fasterxml.jackson.databind.node.ArrayNode convertToArrayNode​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                                                                       Set<String> ids)
      • asNode

        public static com.fasterxml.jackson.databind.JsonNode asNode​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                                                     Object value)
      • convertToArrayNode

        public static com.fasterxml.jackson.databind.node.ArrayNode convertToArrayNode​(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                                                                       Collection<Object> valueList)
      • getIso8601String

        public static String getIso8601String​(Date input)
      • getRawValue

        public static Object getRawValue​(com.fasterxml.jackson.databind.JsonNode jsonNode)
      • getString

        public static String getString​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                       String field)
      • getString

        public static String getString​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                       String field,
                                       String defaultValue)
      • getInteger

        public static Integer getInteger​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                         String field)
      • getInteger

        public static int getInteger​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                     String field,
                                     int defaultValue)
      • getLong

        public static Long getLong​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                   String field)
      • getLong

        public static Long getLong​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                   String field,
                                   long defaultValue)
      • getDate

        public static Date getDate​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                   String field)
      • getInstant

        public static Instant getInstant​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                         String field)
      • getBoolean

        public static Boolean getBoolean​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                         String field)
      • getBoolean

        public static boolean getBoolean​(com.fasterxml.jackson.databind.JsonNode jsonNode,
                                         String field,
                                         boolean defaultValue)
      • getListFromArrayNode

        public static <T> List<T> getListFromArrayNode​(com.fasterxml.jackson.databind.JsonNode node,
                                                       String field,
                                                       Function<com.fasterxml.jackson.databind.JsonNode,​T> extractor)
      • getListFromArrayNode

        public static <T> List<T> getListFromArrayNode​(com.fasterxml.jackson.databind.node.ArrayNode target,
                                                       Function<com.fasterxml.jackson.databind.JsonNode,​T> extractor)
      • getSetFromArrayNode

        public static <T> Set<T> getSetFromArrayNode​(com.fasterxml.jackson.databind.JsonNode node,
                                                     String field,
                                                     Function<com.fasterxml.jackson.databind.JsonNode,​T> extractor)