Upload
veena-naresh
View
134
Download
3
Embed Size (px)
Citation preview
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"
}
JSON Primer
• Supports the combining:
1. Collections ∙ employees[0]∙ employees[1]
2. Maps• Supporting more complex data
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
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
JSON Example
1. Java object representation of an order2. Can be read by business logic3. Fields match that of JSON request.
JSON Example
JSON Example
1. JSON is transformed to Order- returnClass specified2. Order transformed back to JSON
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