Skip to Content
Introduction

jsoncurrent

Transport-agnostic patch protocol for streaming incremental JSON.

tokens → [Emitter] → patch stream → [Collector] → assembled object

Install

npm install jsoncurrent

The problem

LLMs generate JSON token by token. Standard parsers throw on incomplete JSON. jsoncurrent solves this with a patch protocol — the Emitter on your server parses raw tokens as they arrive and emits structured patch operations. The Collector on your client applies them incrementally, giving you a live partially-assembled object you can render immediately.

// What the LLM emits mid-stream (unparseable): {"title": "Quarterly Report", "sections": [{"heading": "Exec // What jsoncurrent delivers to your client as it arrives: { path: 'title', value: 'Quarterly Report', op: 'add' } { path: 'sections', value: [], op: 'add' } { path: 'sections[0]', value: {}, op: 'add' } { path: 'sections[0].heading', value: 'Exec', op: 'add' } { path: 'sections[0].heading', value: 'utive Summary', op: 'append' }
Last updated on