SlideShare a Scribd company logo
Mule ESB
How to use Jackson in Object to Json converter
In this tutorial we will be creating an easy object to json converter using Jackson
annotations in order to have major control on the fields datamapping.
As usual, let’s begin creating the http inbound component to trigger the flow
We want to transform this Object to Json:
package com.mulechampion;
import java.io.Serializable;
import org.codehaus.jackson.annotate.JsonProperty;
public class JsonClass implements Serializable{
/**
*
*/
private static final long serialVersionUID = -5645625751838751914L;
@JsonProperty(value="name")
private String fullName;
@JsonProperty(value="surname")
private String fullSurname;
@JsonProperty(value="profession")
private String job;
public JsonClass(String fullName, String fullSurname, String job) {
super();
this.fullName = fullName;
this.fullSurname = fullSurname;
this.job = job;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getFullSurname() {
return fullSurname;
}
public void setFullSurname(String fullSurname) {
this.fullSurname = fullSurname;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
@Override
public String toString() {
return "JsonClass [fullName=" + fullName + ", fullSurname="
+ fullSurname + ", job=" + job + "]";
}
}
The problem here is that there’s no automatic field mapping based on the fields name,
resulting in the following error, if we start the application with this flow:
org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "name"
(Class com.mulechampion.JsonClass), not marked as ignorable
To solve this, we will use Jackson annotations in this way:
@JsonProperty(value="name")
private String fullName;
@JsonProperty(value="surname")
private String fullSurname;
@JsonProperty(value="profession")
private String job;
If we start now the application we will finally obtain the following output on the console:
HTTP_Listener_Configuration.worker.01]
org.mule.api.processor.LoggerMessageProcessor:
{"name":“Usern","surname":“Users","profession":"programmer"}

More Related Content

PPTX
Mule esb How to use Jackson in Object to Json converter
PPTX
Mule esb - How to convert from Json to Object in 5 minutes
PPTX
Mule esb How to use Jackson in Json to Object converter
PPTX
Mule esb How to convert from Object to Json in 5 minutes
PPTX
Java Script Promise
PPTX
Converting with custom transformer
PPTX
Converting with custom transformer part 2
PPTX
Converting with custom transformer
 
Mule esb How to use Jackson in Object to Json converter
Mule esb - How to convert from Json to Object in 5 minutes
Mule esb How to use Jackson in Json to Object converter
Mule esb How to convert from Object to Json in 5 minutes
Java Script Promise
Converting with custom transformer
Converting with custom transformer part 2
Converting with custom transformer
 

What's hot (14)

PDF
Getting Comfortable with JS Promises
PPTX
Converting with custom transformer
PPTX
JavaScript Promises
PPTX
Mule esb json_to_object
PPTX
Promises, promises, and then observables
PDF
JavaScript promise
PPTX
Promises, Promises
PPTX
Avoiding callback hell in Node js using promises
PDF
JavaScript Promises
PDF
Boom! Promises/A+ Was Born
PDF
Utilizing Bluebird Promises
PDF
Callbacks and control flow in Node js
DOCX
Puerto serialarduino
PDF
Practical JavaScript Promises
Getting Comfortable with JS Promises
Converting with custom transformer
JavaScript Promises
Mule esb json_to_object
Promises, promises, and then observables
JavaScript promise
Promises, Promises
Avoiding callback hell in Node js using promises
JavaScript Promises
Boom! Promises/A+ Was Born
Utilizing Bluebird Promises
Callbacks and control flow in Node js
Puerto serialarduino
Practical JavaScript Promises
Ad

Viewers also liked (16)

PPTX
Challenge assumption3
PDF
Búsqueda en la base de datos Dialnet
PDF
Trc Public Sector Brochure
DOCX
Shyanne vocabulary
PDF
Cómo introducir datos en SPSS
PDF
Petición de ribas para poder presenciar la audiencia
PPTX
PPTX
Xml to xml transformation in mule
PPT
Ok 11 operasi cpu
PPTX
MAGDA ZORAIDA CELY ROJAS
PPT
Crisis del software
PPTX
Cognitive Analysis With SparkSecure
PPTX
Classification of hormones and their mechanism of action
PPTX
Desert adaptations
PPTX
Journey to the end of the earth
PPTX
Postpartum management of mare
Challenge assumption3
Búsqueda en la base de datos Dialnet
Trc Public Sector Brochure
Shyanne vocabulary
Cómo introducir datos en SPSS
Petición de ribas para poder presenciar la audiencia
Xml to xml transformation in mule
Ok 11 operasi cpu
MAGDA ZORAIDA CELY ROJAS
Crisis del software
Cognitive Analysis With SparkSecure
Classification of hormones and their mechanism of action
Desert adaptations
Journey to the end of the earth
Postpartum management of mare
Ad

More from Davide Rapacciuolo (20)

PPTX
Muleesbobjecttojson
PPTX
Mule esb db_2
PPTX
Mule esb db_1
PPTX
Consuming raml
PPTX
Transf from csv to xml
PPTX
Esb choice flow
PPTX
Transformation xmltoobjectesb
PPTX
Transformation jsontoxmlesb
PPTX
Transformation jsontojsonesb
PPTX
Transformation csvtoxml
PPTX
Rest fullservices
PPTX
Xml to xml transformation in mule
PPTX
Mule esb object_to_json
PPTX
Mule esb expression_filter
PPTX
Mule esb collection_splitter
PPTX
Mule esb soap_service
PPTX
Transformation xmltoobjectesb
PPTX
Transformation jsontoxmlesb
PPTX
Mule esb csv_to_json
PPTX
Json to json transformation in mule
Muleesbobjecttojson
Mule esb db_2
Mule esb db_1
Consuming raml
Transf from csv to xml
Esb choice flow
Transformation xmltoobjectesb
Transformation jsontoxmlesb
Transformation jsontojsonesb
Transformation csvtoxml
Rest fullservices
Xml to xml transformation in mule
Mule esb object_to_json
Mule esb expression_filter
Mule esb collection_splitter
Mule esb soap_service
Transformation xmltoobjectesb
Transformation jsontoxmlesb
Mule esb csv_to_json
Json to json transformation in mule

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
KodekX | Application Modernization Development
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Understanding_Digital_Forensics_Presentation.pptx
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MYSQL Presentation for SQL database connectivity
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Reach Out and Touch Someone: Haptics and Empathic Computing

Mule esb object_to_jackson_json

