Class JsonPipe

All Implemented Interfaces:
FrankElement, HasApplicationContext, HasName, HasTransactionAttribute, IConfigurable, IForwardTarget, IPipe, IScopeProvider, IWithParameters, NameAware, EventThrowing, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle

JSON is not aware of the element order. This pipe performs a best effort JSON to XML transformation. If you wish to validate or add structure to the converted (xml) file, please use the Json2XmlValidator.
Author:
Martijn Onstwedder, Tom van der Heijden
  • Constructor Details

    • JsonPipe

      public JsonPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from class: FixedForwardPipe
      Checks for correct configuration of forward.
      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class FixedForwardPipe
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • doPipe

      public PipeRunResult doPipe(Message message, PipeLineSession session) throws PipeRunException
      Description copied from interface: IPipe
      This is where the action takes place. Pipes may only throw a PipeRunException, to be handled by the caller of this object. Implementations must either consume the message, or pass it on to the next Pipe in the PipeRunResult.
      Throws:
      PipeRunException
    • setDirection

      public void setDirection(JsonPipe.Direction value)
      Direction of the transformation.
      Default value
      JSON2XML
    • setAddXmlRootElement

      public void setAddXmlRootElement(boolean addXmlRootElement)
      When direction is JSON2XML, it wraps a root element around the converted message. When direction is XML2JSON, it includes the name of the root element as a key in the converted message, thus preserving the structure of the original input message.
      Default value
      true when JSON2XML and false when XML2JSON
    • setRootElementName

      @Default("root") public void setRootElementName(String rootElementName)
      When direction is JSON2XML, specifies the name of the root element when addXmlRootElement is true. When direction is XML2JSON, can not be used.
    • setPrettyPrint

      public void setPrettyPrint(boolean prettyPrint)
      Format the output in easy legible way (currently only for JSON2XML)