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>> 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:
- Enter __typename in the Target Name text box
- Select the Equals radio button from the Operation options
- Enter Article in the Target Value text box
The completed Developer Interface is as illustrated below:
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:
- Enter __typename in the Target Name text box
- Select the Equals radio button from the Operation options
- 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.