public class SafeJsonTransformationDriver extends DefaultJsonTransformationDriver
DefaultJsonTransformationDriver
that executes a transform to strip-spaces before rendering as JSON.
This differs from DefaultJsonTransformationDriver
in that it will execute a transform to strip spaces using the standard
xsl:strip-space elements="*"
directive before attempting to serialize the XML as JSON. In some situations the default
driver can be very sensitive to whitespace that may occur because of indenting and formatting.
The transform used is stored in the jar file itself - "META-INF/com.adaptris.core.transform.json.strip-spaces.xsl"; it is very simple, and may not handle
namespaces terribly well. If in doubt, execute a transform yourslef, and then use DefaultJsonTransformationDriver
as
usual.
In the adapter configuration file this class is aliased as json-safe-transformation-driver which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
STRIP_SPACES_XSLT |
Constructor and Description |
---|
SafeJsonTransformationDriver() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
xmlToJSON(java.lang.String input)
Convert XML to JSON.
|
parse, parseArray, parseObject
getArrayName, getElementName, getForceTopLevelObject, getObjectName, getRootName, getSkipWhitespace, getTrimSpaces, getTypeHintsCompatibility, getTypeHintsEnabled, objectName, setArrayName, setElementName, setForceTopLevelObject, setObjectName, setRootName, setSkipWhitespace, setTrimSpaces, setTypeHintsCompatibility, setTypeHintsEnabled, transform
public static final java.lang.String STRIP_SPACES_XSLT
protected java.lang.String xmlToJSON(java.lang.String input) throws ServiceException
JsonTransformationDriverImpl
xmlToJSON
in class JsonTransformationDriverImpl
input
- The XML to convert.ServiceException
- Thrown if there was a problem converting from XML to JSON.