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 java.lang.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 viasetJsonTag(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 Summary
Constructors Constructor Description SimpleJsonTransformationDriver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getJsonTag()
Get the JSON tag.void
setJsonTag(java.lang.String jsonTag)
Set the JSON tag.java.lang.String
transform(java.lang.String input, TransformationDirection direction)
Perform transformation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.transform.json.TransformationDriver
transform
-
-
-
-
Method Detail
-
transform
public java.lang.String transform(java.lang.String input, TransformationDirection direction) throws ServiceException
Perform transformation..- Specified by:
transform
in interfaceTransformationDriver
- 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 java.lang.String getJsonTag()
Get the JSON tag.- Returns:
- The JSON tag.
-
setJsonTag
public void setJsonTag(java.lang.String jsonTag)
Set the JSON tag.- Parameters:
jsonTag
- The JSON tag.
-
-