json to json transformer

JSON to JSON Transformer

Version: 17.07

Supported Since: 17.07.5

What is a JSON to JSON Transformer?

A JSON to JSON Transformer is a processing element which transforms a JSON message payload from one format to another JSON format. This transformation is done based on the popular JSON transformation library named Jolt which uses JSON based specification files to define the transformation criteria.

In order to use this processing element, you must first select the JSON Operations dependency from the processors list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the JSON Operations dependency.

json to json transformer outports

Out Ports

Next

The message will be sent to this outport if the payload transformation is completed successfully

On Exception

The message will be sent to this outport if the processing element failed to transform the payload due to some reason

Parameters

Jolt Spec File Path

Basic

The path to a valid Jolt Specification File that will be used for the transformation. Please refer the Jolt library documentation for more information about defining a transformation specification.

Sample Use Case

In the following use case, the requirement is to read a message with a JSON payload from a SFTP server, convert the message payload to a different JSON format and then deliver it to another SFTP endpoint.

The format of the JSON message received is as follows.

{
  "ratings": {
    "primary": 5,
    "quality": 4,
    "design": 5
  }
}

The format expected by the destination SFTP server is as follows.

{
  "Ratings" : [ {
    "Name" : "primary",
    "Value" : 5
  }, {
    "Name" : "quality",
    "Value" : 4
  }, {
    "Name" : "design",
    "Value" : 5
  } ]
}
json to json transformer flow
json to json transformer config

In this flow, the Processor outport of SFTP ingress connector is connected to the inport of the JSON to JSON Transformer so that the SFTP message received by the connector is handed over to the transformer next. If the processing element is able to transform the payload from incoming JSON format to the output JSON format expected successfully, the message with the transformed payload is handed over to the SFTP egress connector, since the "Next" outport of the JSON to JSON Transformer is connected to it.

In the case of transformation failure, a log will be generated and then the message flow will be completed in an exceptional state, as the "On Exception" outport of the JSON to JSON Transformer is connected to a Logger processing element, followed by an Exceptional Flow End element.

The content of the Jolt specification file used for the JSON transformation is as below.

[
  {
    "operation": "shift",
    "spec": {
      "ratings": {
        "*": {
          "$": "Ratings[#2].Name",
          "@": "Ratings[#2].Value"
        }
      }
    }
  }
]
In this topic
In this topic
Contact Us