JsonPostDeserialize Annotation

Annotation to denote to denote methods to run post deserialize

License

License

APLv2.0
Categories

Categories

Jackson Data JSON
GroupId

GroupId

org.goots.jackson
ArtifactId

ArtifactId

deserializer
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

JsonPostDeserialize Annotation
Annotation to denote to denote methods to run post deserialize
Project URL

Project URL

http://github.com/rnc/jackson-annotation
Source Code Management

Source Code Management

http://github.com/rnc/jackson-annotation

Download deserializer

How to add to project

<!-- https://jarcasting.com/artifacts/org.goots.jackson/deserializer/ -->
<dependency>
    <groupId>org.goots.jackson</groupId>
    <artifactId>deserializer</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.goots.jackson/deserializer/
implementation 'org.goots.jackson:deserializer:0.1'
// https://jarcasting.com/artifacts/org.goots.jackson/deserializer/
implementation ("org.goots.jackson:deserializer:0.1")
'org.goots.jackson:deserializer:jar:0.1'
<dependency org="org.goots.jackson" name="deserializer" rev="0.1">
  <artifact name="deserializer" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.goots.jackson', module='deserializer', version='0.1')
)
libraryDependencies += "org.goots.jackson" % "deserializer" % "0.1"
[org.goots.jackson/deserializer "0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.10.0.pr1
com.fasterxml.jackson.core : jackson-core jar 2.10.0.pr1
org.slf4j : slf4j-api jar 1.7.25

test (5)

Group / Artifact Type Version
org.codehaus.groovy : groovy jar 2.5.9
org.codehaus.groovy : groovy-json jar 2.5.9
ch.qos.logback : logback-classic jar 1.2.3
junit : junit jar 4.12
com.github.stefanbirkner : system-rules jar 1.18.0

Project Modules

There are no modules declared in this project.

Build Status (Travis CI)

Jackson Post Deserialization Annotation Hook

Overview

This code provides a simple annotation that may be placed upon a method (even a private method) which will be run upon completion of the deserialization.

This has been inspired by several stackoverflow posts:

and by the following Jackson issues

Usage

In order to use this annotation the ObjectMapper instance must be correctly configured. For example:

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule( org.goots.jackson.deserializer.JacksonPostHookDeserializer.getSimpleModule() );

Then, place the annotation upon a method to run after deserialization e.g.

    @JsonPostDeserialize
    public void postDeserialize()
    {
        myObjects.forEach( { obj -> obj.postInit()})
    }

By default the annotation will not call private methods. To force access set the parameter as follows:

    @JsonPostDeserialize(forceAccess=true)
    private void postDeserialize()
    {
        myObjects.forEach( { obj -> obj.postInit()})
    }

Versions

Version
0.1