Class JacksonJsonToObjectMapper<T>

  • Type Parameters:
    T - the target type to be produced by this Mapper (the target class may contain Jackson annotations for due mapping -- e.g.: @JsonProperty, @JsonIgnore)
    All Implemented Interfaces:
    Mapper<T>
    Direct Known Subclasses:
    JacksonJsonNodeMapper

    public class JacksonJsonToObjectMapper<T>
    extends Object
    implements Mapper<T>
    A specialized Mapper that loads the contents of a valid JSON Source (e.g.: file, URL, string) into POJO (Plain Old Java Object), using Jackson's JsonMapper.

    Additional details may be found at Jackson's official documentation.

    Since version 2.4.0, this class supports lookup and registration of Jackson modules by default. However, since modules lookup is considered a potentially expensive operation, it can be disabled by setting the disableModules flag in the constructor:

    new JacksonJsonToObjectMapper(Class<?>, boolean)

    Note: To avoid a performance overhead, Jackson modules lookup happens automatically at the first instantiation of a JacksonJsonToObjectMapper with enable support for modules.

    Since:
    0.3.0
    Author:
    oswaldo.bapvic.jr (Oswaldo Junior)
    • Constructor Detail

      • JacksonJsonToObjectMapper

        public JacksonJsonToObjectMapper​(Class<T> targetType)
        Builds a new JacksonJsonToObjectMapper instance with the specified target type and support for Jackson modules enabled by default.
        Parameters:
        targetType - the target type to be produced by this Mapper
      • JacksonJsonToObjectMapper

        public JacksonJsonToObjectMapper​(Class<T> targetType,
                                         boolean disableModules)
        Builds a new JacksonJsonToObjectMapper instance with the specified target type.
        Parameters:
        targetType - the target type to be produced by this Mapper
        disableModules - disable Jackson modules; useful for an optimized processing if Jackson add-ons are NOT required
        Since:
        2.4.0
    • Method Detail

      • reloadModulesCache

        public static void reloadModulesCache()
        Reload Jackson modules for use by new or existing JacksonJsonToObjectMapper instances with Jackson modules enabled.

        Note: According to Jackson documentation, calls to ObjectMapper.findModules() are considered potentially expensive, so the lookup happens automatically at the first instantiation of JacksonJsonToObjectMapper with enabled support for modules.

        Since:
        2.4.0
      • resetModulesCache

        public static void resetModulesCache()
        Reset Jackson modules for reload in the next use of JacksonJsonToObjectMapper instances with Jackson modules enabled.
        Since:
        2.4.0