Model to stream

Models Pure
Model to stream
Model(model)
Stream(Output stream)
Format(Data format) JSON

Description

Pure function that serialises a model, or a list of models, to an output stream. Supports JSON, YAML, XML, CSV and Excel. Use to send a model as an HTTP request body, or to build a spreadsheet to upload or attach.

When to use

Use Model to stream when a model needs to become the body of an HTTP request. The HTTP request node takes an output stream for its body so that large payloads are written to the socket on demand rather than buffered in memory — Model to stream bridges a model value into that stream without an intermediate string.

If you only need the serialised text (for logging, comparison, or storage), use Model to string instead. Reach for Model to stream specifically when the destination is a streaming consumer such as http-request.body.

It is also the only way to produce a spreadsheet: an .xlsx file is a zip archive rather than text, so Excel is available here and not on Model to string. Wire a list of models into the Model input and the stream output straight into Upload FTP file, an email attachment, or an HTTP request body.

See the Models tutorial for a full worked example.

Pins

Input pins

Pin Type Default Notes
Model model — The model value to serialise. Takes one model or a list of them — a list becomes a JSON/YAML array, an XML container element, or the rows of a CSV file or workbook. Wire from a Make node, a Parse to model node, or any output that produces a model.
Format Data format JSON The serialisation format: 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
Stream Output stream An output stream that, when consumed, writes the serialised model bytes. Wire directly into the body input of HTTP request.

Example

POST a JSON model to an external API. Build the payload with a Make node, wire its Value output into the Model input of Model to stream (Format set to JSON), then feed the Stream output directly into the Body input of HTTP request (Method set to POST). The model is serialised straight to the request socket, avoiding any full-payload buffering.

See also