Getting started Community Training Tutorials Documentation APIs, AI & Tools
{"name": "Leandro","lastName": "Shokida"}
{"name": "Mariano","lastName": "De Achaval"}
MIME type: application/x-ndjson
ID: ndjson
DataWeave represents the Newline Delimited JSON format (ndjson) as an array of objects. Each line of the ndjson format is mapped to one object in the array.
The following parser strategies are supported by the ndjson reader:
In-memory
Streaming
For details, see DataWeave Readers.
The following examples show uses of the ndjson format.
This example shows how DataWeave represents simple ndjson input.
skipInvalidThis example shows that the ndjson reader ignores all lines of ndjson data that are invalid if skipInvalid=true.
The input to the DataWeave source includes valid and invalid lines of ndjson data. Assume that the input is from a file myInput.ndjson.
{"name": "Christian"
{"name": "Mariano"}
{"name": "Tomo"
{"name": "Shoki"}
The DataWeave script inputs the contents of the input file myInput.ndjson, applies the skipInvalid=true reader property, and transforms the input to the JSON format and MIME type.
%dw 2.0
var myInput = readUrl('classpath://myInput.ndjson', 'application/x-ndjson, {skipInvalid=true})
output application/json
---
myInput
DataWeave supports the following configuration properties for the Newline Delimited JSON format (ndjson).
The ndjson format accepts properties that provide instructions for reading input data.
| Parameter | Type | Default | Description |
|---|---|---|---|
|
|
|
Ignores any empty line. Valid values are |
|
|
|
Skips data that is not valid ndjson. Valid values are |
The ndjson format accepts properties that provide instructions for writing output data.
| Parameter | Type | Default | Description |
|---|---|---|---|
|
|
|
Size of the writer buffer. |
|
|
|
When set to |
|
|
|
Encoding for the ndjson reader to use. |
|
|
|
Valid values are |
|
|
|
Valid values are |