Class JsonArraySplitter

  • All Implemented Interfaces:
    MessageSplitter

    @ComponentProfile(summary="Split a JSON Array into individual JSON objects",
                      tag="json,splitting")
    public class JsonArraySplitter
    extends JsonObjectSplitter
    Message splitter implementation that splits a JSON array so that each element forms a new message.

    If the message cannot be parsed as JSON then an exception will be thrown; If the message is a JSON object but not a JSON array, then the original message is returned. Note that because it operates on the entire payload, size of message considerations may be in order.

    For instance the JSON array [{colour: "red",value: "#f00"},{colour: "green",value: "#0f0"},{colour: "blue",value: "#00f"},{colour: "black",value: "#000"}] would be split into 4 messages whereas {"colours" : [{colour: "red",value: "#f00"},{colour: "green",value: "#0f0"},{colour: "blue",value: "#00f"},{colour: "black",value: "#000"}] } would remain a single message.

    In the adapter configuration file this class is aliased as json-array-splitter which is the preferred alternative to the fully qualified classname when building your configuration.