Skip to main content

JSON Transformer

Parses each received message as a JSON object and adds every field as a value. Nested objects and arrays are flattened with dots: {"env": {"t": 23.5}, "acc": [1, 2]} gives env.t, acc.0 and acc.1. Numbers become integer or float values, booleans become boolean values and strings become string values. null and empty objects or arrays are skipped.

On MQTT and MQTT Server connections, the topic is added in front of every name, with / replaced by .. For example, {"t": 23.5} on sensors/room1 gives sensors.room1.t, so values from different topics stay apart on the values page and dashboard.

Use it with message-based transports (MQTT, WebSocket), or with a serial or TCP device that prints one JSON object per line, using the Line codec.

Things to know:

  • The payload must be one JSON object, starting with { after surrounding whitespace is trimmed. Anything else gets no values: a top-level array, several objects in one message, or invalid JSON.
  • The transformer only runs on messages that have no values yet. When the codec already decodes values, it does nothing.

Configuration reference​

Config IDjson_transformer
Selected byapp_transformer = "json_transformer"
PlatformsLinux, Windows, Android
LicenseFree

Parses JSON key-value pairs.

This transformer has no settings of its own.

Example config​

Default values as they appear in a saved configuration (for example the JSON block at the end of a cycbox/examples/*.lua file). Settings detected at runtime are omitted.

{
"app": {
"app_transformer": "json_transformer"
}
}