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 Details

    • JsonlibTransformationDriver

      public JsonlibTransformationDriver()
  • Method Details

    • parse

      protected net.sf.json.JSON parse(String input) throws net.sf.json.JSONException
      Description copied from class: JsonTransformationDriverImpl
      Parse the string to JSON.
      Specified by:
      parse in class JsonTransformationDriverImpl
      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(String input) throws net.sf.json.JSONException
      Throws:
      net.sf.json.JSONException
    • parseArray

      protected static net.sf.json.JSONArray parseArray(String input) throws net.sf.json.JSONException
      Throws:
      net.sf.json.JSONException