JSON response filter - HTTP

This filter allows you to intercept JSON responses as they come from the server, and modify them if needed.

You must make sure that all the responses for this filter contain JSON text, otherwise an exception will be thrown when the content is parsed.

This is usually done either by specifying a URL that is known to respond with JSON, or by specifying a JSON

Parameters

URL pattern

Optional. Specifies for which request URL(s) the filter should be executed. This does not include the protocol, host and port number. If specified, it can be either:

  • a URL as a string for which this filter should get executed. For instance: /rest/state

  • a regular expression (starting with regex: ) that matches the URL. For instance: regex:/rest/state/[0-9]+

Method

Optional. If specified, the request's HTTP method (e.g. GET, POST, PUT, etc...) for which this filter should get executed. If not specified, all methods will match.

Client IPs

Optional. If specified, a comma-separated (or line break separated) list of IP4 or IP6 addresses or regular expressions for IP addresses. If specified, only requests from matching IP addresses will cause the execution of the filter. For example:

  • 201.43.1.33, 88.49.9.199, regex:88\.48\.23\.\d{1,3}

  • 0:0:0:0:0:0:0:1, regex:2600:1700:6270:6aa0:51:92ca:\d+:\d+

Header patterns

Optional. If specified, a newline-separated list of response header specifications which must match. The name of the header is a simple case-insensitive string, followed by a colon, and a regular expression for the header value. For instance:

Content-type: ((application/json)|(text/json))

If more than one pattern is specified (separated by line breaks), then the filter will be executed if at least one of the patterns matches at least one header in the response.

JSON path

Optional. A JSON Path expression. If specified, this filter will be invoked only if the body of the response contains at least one object that matches this path.

Context

In addition to the usual variables, this filter also defines the following variables:

  • context.jsonPathResult : if the JSON path parameter is set, then the result of that path will be available in this variable.

  • context.jsonHolder : a JSON holder object providing access to the JSON payload