Configuring a JSON data transform as a response data transform in data pages
You can use a JSON data transform as a response data transform in data pages for REST integration to make serialization and deserialization faster and more efficient. The REST Integration wizard creates a REST connector, creates a class, generates the data model, and creates the request and response data transforms that turn the integration layer into the data layer. For JSON data models, the data transforms that the REST Integration wizard creates work, but they are slower and less efficient than using a JSON data transform. You can replace the request and response data transforms created by the REST Integration wizard with JSON request and response data transforms.
To use a JSON data transform, create a JSON data transform and configure the response or request data transform that was created by the REST Integration wizard to use it. For instructions on configuring a request JSON data transform, see the following instructions. For instructions on configuring a request JSON data transform, see Configuring a JSON data transform as a request data transform in data pages.
Configuring a JSON response data transform has the following high-level steps.
- Create a REST connector by using the REST Integration wizard.
- Create the JSON response data transform.
- Configure the response data transform.
- Configure the REST connector.
Creating a REST connector by using the REST Integration wizard
Run the REST Integration wizard to create a REST connector by clicking Creating REST integration.
. For details about the REST Integration wizard, seeCreating the JSON response data transform
Create the JSON response data transform to use in the response data transform created by the REST Integration wizard. The JSON data transform must be created in the same class as the response data transform. You can determine the class by opening the data page from the Generation Summary page generated by the REST Integration wizard, and clicking the Open icon next to the response data transform.
- In the Application Explorer, locate the class that the response data transform is in, for example, Code-Pega-List.
- Right-click the class and click .
- In the Label field, enter a short description.
- In the Data model format field, click JSON.
- In the Add to ruleset field, select the ruleset. It is recommended that you use the same ruleset as the data page so that all data assets are packaged in the same ruleset. You can use a different ruleset, however, if you want to package and move the data assets to another application, having them in the same ruleset ensures that all data assets are moved.
Create Data Transform dialog box
- Click Create and open.
- Click the Definition tab.
- If you are using a single-record data page, skip this step; otherwise, complete the following steps for a list data page.
- In the Top element structure, click Array.
- In the Pagelist Property field, select .pxResults.
- Click the Pages & Classes tab.
- Add the pages and classes from the response data transform to the JSON data transform. You do not need to add the data source. The following example shows the pages and classes in the response data transform.
Response data transform Pages & Classes tab
JSON data transform Pages & Classes tab
- In the Page name field, enter the page name.
- In the Class field, enter the class. It must be the same as the class in the response data transform.
- Click the Definition tab.
- Create the mapping between the clipboard and the JSON data by adding the fields that are in the response data transform to the JSON data transform. The following example shows the fields in the response data transform.
The following examples use a list data page. If you are using a single-record data page, .pxResults is not used.
Response data transform Definition tab
- In the Action field, click Set.
- In the Clipboard field, enter the first property.
- In the JSON field, enter the corresponding JSON property.
- Click Add element to repeat these steps for every field that you need to add. The following example shows the JSON data transform with the fields from the response data transform.
JSON fields might not match the fields in the response data transform if the JSON fields contained characters that cannot be used in property names. In this case, the REST Integration wizard adjusts the names so that they do not contain unsupported characters. To find the property names for the JSON side of the transform, open the property rule and look at the pzExternalName property qualifier as shown in the following example.
Property rule form pzExternalName property
JSON data transform
- Click Save.
Configuring the response data transform
Update the response data transform generated by the REST Integration wizard to use the new JSON response data transform.
The following example shows a sample response data transform.
Data transform generated by the REST Integration wizard
- In the response data transform, delete step 2, Append and Map to, by clicking the Trash can icon to the right of the step.
- Click Submit when asked to confirm the deletion.
- Click in row 1.
- Click the Add a row icon to create a new step 2.
- In the Action field, click Apply Data Transform.
- In the Target field, select the JSON response transform that you just created.
Response data transform updated to use new JSON response data transform
- Click the Gear icon next to the JSON data transform.
- In the jsonData field, enter DataSource.pyJsonData. This field that contains the JSON string that is deserialized and passed to the clipboard.
- In the executionMode field, enter DESERIALIZATION.
Apply Data Transform Parameters dialog box
- Click Submit.
Configuring the REST connector
Update the REST connector that was generated by the REST Integration wizard to use the DataSource.pyJsonData parameter.
- In the REST connector, click the Methods tab.
- Click the Response tab.
- In the Map To field, select Clipboard.
- In the Map to key field, enter .pyJsonData. The .pyJsonData property is part of @baseclass and is the property to use for mapping.
- Click Save.
Edit Connect REST method