Functional extensions to JSONata
You can use the following functional extensions to standard JSONata notation. Each extension corresponds to a part of the API context.
- $apiCtx()
- $header()
- $httpVerb()
- $operationID()
- $operationPath()
- $queryParameter()
- $statusCode()
- $storageType()
- $urlParameter()
- $xpath()
For more information, see API context variables.
$apiCtx()
- Signature
$apiCtx()- Variable
- Generic access to an API context
- Description
- The
$apiCtx()extension gives generic access to an API context.- Sample transform field in an extract action.
"$apiCtx().request.uri" - Sample condition of a case in a switch
action.
"$apiCtx().request.path = '/simple/apictx-function'"
- Sample transform field in an extract action.
$header()
- Signature
$header(name)- Variable
message.headers.name- Description
- Message header.
$httpVerb()
- Signature
$httpVerb()- Variable
request.verb- Description
- HTTP method of the request.
$operationID()
- Signature
$operationID()- Variable
api.operation.id- Description
- ID of the operation.
$operationPath()
- Signature
$operationPath()- Variable
api.operation.path- Description
- Path of the operation.
$queryParameter()
- Signature
$queryParameter('name')- Variable
-
request.parameters.name.locationsThe supported keyword is
query.request.parameters.name.values
- Description
- Searches for the index of
queryinrequest.parameters.name.locationsand returnsrequest.parameters.name.values[index], where[index]is the value forqueryin locations. Parameter values are not URL decoded.
$statusCode()
- Signature
$statusCode()- Variable
message.status.code- Description
- Status code.
$storageType()
- Signature
$storageType([arg])- Variable
variable.bodyYou can specify any variable in the API context. When no variable is specified, the default variable
message.bodyis used.- Description
- Storage type of the message. The supported values are
binary,empty,graphql,json,stream, orxml.
$urlParameter()
- Signature
$urlParameter('name')- Variable
-
request.parameters.name.locationsThe supported keywords are
pathandquery.request.parameters.name.values
- Description
- Searches for the index of
pathandqueryinrequest.parameters.name.locationsand returns a single array that contains bothpathandqueryvalues fromrequest.parameters.name.values. When the URL contains both path and query parameter values, the array includes the path values first followed by the query values. The values of each parameter type are added in the order that they are received. Parameter values are URL decoded.For example, the following URL contains both path and query parameter values.http://example.com/petstore/cats/adopt?breed=Sphynx&breed=SiameseThe$urlParameter('breed')URL returns the following array of values.[cats, adopt, Sphynx, Siamese]In this example, the URL includes an API path that is configured as
/petstore/{breed}/{breed}, wherebreedis configured to be a path parameter of the API path. As a result,catsandadoptare included in the output.
$xpath()
- Signature
$xpath(path, xpathExpression)- Variable
- You can specify any writable variable in the API context. The
xpathExpressionmust be a literal string. - Description
- Allows use of XPath expressions. The following example specifies all price elements in the
source.
$xpath($, '//price')