gradual-json
0Runtime dependencies
8.1 kBnpm tarball · v0.1.1
Browser / Node.jsOne ESM implementation
MITOpen source license ↗

Progressive JSON parser v0.1.1

Build JSON objects
progressively

Read the object while input is still arriving.

function parse(
  chunks: AsyncIterable<string>,
  host?: object,
  property?: string
): Promise<JsonValue>;
npm install gradual-json
Input string chunks{{ step }} / {{ parts.length }} chunks
{{ parts.slice(0, Math.max(0, step - 1)).join('') }}{{ parts[step - 1] }}
parse(chunks(), host, "data")
host.data{{ complete ? 'Complete object' : 'Building' }}
{{ complete ? 'Input ended · returns host.data' : 'Input continues · partial result available' }}

Integration examples

Use it in different scenarios

Receive input from HTTP or SSE.
Write into Vue objects or record commands with a Proxy.

{{ current.title }}

{{ current.description }}

Integration codeFull code · Gist ↗
{{ current.code }}
{{ scenario === 'proxy' ? 'Proxy get / set implementation' : 'Show input adapter code' }}
{{ current.adapter }}
Live output

{{ host.data?.title }}

  • {{ item.name }}

{{ scenario === 'proxy' ? 'Commands generated as input arrives' : 'host.data' }}

  1. {{ entry.op }} {{ JSON.stringify(entry.path) }} = {{ JSON.stringify(entry.value) }}
{{ scenario === 'http' ? 'Show byte chunks and decoded text' : scenario === 'sse' ? 'Show SSE messages and JSON fragments' : 'Show input and object' }}

String input passed to parse

{{ received }}
{{ statusLabel }}

{{ current.note }}

Tests and measurement

Tests & performance

Validate syntax, chunk boundaries, Vue proxies, and the published package.
Compare complete parsing times using the same input and chunks.

1,096Tests passed
0Tests failed
345Upstream string test files

Node 24.21.0 · JSON syntax, chunk boundaries, Vue integration, and package installation.Test coverage ↗

Benchmark on your device

4,096-character chunks
{{ message }}
Complete parsing time · shorter bars mean less time · each group has its own scale
gradual-json0.1.1 jsonriver1.1.1 @streamparser/json0.0.26 · partial

{{ item.title }}{{ item.bytes ? item.bytes.toLocaleString('en-US') + ' B' : '—' }}

{{ method.label }}{{ item.medianMs ? item.medianMs[method.id].toFixed(3) + ' ms' : '—' }}

Libraries differ in partial update granularity and parsing semantics. This chart compares complete parsing times for valid input.

Runs in this browser on your device. ASCII JSON, 4,096-character chunks, 3 warmups, and 11 trials with rotating library order; reports the median. Complete results are checked before timing. Excludes library loading, network waits, input decoding, and Vue updates.Measured on this device: {{ measuredAt }}.

Benchmark source ↗