Parsing (JSON, Regex, UDT)
Message parsing converts the message body into fields and records for mapping, using JSON, Regex, or an existing UDT. Some JSON syntax errors and UDT evaluation failures are logged and skipped. A successful preview does not prove all inputs are valid.
Where to operate: configuration for data ingestion tasks supporting Payload parsing. On the command line, pass complete parsing and mapping configuration through taosx run -p. Input fields differ by connector; do not reuse entire configurations across connectors.
Parsing converts message bodies to fields and records, which are then filtered, mapped, and written. Prefer built-in parsers that cover the actual format. Use reviewed UDT configuration only when built-in methods are insufficient. A UDT is a user-defined transformation rule. This page covers its use and verification, not parser development or plugin interfaces.
1. Choose a parser
| Input | Selection | Operator checks |
|---|---|---|
| JSON objects or arrays of objects | JSON | Field paths, array expansion, empty fields, and numeric types. |
| Text with a stable format | Regex extraction | Delimiters, named capture groups, unmatched lines, and subsequent type conversion. |
| JSON requiring custom field organization | UDT | Rule source, input/output contract, type stability, and abnormal samples. |
Braces in text do not make it JSON. Obtain the complete original and confirm encoding and compression first. Current UDT inputs must also be parseable as JSON; UDT is not a general decoder for arbitrary binary protocols.
2. Minimal JSON parsing
Enter the following message-body sample in a Kafka or MQTT task:
{"device":"d001","ts":1795132800000,"temperature":23.5}
Select JSON parsing and inspect the parsing preview. Expect one row with three business fields. Selecting the entire object and selecting a nested path are different configurations. To extract a nested object, specify the actual field and path at the extraction stage, then recheck output.
For clicking, viewing, and expanding preview tables, see Obtain samples and preview. The following shows parsing results for the temperature message above, before time type mapping or target writes:
For an array of objects, for example:
[{"device":"d001","ts":1795132800000,"temperature":23.5},{"device":"d002","ts":1795132801000,"temperature":24.5}]
Expect two device records. Check field name and type consistency, then configure time and device mapping separately. The number of messages in an array is not directly the target record count.
Also test invalid JSON, such as a missing closing bracket. The parser logs and skips some JSON syntax errors. A preview may be empty or retain only valid inputs from the same batch without displaying an error. If rows are missing, follow Logs and performance and search for Deserialize json from and Parse json row on the actual parsing host. Compare the original and input/output counts. A successful preview request does not establish that all messages are valid. Do not assume missing records were automatically archived.
2.1 Nested fields and aliases
Do not map nested objects and arrays based only on outermost column names. In this message, temperature is inside the data object and site is in the first object of the locations array:
{"device":"d001","ts":1795132800000,"data":{"temperature":23.5},"locations":[{"site":"zoneA"}]}
Enter the following JSON Path expressions in JSON parsing field selection. Commas separate fields, and the right side of each equals sign is the alias used in later processing:
$["device"]=device,$["ts"]=ts,$["data"]["temperature"]=temperature,$["locations"][0]["site"]=site
Expect one row with four columns: device=d001, ts=1795132800000, temperature=23.5, and site=zoneA. [0] selects only the first position; it does not expand all positions. To handle multiple positions, redesign expansion rules and check output row counts. If an original property name contains periods or other characters inconvenient for direct references, select it with a bracket path and set a simple, unique alias. Do not use the original property name directly as an expression variable.
Test three inputs first: field present, path absent, and empty array. Inspect empty columns and errors before deciding whether missing values are acceptable. After changing an alias, also check filtering, target mapping, and child table templates. Old references do not update automatically because their meanings are similar.
View a JSON parsing and result preview interface example
This separate example uses id and message only to locate parsing and preview buttons. It does not replace the temperature message above. Use this array as preview input; do not send it to a production topic:
[{"id":1,"message":"hello-word"},{"id":2,"message":"hello-word"}]
Select json and click the magnifying glass. Expect two rows with id values 1 and 2, both with message equal to hello-word. Object samples can also be entered individually in the interface. Do not concatenate multiple separate objects and treat them as one valid JSON object.

After locating the buttons, restore the task's actual sample before continuing. Do not mix demonstration fields into temperature table mapping.
3. Minimal Regex extraction
The following message body has a fixed format. In parsing or field extraction, select Regex for the actual message-body field and enter the named capture expression:
d001,1795132800000,23.5
^(?<device>[^,]+),(?<ts>[0-9]+),(?<temperature>-?[0-9]+[.][0-9]+)$
Expect columns device, ts, and temperature. Captures are initially all text. During mapping, convert ts to a timestamp in milliseconds and temperature to DOUBLE. This expression accepts only temperatures with a decimal point, not integers or scientific notation. If the source contains those formats, have the rule maintainer extend and reverify it before production use.
Add an input with a missing field or different delimiter and confirm that the preview explicitly reports a mismatch. Avoid overly broad matching that sends malformed data into incorrect fields.
View a Regex parsing example for access logs
This separate text sample demonstrates log field extraction. Do not mix it with the temperature messages above in the same rule:
192.168.1.1 - - [22/Aug/2021:12:34:56 +0200] "GET /index.html HTTP/1.1" 200 12345
Select regex and enter:
^(?<ip>[0-9]{1,3}(?:\.[0-9]{1,3}){3}) - - \[(?<ts>[^\]]+)\] "(?<method>[A-Z]+) (?<url>\S+) HTTP/[0-9.]+" (?<status>[0-9]{3}) (?<length>[0-9]+)$

