Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Data processing pipelines

A data processing pipeline connects reading, validation, filtering, transformation, and writing stages. When exchanging JSON, graph references and correctly escaped paths need separate attention.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

JSON.stringify(JSON.parse(text).filter(predicate).map(transform))

A data processing pipeline passes each stage's result to the next: read → validate → select → transform → write. In the example, JSON.parse reads text, filter selects records, map defines their shape, and JSON.stringify produces JSON output. Define each stage's input contract; successful parsing alone does not validate a data schema.

Array filter and map are eager and create result arrays; this is not a streaming pipeline. They do not deeply copy nested objects. Avoid mutation inside callbacks and handle errors deliberately. The example only checks that the input is an array; untrusted data also needs record validation. The language features used fit within ECMAScript 2015; the example requires no Web APIs and does not infer their browser support from Node 24.

Graph references and escaped paths in JSON. JSON does not preserve shared object identity; without special conversion, JSON.stringify rejects cycles with TypeError. Here, nextId is an ordinary field in the chosen format, not an automatically resolved reference. After filtering, it can point to a removed record: decide whether to retain, remove, or reject such a reference. The example deliberately retains it.

A path is text, not an instruction to access a file. In JSON text, a backslash is written as \\; JSON.parse restores a single character. A JavaScript literal has its own escaping layer. Use JSON.stringify rather than manually concatenating JSON. Escaping does not validate a path or make it safe.

Examples

const text = JSON.stringify([
  { id: "a", active: true, path: "C:\\data\\a.json", nextId: "b" },
  { id: "b", active: false, path: "C:\\data\\b.json", nextId: "a" }
]);

const rows = JSON.parse(text);
if (!Array.isArray(rows)) throw new TypeError("Expected array");

const result = rows
  .filter(row => row.active === true)
  .map(row => ({ id: row.id, path: row.path, nextId: row.nextId }));

console.log(JSON.stringify(result));

Result

[{"id":"a","path":"C:\\data\\a.json","nextId":"b"}]

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources