json array element remover

JSON Array Element Remover

Version: 17.07

Supported Since: 17.07

What is a JSON Array Element Remover?

A JSON Array Element Remover is a processing element which removes an element, in a given index of an array specified by the key at a given JSON path, from a message payload.

In order to use this processing element, you must first select the JSON Operations dependency from the processors list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the JSON Operations dependency.

json array element remover outports

Out Ports

Next

The resulting message context will be sent to this outport after removing the specified array element from the array at the provided JSON path, if the process is completed successfully.

On Exception

The message context will be sent to this outport if any exception occurred while removing the specified array element from the array specified by the key at the provided JSON path of the message payload

Parameters

JSON Path

JSON path of the array specified by the key which is to be modified by removing an element

For additional information please refer to the JSON Path section of JSON Feature documentation

Key Name

Key name of the array, at the specified JSON path of the message payload, which is to be modified by removing an element. Key can be a plain text or any combination of placeholder expressions such as @{message.headers.<name>}, @{message.properties.<name>}, @{mc.properties.<name>}, @{variable.<name>}

Array Index

Index of the array element which is to be removed. Index can be a number or any combination of placeholder expressions such as @{message.headers.<name>}, @{message.properties.<name>}, @{mc.properties.<name>}, @{variable.<name>}

Sample Use Case

In the following use case, the requirement is to receive a message with a JSON payload from an HTTP NIO Ingress Connector, remove the array element specified by the index of the array with key at a given JSON path from the received message payload and deliver the message to a backend service via an HTTP NIO Egress Connector.

The challenge is to remove the array element, specified by the index of the array with key at the given JSON path, from the message payload.

json array element remover flow
json array element remover config

In this flow a JSON Array Element Remover processing element is configured to remove the zeroth element from the sample array telephone-numbers at the JSON path $ of the input JSON payload.

For the following sample input JSON payload, the element {"type" : "mobile", "number": "074-234-567-890"} will be removed from the array telephone-numbers.

 {
    "first-name": "John",
    "last-name" : "Doe",
    "age"      : 24,
    "address"  : {
      "streetAddress": "1st Cross Street",
      "city"         : "Colombo",
      "postalCode"   : "81000"
    },
    "telephone-numbers": [
      {
        "type"  : "mobile",
        "number": "074-234-567-890"
      },
      {
        "type"  : "land line",
        "number": "011-234-567-890"
      }
    ]
 }

Final result will be as follows,

 {
    "first-name": "John",
    "last-name" : "Doe",
    "age"      : 24,
    "address"  : {
      "streetAddress": "1st Cross Street",
      "city"         : "Colombo",
      "postalCode"   : "81000"
    },
    "telephone-numbers": [
      {
        "type"  : "land line",
        "number": "011-234-567-890"
      }
    ]
 }
In this topic
In this topic
Contact Us