Class JsonConverter


  • @Component
    public class JsonConverter
    extends Object
    Extends Jackson's ObjectMapper with custom configuration
    • Field Detail

      • BLACKLISTED_ERROR_PROPERTIES

        public static final List<String> BLACKLISTED_ERROR_PROPERTIES
    • Constructor Detail

      • JsonConverter

        public JsonConverter()
    • Method Detail

      • mask

        public static Object mask​(Object owner,
                                  String property,
                                  Object value)
        If the given value should be masked, returns '***', otherwise, returns the value as is NOTE: In case there is a corresponding entity log handler implementation please ensure the property value is masked too. See EntityLogHandler (impl project)
      • beanIsSimpleLogNode

        public boolean beanIsSimpleLogNode​(Bean bean)
      • errorToLogNode

        public com.fasterxml.jackson.databind.node.ObjectNode errorToLogNode​(Throwable error)
                                                                      throws com.fasterxml.jackson.core.JsonProcessingException
        Wraps an exception as a suitable object to be converted to JSON in a log
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • getObjectMapper

        public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      • intialize

        @PostConstruct
        public void intialize()
      • nodeValue

        public Object nodeValue​(com.fasterxml.jackson.databind.JsonNode node)
      • readTree

        public com.fasterxml.jackson.databind.JsonNode readTree​(byte[] content)
                                                         throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • readTree

        public com.fasterxml.jackson.databind.JsonNode readTree​(File file)
                                                         throws IOException,
                                                                com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonProcessingException
      • readTree

        public com.fasterxml.jackson.databind.JsonNode readTree​(InputStream in)
                                                         throws IOException,
                                                                com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonProcessingException
      • readTree

        public com.fasterxml.jackson.databind.JsonNode readTree​(Reader r)
                                                         throws IOException,
                                                                com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonProcessingException
      • readTree

        public com.fasterxml.jackson.databind.JsonNode readTree​(String content)
                                                         throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • readValue

        public <T> T readValue​(byte[] src,
                               Class<T> valueType)
                        throws com.fasterxml.jackson.core.JsonParseException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException
      • readValue

        public <T> T readValue​(File src,
                               Class<T> valueType)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonParseException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException
      • readValue

        public <T> T readValue​(InputStream src,
                               Class<T> valueType)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonParseException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException
      • readValue

        public <T> T readValue​(Reader src,
                               Class<T> valueType)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonParseException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException
      • readValue

        public <T> T readValue​(String content,
                               Class<T> valueType)
                        throws com.fasterxml.jackson.core.JsonParseException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException
      • readValue

        public <T> T readValue​(URL src,
                               Class<T> valueType)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonParseException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonParseException
        com.fasterxml.jackson.databind.JsonMappingException
      • toLogNode

        public com.fasterxml.jackson.databind.JsonNode toLogNode​(Object value,
                                                                 boolean input)
      • useLogJsonAsProperty

        public boolean useLogJsonAsProperty​(com.fasterxml.jackson.databind.JsonNode json,
                                            Class<?> type)
      • writeValue

        public void writeValue​(File resultFile,
                               Object value)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonGenerationException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonGenerationException
        com.fasterxml.jackson.databind.JsonMappingException
      • writeValue

        public void writeValue​(OutputStream out,
                               Object value)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonGenerationException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonGenerationException
        com.fasterxml.jackson.databind.JsonMappingException
      • writeValue

        public void writeValue​(Writer w,
                               Object value)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonGenerationException,
                               com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonGenerationException
        com.fasterxml.jackson.databind.JsonMappingException
      • writeValueAsBytes

        public byte[] writeValueAsBytes​(Object value)
                                 throws IOException,
                                        com.fasterxml.jackson.core.JsonGenerationException,
                                        com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonGenerationException
        com.fasterxml.jackson.databind.JsonMappingException
      • writeValueAsString

        public String writeValueAsString​(Object value)
                                  throws com.fasterxml.jackson.core.JsonGenerationException,
                                         com.fasterxml.jackson.databind.JsonMappingException
        Throws:
        com.fasterxml.jackson.core.JsonGenerationException
        com.fasterxml.jackson.databind.JsonMappingException