MetricsHub
MetricsHub Community Connectors 1.0.22
-
Home
- Connector Developer Guide Computes 24
decode (Compute)
When To Use
Use decode to reverse base64 or url encoding on a single column, row by row, leaving the other columns untouched. Reach for it when an API or command returns encoded values — a Base64-encoded name, description, or token payload, or percent-encoded identifiers extracted from URLs — and you need the original text for matching, translation tables, or display attributes in mapping.
Syntax
sources:
sensors:
type: http
method: get
path: /api/v1/sensors
resultContent: body
computes:
- type: json2Csv
entryKey: /sensors
properties: /id;/encodedName;/status
# Column 3 (/encodedName) holds a Base64-encoded display name
- type: decode
column: 3
encoding: base64
Properties
| Property | Required | Default | Description |
|---|---|---|---|
type |
Yes | None | decode. |
column |
Yes | None | 1-based index of the column to decode. Every row is processed; other columns are left unchanged. |
encoding |
No | None | Encoding to reverse: base64 or url. Set it explicitly and match the encoding actually applied to the data. |
Table Transformation Example
With column: 3 and encoding: base64 (columns shown after json2Csv, whose leading entry column is column 1):
Input
| Entry | id | encodedName | status |
|---|---|---|---|
| /sensors[0] | s1 | U2Vuc29yIEJheSAx | ok |
Result
| Entry | id | encodedName | status |
|---|---|---|---|
| /sensors[0] | s1 | Sensor Bay 1 | ok |
With encoding: url, a value such as sensor%20bay%201 becomes sensor bay 1.
Recommended Pattern
- Decode as early as possible, right after the payload-to-table compute, so every later compute (
keepOnlyMatchingLines,translate,replace) andmappingworks on readable text. - Pick the
encodingfrom the API documentation or an observed sample; a wrong choice yields garbage, not an error you can grep for. - Combine with
extractorsubstringwhen only part of a column is encoded: isolate the encoded fragment in its own column first, then decode it.
Common Mistakes
- Decoding the wrong column after an upstream compute changed the table shape (indexes are 1-based and shift when columns are added or removed).
- Forgetting the leading entry column produced by
json2Csv: the first JSON property sits in column 2, so the decoded field is one column further right than expected. - Applying
base64decoding to plain text: the result is binary garbage that silently corrupts the row. - Confusing direction:
decoderecovers original text; useencode[1] to produce Base64/URL-encoded values.
Community Examples
Note
No community connector currently uses decode; the examples above are illustrative.
decode
compute
base64
url
decoding
metricshub
community
connector
hardware
system
Links:
- [1] ./encode.html
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
Searching...
No results.
