Interoperability
The jsoncurrent wire format is language-agnostic. The Python and Node implementations are reference implementations — any Emitter or Collector that speaks the same wire format is a first-class participant.
Building a compliant Emitter
An Emitter must:
- Parse raw JSON token-by-token using a single-pass approach (no buffering the full response)
- Emit
addpatches for new values — empty{}or[]for containers, the value directly for primitives - Emit
appendpatches for subsequent string chunks at an already-initialised path - Numbers, booleans, and null must be atomic — never emitted partially
- Emit
completepatches (unless disabled) in child-before-parent order - The
completepatch value must be a deep snapshot of the assembled value at that path
Building a compliant Collector
A Collector must:
- Apply
addpatches viasetPath(state, path, value) - Apply
appendpatches by concatenating onto the existing string at that path - Apply
insertpatches by pushing onto the existing array at that path - Handle
completepatches without mutating state — fire apathcompleteevent using the patch’svaluefield directly (already snapshotted by the Emitter) - Handle the absence of
completepatches gracefully - Fire
pathstarton the firstaddorinsertat a previously-unseen path
Path parsing
Paths use dot-notation with bracket array indices. A compliant parser must handle:
'' → root (empty array of keys)
'title' → ['title']
'sections[0]' → ['sections', 0]
'sections[0].heading' → ['sections', 0, 'heading']Conformance checklist
- Numbers emitted as a single
add— never partially - Booleans and null emitted as a single
add— never partially - Containers (
{},[]) emit a fresh empty value in theaddpatch -
completepatch value is a deep snapshot, not a live reference - Children complete before parents
- Empty path
''handled for root container -
completepatches absent whencompletions: false— Collector handles gracefully -
appendonly appears afteraddat the same path
Reference implementations
- Node Emitter —
jsoncurrent - Python Emitter —
jsoncurrent - JS Collector —
jsoncurrent
Last updated on