Comment on page
This example demonstrates how to use the Transformation to extract sensor data from JSON into individual attributes.
Drag the JSON Deserializer Transformation Agent to the canvas, link the input endpoint to the sensor readings and the output to the printer. Rename the Agent and save the Data Stream.
Select the Agent and click Configure. In this case, keep the default Collection.
Set the Json Column - in our example use SensorReading.
Fill in the Payload Definition. Click the + button and enter the name, output alias, and type as follows:
- assetid, Asset, String
- temperature, Temperature, Double
- pressure, Pressure, Double
- flowrate, Flow Rate, Double
Enter any additional columns from the input payload that you want to include in the output. In this case, add Timestamp for both the column name and alias as we want to keep the same name.
Apply the changes, save the Data Stream, and Publish it.
Let's look at the Live Data View. Observe that the incoming payload is replaced by the payload attributes extracted from the sensor JSON as well as the timestamp, the column we chose to keep.