Extract
Use the Extract policy to extract and transform data from fields in the API context.
Before you begin
Gateway | Policy version |
---|---|
DataPower® API Gateway | 2.0.0 |
This topic describes how to configure the policy in the assembly editor. For details about how to configure the policy in your OpenAPI source, see extract.
About this task
The Extract policy specifies the data source that contains the content to transform, the fields that contain the content, and expressions that define how to transform the content. You use a subset of JSONata notation to specify the fields to extract and transform. For more information, see Constructing JSONata expressions to extract and transform data.
The input to the Extract policy must be parsed data. One way to produce parsed data is to add a Parse policy before the Extract policy in your assembly.
Procedure
Example
Transform the contents of the
account
field to include only
the last 4 characters.- extract:
version: 2.0.0
title: extract
root: message.body
extracts:
- capture: $.members.policy.**.account
transform: $substring($,-4)
description: Include only the last 4 characters of the account field.