@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
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 and Description |
---|
JsonlibTransformationDriver() |
Modifier and Type | Method and 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) |
getArrayName, getElementName, getForceTopLevelObject, getObjectName, getRootName, getSkipWhitespace, getTrimSpaces, getTypeHintsCompatibility, getTypeHintsEnabled, objectName, setArrayName, setElementName, setForceTopLevelObject, setObjectName, setRootName, setSkipWhitespace, setTrimSpaces, setTypeHintsCompatibility, setTypeHintsEnabled, transform, xmlToJSON
protected net.sf.json.JSON parse(java.lang.String input) throws net.sf.json.JSONException
JsonTransformationDriverImpl
parse
in class JsonTransformationDriverImpl
input
- The string to parse.net.sf.json.JSONException
- Thrown if the string could not be parsed to JSON.protected static net.sf.json.JSONObject parseObject(java.lang.String input) throws net.sf.json.JSONException
net.sf.json.JSONException
protected static net.sf.json.JSONArray parseArray(java.lang.String input) throws net.sf.json.JSONException
net.sf.json.JSONException