  • 1. Mule ESB How to use Jackson in Object to Json converter
  • 2. In this tutorial we will be creating an easy object to json converter using Jackson annotations in order to have major control on the fields datamapping. As usual, let’s begin creating the http inbound component to trigger the flow
  • 3. We want to transform this Object to Json: package com.mulechampion; import java.io.Serializable; import org.codehaus.jackson.annotate.JsonProperty; public class JsonClass implements Serializable{ /** * */ private static final long serialVersionUID = -5645625751838751914L; @JsonProperty(value="name") private String fullName; @JsonProperty(value="surname") private String fullSurname; @JsonProperty(value="profession") private String job; public JsonClass(String fullName, String fullSurname, String job) { super(); this.fullName = fullName; this.fullSurname = fullSurname; this.job = job; } public String getFullName() { return fullName; } public void setFullName(String fullName) { this.fullName = fullName; } public String getFullSurname() { return fullSurname; } public void setFullSurname(String fullSurname) { this.fullSurname = fullSurname; } public String getJob() { return job; } public void setJob(String job) { this.job = job; } @Override public String toString() { return "JsonClass [fullName=" + fullName + ", fullSurname=" + fullSurname + ", job=" + job + "]"; } }
  • 4. The problem here is that there’s no automatic field mapping based on the fields name, resulting in the following error, if we start the application with this flow: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "name" (Class com.mulechampion.JsonClass), not marked as ignorable To solve this, we will use Jackson annotations in this way: @JsonProperty(value="name") private String fullName; @JsonProperty(value="surname") private String fullSurname; @JsonProperty(value="profession") private String job;
  • 5. If we start now the application we will finally obtain the following output on the console: HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: {"name":“Usern","surname":“Users","profession":"programmer"}