Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Configuring a JSON data transform as a response data transform in data pages

Updated on May 4, 2020

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.

  1. Create a REST connector by using the REST Integration wizard.
  2. Create the JSON response data transform.
  3. Configure the response data transform.
  4. 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 Designer Studio > Integration > Connectors > Create REST Integration. For details about the REST Integration wizard, see Creating REST integration.

Creating 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.

  1. In the Application Explorer, locate the class that the response data transform is in, for example, Code-Pega-List.
  2. Right-click the class and click Create > Data Model > Data Transform.
  3. In the Label field, enter a short description.
  4. In the Data model format field, click JSON.
  5. 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.

    GET data transform screen oneCreate Data Transform dialog box

  6. Click Create and open.
  7. Click the Definition tab.
  8. If you are using a single-record data page, skip this step; otherwise, complete the following steps for a list data page.
    1. In the Top element structure, click Array.
    2. In the Pagelist Property field, select .pxResults.
    3. Click the Pages & Classes tab.
    4. 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 tabResponse data transform Pages & Classes tab

      JSON data transform Pages & Classes tabJSON data transform Pages & Classes tab

    5. In the Page name field, enter the page name.
    6. In the Class field, enter the class. It must be the same as the class in the response data transform.
  9. Click the Definition tab.
  10. 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

    Response data transform Definition tab

    1. In the Action field, click Set.
    2. In the Clipboard field, enter the first property.
    3. In the JSON field, enter the corresponding JSON property.
    4. 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
      Property rule form pzExternalName property

    JSON data transform Definition tab

    JSON data transform

  11. 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.

It is not recommended that you delete this data transform. Modifying it to use the new JSON response data transform is the fastest way to access the data page. In addition, step 3 is required for error handling.

The following example shows a sample response data transform.

Response data transform

Data transform generated by the REST Integration wizard

  1. In the response data transform, delete step 2, Append and Map to, by clicking the Trash can icon to the right of the step.
  2. Click Submit when asked to confirm the deletion.
  3. Click in row 1.
  4. Click the Add a row icon to create a new step 2.
  5. In the Action field, click Apply Data Transform.
  6. In the Target field, select the JSON response transform that you just created.

    Updated response data transform

    Response data transform updated to use new JSON response data transform

  7. Click the Gear icon next to the JSON data transform.
  8. In the jsonData field, enter DataSource.pyJsonData. This field that contains the JSON string that is deserialized and passed to the clipboard.
  9. In the executionMode field, enter DESERIALIZATION.

    Apply Data Transform Parameters dialog box

    Apply Data Transform Parameters dialog box

  10. Click Submit.

Configuring the REST connector

Update the REST connector that was generated by the REST Integration wizard to use the DataSource.pyJsonData parameter.

  1. In the REST connector, click the Methods tab.
  2. Click the Response tab.
  3. In the Map To field, select Clipboard.
  4. In the Map to key field, enter .pyJsonData. The .pyJsonData property is part of @baseclass and is the property to use for mapping.
  5. Click Save.

Edit Connect REST GET methodEdit Connect REST method

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us