Class SimpleJsonTransformationDriver

java.lang.Object
com.adaptris.core.transform.json.SimpleJsonTransformationDriver
All Implemented Interfaces:
TransformationDriver

@ComponentProfile(summary="Simple JSON/XML Transformation driver", tag="json,xml,transformation") public class SimpleJsonTransformationDriver extends Object implements TransformationDriver
Simple XML to JSON converter.

This uses the default json.org implementation to convert between JSON and XML. When converting to XML, it will add a root element called json (this is configurable via setJsonTag(String)) as the required XML root element. When converting from XML then it expects the same tag as the root element of the XML.

If your input is a relatively JSON object, then this is the transformation driver to use. The key differentiator is that where the output should be a JSON array with a single element; it will not be supported by this driver implementation. You can still use it, but you will have to execute a JsonTransformService afterwards to change the cardinality.

If the input is a JSON array, then json-array (not configurable) will be added as the root element, that wraps the JSON array.

In the adapter configuration file this class is aliased as simple-transformation-driver which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • SimpleJsonTransformationDriver

      public SimpleJsonTransformationDriver()
  • Method Details

    • transform

      public String transform(String input, TransformationDirection direction) throws ServiceException
      Perform transformation..
      Specified by:
      transform in interface TransformationDriver
      Parameters:
      input - The data to transform.
      direction - The direction of the transformation.
      Returns:
      The transformed data.
      Throws:
      ServiceException - Thrown if there is a problem with the transformation.
    • getJsonTag

      public String getJsonTag()
      Get the JSON tag.
      Returns:
      The JSON tag.
    • setJsonTag

      public void setJsonTag(String jsonTag)
      Set the JSON tag.
      Parameters:
      jsonTag - The JSON tag.