Package com.adaptris.core.transform.json
Class JsonlibTransformationDriver
java.lang.Object
com.adaptris.core.transform.json.JsonTransformationDriverImpl
com.adaptris.core.transform.json.JsonlibTransformationDriver
- All Implemented Interfaces:
TransformationDriver
- Direct Known Subclasses:
JsonArrayTransformationDriver
,JsonObjectTransformationDriver
,SafeJsonTransformationDriver
@ComponentProfile(summary="JSON/XML Transformation driver based on net.sf:json-lib, supports top level JSON arrays",
tag="json,xml,transformation",
since="3.10.0")
public class JsonlibTransformationDriver
extends JsonTransformationDriverImpl
Transformation Driver that uses both
JSONObject.fromObject(Object)
and JSONArray.fromObject(Object)
to parse the
input.
In some processing scenarios, this driver is inherently CPU bound because of how it processes XML elements. In
most use-cases you can use SimpleJsonTransformationDriver
instead. You can also opt to use the
com.adaptris:interlok-json-streaming
package instead to transform to and from XML
This uses the net.sf.json
package, which in some situations, can be very sensitive to whitespace, and output may not be
as you expect. Accordingly, when you are generating the XML to be rendered as JSON make sure that you use
xsl:strip-space elements="*"
.
In the adapter configuration file this class is aliased as jsonlib-transformation-driver which is the preferred alternative to the fully qualified classname when building your configuration.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected net.sf.json.JSON
Parse the string to JSON.protected static net.sf.json.JSONArray
parseArray
(String input) protected static net.sf.json.JSONObject
parseObject
(String input) Methods inherited from class com.adaptris.core.transform.json.JsonTransformationDriverImpl
getArrayName, getElementName, getForceTopLevelObject, getObjectName, getRootName, getSkipWhitespace, getTrimSpaces, getTypeHintsCompatibility, getTypeHintsEnabled, objectName, setArrayName, setElementName, setForceTopLevelObject, setObjectName, setRootName, setSkipWhitespace, setTrimSpaces, setTypeHintsCompatibility, setTypeHintsEnabled, transform, xmlToJSON
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
-
Constructor Details
-
JsonlibTransformationDriver
public JsonlibTransformationDriver()
-
-
Method Details
-
parse
Description copied from class:JsonTransformationDriverImpl
Parse the string to JSON.- Specified by:
parse
in classJsonTransformationDriverImpl
- Parameters:
input
- The string to parse.- Returns:
- The JSON.
- Throws:
net.sf.json.JSONException
- Thrown if the string could not be parsed to JSON.
-
parseObject
- Throws:
net.sf.json.JSONException
-
parseArray
- Throws:
net.sf.json.JSONException
-