function jsonStringify
jsonStringify<T>(items: AsyncIterable<T>): AsyncIterable<string>

Convert objects to JSON-encoded strings (one per line).

Useful for serializing structured data to pass between processes or save to files in JSONL (JSON Lines) format.

Examples

Serialize objects to JSON

import { enumerate, jsonStringify } from "jsr:@j50n/proc";

const objects = [{ id: 1 }, { id: 2 }];
const json = await enumerate(objects)
  .transform(jsonStringify)
  .collect();
// ['{"id":1}', '{"id":2}']

Type Parameters

Parameters

items: AsyncIterable<T>

The objects to convert.

Return Type

AsyncIterable<string>

An AsyncIterable of JSON strings.

Usage

import { jsonStringify } from ".";