1. Domino Jackson
  2. Getting started
  3. Quick start

Quick start

Prerequisites

  • Java 11 or higher.
  • Maven 3.6.0 or higher.

Setting up domino-jackson and using it in your project is a straightforward process, simplified as Add dependency, Annotate the POJO, and finally use the generated mapper :

Steps

  1. Add the library and processors dependencies to your project
    			<dependency>
        <groupId>org.dominokit</groupId>
        <artifactId>domino-jackson</artifactId>
        <version>1.0.4</version>
    </dependency>
    <dependency>
        <groupId>org.dominokit</groupId>
        <artifactId>domino-jackson-processor</artifactId>
        <version>1.0.4</version>
        <scope>provided</scope>
    </dependency>
    		
  2. If you are using Domino-jackson with GWT then you will need to add the following inherit directive to your project .gwt.xml file
    			<inherits name="org.dominokit.jackson.Jackson"/>
    		
  3. Annotate your bean or pojo with @JSONMapper, once you compile or build a mapper will be generated :
    			import org.dominokit.jacksonapt.annotation.JSONMapper;
    
    @JSONMapper
    public class Person {
    
        private String firstName;
        private String lastName;
    
        public String getFirstName() {
            return firstName;
        }
    
        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }
    
        public String getLastName() {
            return lastName;
        }
    
        public void setLastName(String lastName) {
            this.lastName = lastName;
        }
    }
    		
  4. Finally you can use the generated mapper like the following :
    			public static void main(String[] args) {
    
            Person person = new Person();
            person.setFirstName("Ahmad");
            person.setLastName("Bawaneh");
    
            String personJsonString = Person_MapperImpl.INSTANCE
                    .write(person);
            //{"firstName":"Ahmad","lastName":"Bawaneh"}
    
            Person person2 = Person_MapperImpl.INSTANCE.read("{\"firstName\":\"Ahmad\",\"lastName\":\"Bawaneh\"}");
        }
    		

We are a group of passionate people who love what we do

Donate & Support Us