Skip to content
sudeanbPublic

About

{ ? JSONQuest } — a strict RFC 8259 JSON engine with line/column errors, an event-based streaming parser, and a jq-flavoured compiled query language. Zero dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

{ ? JSONQuest }

An RFC 8259 JSON engine and a jq-flavoured query language — strict parser with line/column errors, event-based streaming, and a compiled generator pipeline. Zero dependencies.

CI License: MIT Node

▶ Paste, query, transform →

import { parse, query } from './src/index.js';

const doc = parse(storeJson);

query(doc, '.store.books[] | select(.price < 20) | .title');
// → ['Neuromancer']

query(doc, '{titles: [.store.books[].title], count: (.store.books | length)}');
// → [{ titles: ['Dune', 'Neuromancer', 'Sapiens'], count: 3 }]

query(doc, '[.. | numbers] | add');
// → [63]

What's inside

  • Strict RFC 8259 parser — precise line/column on every error (Unexpected token '}' at line 4, column 1), surrogate-pair-aware escapes, zero tolerance for trailing commas / comments / leading zeros
  • Streaming parser — event-based scanning with full paths (store.books.0.title), no tree building
  • Query language — pipes, comma (multi-output), select/map, object & array construction, recursive descent (..), arithmetic with type-aware + (numbers add, strings concat, arrays append, objects merge), alternative //
  • Compiled queries — each query compiles once into nested generators; laziness is free (first(...) | … never evaluates the rest)
  • Fuzz-tested — 300 random documents round-trip through stringify ∘ parse; streaming events reconciled against hand-counted leaves; every malformed mutation throws WITH a position

Full grammar, operator semantics and the error model: docs/SPEC.md.

Quick start

git clone https://github.com/sudeanb/jsonquest.git
cd jsonquest
node --test     # 27 tests
query(doc, '{titles: [.store.books[].title]}');
// → [{ titles: ['Dune', 'Neuromancer', 'Sapiens'] }]

Design decisions worth reading about

docs/SPEC.md:

  • // semantics: empty streams count as "no output" — false | // x yields false first (it IS an output), then falls back only on emptiness
  • the compiler is a generator pipeline: pipes are yield* delegation, so first can short-circuit an unbounded stream
  • duplicate object keys keep the last value (documented choice; the RFC permits any)

Limitations (honest list)

  • no |= update-assignment, no string interpolation \(...), no @base64-style format strings
  • has/1 is a roadmap item (use .["k"] != null today)
  • the streaming parser is single-string (chunked async input is roadmap)

License

MIT

About

{ ? JSONQuest } — a strict RFC 8259 JSON engine with line/column errors, an event-based streaming parser, and a jq-flavoured compiled query language. Zero dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages