Skip to main content

Example JSON Feature

Zuora

Example JSON Feature

In this example, we perform a transformation on JSON content, and target the object that contains a field called __typename with a value of Article.

Example JSON Content

For this example, we use the following JSON content:

{
    "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\""
                    },
                    {
                        "__typename": "DataBlock",
                        "type": "TEXT",
                        "data": "\"<p><a href=\\\"https://www.example.com/test/test-data/22021/test-data-link\\\"><strong>&gt; Click here to review our sample data.</strong></a></p>\\n\""
                    },
                    {
                        "__typename": "DataBlock",
                        "type": "TEXT",
                        "data": "\"<p><span><span><span><span><span><span>A third paragraph appears!</span></span></span></span></span></span></p>\\n\""
                    },
                    {
                        "__typename": "DataBlock",
                        "type": "TEXT",
                        "data": "\"<p><span><span><span><span><span><span>This is the end of the article.</span></span></span></span></span></span><span><span><span><strong><span><span>evo</span></span></strong></span></span></span><span><span><span><span><span><span> readers is another matter, and with a large choice of circa-300bhp alternatives in the hot hatch class, the M135i xDrive will have to be special indeed to warrant attention</span></span></span></span></span></span></p>\\n\""
                        }
                    ]
                }
            }
        }
    }

Example Developer Interface

When you create the rule, complete the Developer Interface section as follows:

  1. Enter __typename in the Target Name text box
  2. Select the Equals radio button from the Operation options
  3. Enter Article in the Target Value text box

The completed Developer Interface is as illustrated below:

Screen-Shot-2020-08-17-at-3.39.34-PM.png

This configuration means that the target rule matches any objects that meet the target condition.

Alternatively, you could complete the Develop Interface as follows to transform all four objects defined in the body array of the JSON defined above:

  1. Enter __typename in the Target Name text box
  2. Select the Equals radio button from the Operation options
  3. Enter Datablock in the Target Value text box

When you have completed your Developer Interface, select the Update & Lock button, then complete your feature rule as described in the Rules Builder topic.