Remove node from JSON document

Overview

You can use the JSON Remove Node filter to remove a JSON node from a JSON message. You can specify the node to remove using a JSON Path expression. The JSON Path query language enables you to select nodes in a JSON document.

For more details on JSON Path, see http://code.google.com/p/jsonpath.

Configuration

To configure this filter, specify the following fields:

Name:

Enter a suitable name that reflects the role of the filter.

JSON Path Expression:

Enter a JSON Path expression to specify the node to remove (for example, $.store.bicycle). Policy Studio warns you if you enter an unsupported JSON Path expression.

[Note] Note

If the specified expression returns more than one node, all returned nodes are removed.

Fail if no nodes returned from JSON Path:

When this option is selected, and the JSON Path expression returns no nodes, the filter returns false. If this option is not selected, and the JSON Path returns no nodes, the filter returns true, and no nodes are removed. This option is not selected by default.

Save deleted nodes to be reinserted to new location:

Select this option if you want to move JSON nodes from one location in the message to another. The deleted nodes are stored in the deleted.json.node.list message attribute. You can then use the JSON Add Node filter to insert the deleted nodes into a different location in the message. For more details, see the Add node to JSON document topic.

Examples

The following are some examples of using the JSON Remove Node filter.

Remove a node

The following example shows removing a bicycle from the store:

Remove JSON node

The following example shows the corresponding request and response message in Oracle API Gateway Explorer:

Remove JSON node request and response

Remove all items in an array

The following example shows removing all books in an array:

Remove JSON array

The following example shows the corresponding request and response message in Oracle API Gateway Explorer:

Remove JSON array request and response