BookmarkSubscribeRSS Feed

Sample Route for Data Type Conversion

Started ‎07-27-2021 by
Modified ‎07-27-2021 by
Views 3,657



SAS Business Orchestration Services is an orchestration framework that allows you to integrate multiple systems.  It enables you to implement enterprise integration patterns that make it easier to send, transform, and enrich your data as our data flows from one system to another. SAS Business Orchestration Services uses Apache Camel as its execution engine. Data are sent from one system to another in Camel is via routes. Routes are a series of steps which are performed by Camel to consume and process a message. When integrating multiple systems, data structures used by the source and target systems may not match. SAS Business Orchestration Services provides the ability to convert data types without requiring extensive and time-consuming development.

To showcase this functionality, we provide a sample route, in which a JSON file containing information about an airplane is unmarshaled to a Java Map and then converted to a Java Bean. Below is the JSON file containing the data that will be transformed in this sample.

    "planeType" : "Boeing 737",
    "tailNumber" : "N147CA",
    "maxCapacity" : 215,
    "landed" : true



JSON to Bean Route


The route below converts the JSON file to a Java bean via the following steps:

  1. Fetch the File from the local file path.
  2. Unmarshal the JSON file into a Java Map.
  3. Send Map to the data type converter to be converted to a Bean.
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="">
        <from uri="file:input-files"/>
        <log message="${body}"/>
        <log message="${body}"/>
        <to uri="sas-convert-body-to:?mapperId=JsonToBeanMapper"/>
        <log message="${body}"/>

In Line 4, the file is fetched from the “input-files” directory. Lines 6-8, unmarshals the JSON file. The default object type for unmarshaling a JSON file is a map. In line 10, the sas-convert-body-to endpoint is used to send the Map to the data type converter to be converted to a Java bean. In the route, the mapperId=JsonToBeanMapper parameter indicates that the mapper file below is the file to be used for the conversion. 



Field Mapping File


The purpose of the field mapping XML file below is to provide the necessary information on what the converter is expected to do. SAS Business Orchestration Services loads up the field mapping files and configures them in the system after they are validated for errors.  Then the converter processes fields in the order they are defined in the field mapping file.

<?xml version="1.0"?>
<fieldMapper xmlns=""
             xsi:schemaLocation=" fieldMapper-10.2.xsd"
    <field name="planeType">
        <sourceField name="planeType"/>
    <field name="tailNumber">
        <sourceField name="tailNumber"/>
    <field name="maxCapacity">
        <sourceField name="maxCapacity"/>
    <field name="landed">
        <sourceField name="landed"/>

Line 6 defines the mapper's id, to which the mapperId parameter in the JSON to Bean route refers. The target type attribute in line 5 of the mapping file provides the data type that is to be produced by the converter.  In this example, the type is a Java Bean. The field element declares a field in the Java Bean that is produced by the converter. These field names correspond with the instance variables in the Planes class, which is shown below.  Nested inside each field element is the sourceField element, which declares which field in the input object should be read as the source value for that field element.  Each source field name corresponds with the key for some value in the Map input object. The source field and output field names are kept the same for simplicity. Since a Java bean is the target type, the converter uses an introspector to determine the field type of the instance variables in the bean, invoking the proper converters. Therefore, allowing the integer and boolean fields to be handled appropriately by the converter. For more information about the Field Mapping file, see “Working with Data Types” in  SAS® Business Orchestration Services 10.2: User’s Guide.





Below is the Java class Planes:

public class Planes {
    private String planeType;
    private String tailNumber;
    private int maxCapacity;
    private boolean landed;
    public String getPlaneType() {
        return planeType;
    public void setPlaneType(String planeType) {
        this.planeType = planeType;
    public String getTailNumber() {
        return tailNumber;
    public void setTailNumber(String tailNumber) {
        this.tailNumber = tailNumber;
    public int getMaxCapacity() {
        return maxCapacity;
    public void setMaxCapacity(int maxCapacity) {
        this.maxCapacity = maxCapacity;
    public boolean getLanded() {
        return landed;
    public void setLanded(boolean landed) {
        this.landed = landed;
    public String toString(){
    return "Plane Type: " + getPlaneType() + "\nTail Number: " + getTailNumber() + "\nMax Capacity: " + getMaxCapacity() +
    "\nStatus: " + getLanded() ;





To conclude, SAS Business Orchestration Services allows you to seamlessly convert data from one format to another with the built-in data type converter. To do so,  you must fetch your data from wherever it is stored. Then, your data must be parsed into an object then sent to the converter. The field mapping file is the blueprint, giving the converter the necessary instructions to convert your data. Then send the Java Bean to your endpoint. For additional information on SAS Business Orchestration Services and Apache Camel, consult the following resources:

SAS® Business Orchestration Services 10.2 User’s Guide

Camel Documentation



Version history
Last update:
‎07-27-2021 01:19 PM
Updated by:


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags