Parse to model
Description
Parses an input stream into a typed model. Pick the model in the inspector and choose the wire format — JSON, YAML, XML, CSV or Excel. Branches on success/error so the pipeline can handle malformed input. An array variant parses the stream into an array of the chosen model.
When to use
Use Parse to model to turn raw JSON, YAML, XML, CSV or Excel data from a stream into a
typed model your pipeline can work with. Pick the target model in the inspector; the node reads the stream,
validates it against that model, and emits the parsed value on its Model output. Because
parsing can fail on malformed or unexpected input, the node sits on the execution flow
and branches: the success pin fires with the parsed Model, the error pin fires when
parsing fails.
It is the usual first step after receiving structured data — parse the body of a Receive HTTP trigger, or the response body of an HTTP request, then wire the Model output into a Break node to read individual fields. When the payload is a list rather than a single object, use the array variant (Parse to model (array)), which emits an array of the chosen model instead.
CSV and Excel work differently from the document formats, because a model is a tree and a
spreadsheet is a grid. One row becomes one model, so the array variant is the normal
choice. Nested objects are read from prefixed columns (address.city), a list of scalars
from one cell split on a separator, and a list of models from rows of its own — either a
second sheet joined on a key column, or this same file grouped by one, which is how a flat
order export that repeats its order columns on every line row becomes one model per order.
All of that is configured on the model, under Hints. A header row is always required, and
only the modern .xlsx/.xlsm files are readable — the legacy binary .xls is not.
Character encodings are worked out for you. A byte-order mark settles it, an XML
declaration (<?xml version="1.0" encoding="ISO-8859-1"?>) is honoured, and anything else
that is well-formed UTF-8 is read as UTF-8 — the ISO-8859, windows-125x, KOI8, Shift-JIS,
Big5 and EUC families are all understood, so a legacy partner feed does not have to be
converted first. A file that declares nothing and is not UTF-8 is read as windows-1252,
with a warning in the execution log naming the assumption, so mojibake is traceable rather
than mysterious. CSV and Excel are the exception: CSV takes its encoding from the model’s
CSV hints, where it can be pinned per model, and an Excel workbook has no document
encoding to pick.
See the Models tutorial for a full worked example.
Pins
Input pins
| Pin | Type | Default | Notes |
|---|---|---|---|
| Input | Input stream | — | The input stream to parse — for example the body output of a Receive HTTP trigger or an HTTP response body. |
| Format | Data format | JSON | The wire format to parse: JSON, YAML, XML, CSV or EXCEL. CSV and Excel are tabular — how the model maps onto rows and columns is declared with the CSV/Excel hints on the model itself. |
Output pins
| Pin | Type | Notes |
|---|---|---|
| Model | model | The parsed model value, available on the `success` branch. Wire into a Break node to read its fields. |
Execution pins
| Pin | Direction |
|---|---|
| In | Input |
| Success | Output |
| Error | Output |
Example
Parse an incoming webhook body. Wire the body output of Receive HTTP into the Input of
Parse to model, select the expected model in the inspector, and leave Format at JSON.
On the Success execution output, wire the Model output into a Break node to read its
fields; on the Error execution output, wire a Log message or Fail node so malformed
payloads are surfaced.
For a supplier’s spreadsheet, wire the file output of Open FTP file into a Parse to model
(array) with Format set to EXCEL, then loop the resulting array with For each and send
each model on with Model to stream and HTTP request.