New Pipelines Transformer: JSON Patch

Originally published at: New Pipelines Transformer: JSON Patch - Golioth

A new JSON Patch Pipelines transfomer is now generally available for Golioth users. It allows for modifying JSON payloads, or payloads that have been transformed into JSON in a previous pipeline step, in order to fit a specific structure or schema. To see this transformer in action, check out the documentation example or last week’s Friday Afternoon Stream. Shaping Data for Different Destinations Golioth frequently sits at the intersection of firmware and cloud platforms. One of our goals when launching Pipelines was to enable those to worlds to seamlessly interact, avoiding the need for one side to compromise to suit the other. For example, Pipelines can allow for devices to send data in a compact binary format, such as CBOR, then have it translated to a text-based representation, such as JSON, for delivery to a cloud service. The json-patch transformer enhances this capability by not only changing the format, but also the structure and content. Furthermore, it allows for the structure required by the end destination to change over time, without requiring firmware updates. In the following example, fields are re-arranged to meet the requirements of the custom webhook data destination. Critically, if this destination changed, or a new one was added in the future, the pipeline could be updated, and the device could continue sending the same payloads. filter: path: “*” content_type: application/cbor steps: - name: change-format transformer: type: cbor-to-json version: v1 - name: transform-and-deliver transformer: type: json-patch version: v1 parameters: patch: | [ {“op”: “add”, “path”: “/environment”, “value”: {}}, {“op”: “add”, “path”: “/location”, “value”: {}}, {“op”: “move”, “from”: “/temp”, “path”: “/environment/temp”}, {“op”: “move”, “from”: “/lat”, “path”: “/location/lat”}, {“op”: “move”, “from”: “/long”, “path”: “/location/long”} ] destination: type: webhook version:…

1 Like