Welcome to Zuora Product Documentation

Explore our rich library of product information

Example truncate array transformation

This task demonstrates how to truncate the body property from JSON content using the Truncate Array transformation in the Rules Builder.

In the following example, we truncate the body property from the JSON content that we used in the Example JSON Feature topic.

To truncate the body property, complete the following steps:

  1. In the Rules Builder, select the Transformations segment title
  2. Drag the Truncate Array decision node to your rules canvas The Truncate Array dialog box displays.
  3. Enter body in the Target property name text box.
  4. Enter 2 in the Enter the number of array values to truncate text box.
  5. Select the Save button to add the decision node to your rule.
  6. Drag from the white circle under the Page View node to the black circle to the left of the Truncate Array decision node, as illustrated below:
  7. Select the down arrow beside the Save as New Version button.
  8. Select Save as New Version & Publish .

When an end user encounters this rule, the JSON returns only two data blocks from the original four defined in the JSON content, as shown below:

{
    "data": {
       "getContentByUrl": {
          "page": {
             "__typename": "Article",
             "title": "This Is A Test Article",
             "body": [
                {
                   "__typename": "DataBlock",
                   "type": "TEXT",
                   "data": "\"<p><span><span><span><span><span><span>Here is the first paragraph of content.</span></span></span></span></span></span></p>\\n\""
                },
                {
                   "__typename": "DataBlock",
                   "type": "TEXT",
                   "data": "\"<p><span><span><span><span><span><span>Here is paragraph number two.</span></span></span></span></span></span></p>\\n\""
                   }
                ]
             }
          }
       }
    }