9
Mule JSON Transformers

Mule json transformers

Embed Size (px)

Citation preview

Page 1: Mule json transformers

Mule JSON Transformers

Page 2: Mule json transformers

JSON Primer

• JavaScript Object Notation- a lightweight datainterchange format

[ element1, element2, element3..... ]

• Human-Readable Syntax• Supports

1. Collections2. Maps {

"name1":"value","name2":"value"

}

Page 3: Mule json transformers

JSON Primer

• Supports the combining:

1. Collections ∙ employees[0]∙ employees[1]

2. Maps• Supporting more complex data

Page 4: Mule json transformers

JSON Transformer

• Object to JSON- receives an object and returns JSON syntax- uses reflection (no configuration necessary)

• JSON to Object- populates a Java object from a JSON structure- requires at least the name of the class

Page 5: Mule json transformers

JSON Example

1. JSON input enters with an order request2. Order business logic exists in a java component3. After processing, a response comes back with the tax included

Page 6: Mule json transformers

JSON Example

1. Java object representation of an order2. Can be read by business logic3. Fields match that of JSON request.

Page 7: Mule json transformers

JSON Example

Page 8: Mule json transformers

JSON Example

1. JSON is transformed to Order- returnClass specified2. Order transformed back to JSON

Page 9: Mule json transformers

JSON Example

• XML to JAXB

- Uses the JAXB binding framework to serialize to xml or in reverse to an object- Counterpart exists at JAXB to XML

• XML to Object

- Utilizes Xstream to convert data to and from XML and Java Objects- Counterpart exists as Object to XML