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 bothJSONObject.fromObject(Object)
andJSONArray.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 thecom.adaptris:interlok-json-streaming
package instead to transform to and from XMLThis 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 usexsl: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
Constructors Constructor Description JsonlibTransformationDriver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected net.sf.json.JSON
parse(java.lang.String input)
Parse the string to JSON.protected static net.sf.json.JSONArray
parseArray(java.lang.String input)
protected static net.sf.json.JSONObject
parseObject(java.lang.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
-
-
-
-
Method Detail
-
parse
protected net.sf.json.JSON parse(java.lang.String input) throws net.sf.json.JSONException
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
protected static net.sf.json.JSONObject parseObject(java.lang.String input) throws net.sf.json.JSONException
- Throws:
net.sf.json.JSONException
-
parseArray
protected static net.sf.json.JSONArray parseArray(java.lang.String input) throws net.sf.json.JSONException
- Throws:
net.sf.json.JSONException
-
-