JSON Templates

FME has the ability to populate an existing JSON structure using the JSONTemplater transformer.

Whilst its possible to create a basic JSON document within transformers such as the AttributeManager or the HTTPCaller itself using the Text Editor function the JSONTemplater allows a great degree of sophistication and also allows the creation of sub templates.

Sub Templates allow for multiple rows to be added to an existing document. For example a web service may have a wrapper that puts in information about a specific brand of car, however it may have multiple colour options all of which need to be included. The Root document would have the basic car specification but we could create a sub-template for colour. We could add multiple features each representing a colour into the Colour port on the transformer and this would added these as an array to the root document.


Microsoft Teams Integration Example

Currently there is not a transformer for Mircosoft Teams as there is for Slack however its possible to enable Web Hooks in Teams and post a message to it.

As can be seen in the example below the JSON that Teams expects is well structured and is supplied by Mircosoft so we dont need to create all of it from scratch just modify it to fit our requirement.

We can take that template add it to the JSONTemplater and populate it with information from the Workspace, in this case it would be why a Job has failed and its job number which all come from a published parameters.

In this case we have a single template type but we could use different JSONTemplater transformers for different message types if required.

This then gets passed into the HTTPCaller and the populated template is used as the Upload Body within a HTTP Post request as shown below.

This results in the following notification arriving in Teams.