The image illustrates field positions for the same log format. Enter the complete expression above. Expect one row: ip=192.168.1.1, ts=22/Aug/2021:12:34:56 +0200, method=GET, url=/index.html, status=200, and length=12345. These values are initially text. ts cannot be handled directly as a millisecond integer; status and length also need conversion to target types. This expression only extracts the format; it does not validate that each IP segment is within 0–255. Adapt it separately for logs with extra proxy fields, different method formats, or escaped quotes.
4. Use existing UDT configuration
Before using UDT, obtain the rule text, input samples, expected output columns and types, version, and error behavior from the rule provider. Use only trusted rules. If extra parsing modules are required, deployment personnel must confirm installation on the taosX host that actually parses data. Browser file upload does not establish runtime readiness.
The simplest JSON pass-through rule is data: it outputs the fields of an input JSON object. Use it to confirm the input contract, not as evidence that business transformation is complete. This is a parsing configuration fragment for Kafka's value field:
{"parse":{"value":{"udt":"data"}}}
Here, value is the Kafka message-body field, the value of udt is rule text, and data represents the parsed JSON value. This fragment lacks a complete target model and cannot replace full task configuration. For taosx run, save the reviewed complete parsing and model configuration as a JSON file, then execute on a command-line host that can reach source and target:
taosx run -f "<源DSN>" -t "<目标DSN>" -p "@<完整配置JSON路径>"
-p accepts JSON text or a file path beginning with @. The file is on the command host and is read by the command's execution account; it is not a remote browser path. Keep quotes around parameters in both PowerShell and Bash. Do not apply Kafka's value field name directly to other connectors.
Use the preview provided by the configuration interface to check normal inputs, nulls, missing fields, and abnormal formats. For array output, check expanded row counts. If output field types are unstable, correct the rule instead of changing every field to a string to hide the problem. If the interface has no corresponding configuration control, do not force task changes through internal APIs. First confirm which interfaces the distribution provides.
4.1 Split three-phase voltage into rows
The following splits three-phase voltage in one device message into three rows. This is only a parsing rule example and does not collect from the source. Preview it successfully in an isolated task first, then enable it with a business-approved target model.
{"ts":"2026-11-20T00:00:00Z","voltage":"220.1,220.3,221.1","dev_id":"8208891"}
Enter this complete rule in the UDT rule input:
let voltages = data["voltage"].split(",");
if voltages.len() != 3 {
throw "voltage must contain exactly three values";
}
[
#{"ts": data["ts"], "voltage": parse_float(voltages[0]), "dev_id": data["dev_id"], "phase": "A"},
#{"ts": data["ts"], "voltage": parse_float(voltages[1]), "dev_id": data["dev_id"], "phase": "B"},
#{"ts": data["ts"], "voltage": parse_float(voltages[2]), "dev_id": data["dev_id"], "phase": "C"}
]
Expect three rows with the same time and device, with phase values A, B, and C, and voltages 220.1, 220.3, and 221.1. UDT can output a single object or an array of objects; not all rules must return arrays.

This is the parsing preview for the complete rule on this page, with fields including voltage and phase. Each row represents one phase. Time remains a UTC string from the source JSON and must later be mapped to the target timestamp type. Three preview rows do not mean writes to three child tables have occurred.
The target supertable can use data columns ts TIMESTAMP and voltage DOUBLE, tags dev_id VARCHAR(32) and phase VARCHAR(1), and child table name t_{dev_id}_{phase}. In an input providing format mapping, write the same child table expression as t_${dev_id}_${phase}. Do not mix the two input syntaxes. Parse time as UTC text with Z. Write the phases to three different child tables or use an approved distinguishing primary key. Do not write all three rows for the same device and time into one child table with only a time primary key, or they will overwrite one another.
This rule first checks for exactly three segments, then parses each as a number. Other inputs are rejected so a fourth segment is not silently ignored. Also test missing phases, four numeric segments, invalid text in the fourth segment, units, and invalid numbers in the first three segments. None should produce normal three-phase records.
UDT evaluation failures are logged and the input skipped by default. A preview may show only empty results without an error dialog. A successful preview request or a task still running does not establish valid data. Do not assume these records entered an error archive or retry queue. First check output row counts, then follow Logs and performance to inspect udt parse data error and Failed to evaluate UDT on the actual parsing host. Preserve the original invalid messages or authorized copies, correct the rule, and reingest from the rereadable source range. Restarting the task cannot recover skipped inputs.
After sending one valid message to the test source, query the same timestamp in each of the three child tables in the taosExplorer Data Browser or taos CLI. Check phases and values. Three preview rows do not guarantee three retained target rows.
5. From parsing verification to actual writes
- For each message format, record input count, parsed output count, fields, and values.
- Configure time, child tables, columns, and tags, and check model previews following Target table modeling and field mapping.
- Send the same inputs to the actual test source, start the task, and query the target to check every valid record.
- Confirm that deliberately invalid inputs follow Write errors and abnormal data. Do not assume data was not discarded because the task did not exit.
6. Troubleshooting, changes, and recovery
| Symptom | Next step |
|---|---|
| JSON parsing fails | Check complete original text, escaping, encoding, and compression before changing target tables. |
| Regex has no match | Compare actual delimiters, whitespace, newlines, and numeric formats. Narrow to one sample first. |
| UDT has no output or changing types | Check the input/output contract. Determine whether the rule deliberately excludes data, skips evaluation failures, or mixes numbers and text. Inspect UDT error logs on the parsing host, not just preview errors. |
| Parsing is correct but writing fails | Check time conversion, target types, table names, and permissions. Continue to mapping and error handling pages. |
Before maintenance, save original configuration and redacted samples. Stop the original task, then modify, save, and start it under the existing procedure. Rolling back rules restores configuration only; it cannot undo written, truncated, or discarded data. For reingestion, define the rereadable source range and a separate verification plan. Successful parsing does not establish end-to-end exactly-once behavior or automatic historical gap filling.