Skip to content

docs(help): jsonwrite and jsonparse, and rewire JsonKB to the builtin - #204

Merged
ddehilster merged 1 commit into
VisualText:mainfrom
ddehilster:docs/json-builtins
Aug 4, 2026
Merged

docs(help): jsonwrite and jsonparse, and rewire JsonKB to the builtin#204
ddehilster merged 1 commit into
VisualText:mainfrom
ddehilster:docs/json-builtins

Conversation

@ddehilster

@ddehilsterddehilster commented Aug 4, 2026

Copy link
Copy Markdown
Member

Docs and library side of VisualText/nlp-engine#712 (jsonwrite / jsonparse builtins).

⚠️Do not merge before nlp-engine#712 is released.KBFuncs.nlp here calls the jsonwrite builtin; on an older engine that name doesn't exist and JsonKB would fail.

spec/KBFuncs.nlp — JsonKB becomes a wrapper

JsonKB(L("file"),L("con")) {
jsonwrite(L("file"),L("con"));
}

Byte-identical output, ~ faster on the pass. Serializing the KB is where a knowledge-base analyzer spends most of its time — on date-time, the thirteen-line output.nlp that calls JsonKB and SaveKB was 43.9% of total runtime.

Scope, stated plainly: analyzers carry their own copy of KBFuncs.nlp (13 in the analyzers repo, 21 bundled in the extension), and those copies already differ from this template. So this gives newly created analyzers the speedup automatically; an existing analyzer gets it when its copy is refreshed. It is not a silent global upgrade.

JsonKBRecurse, JsonAttributes and JsonStr are left in place with a note explaining why — an analyzer may call them directly (JsonStr is independently useful for escaping), and they document exactly what the builtin reproduces.

New pages

jsonwrite.md and jsonparse.md, including the mapping table and the two quirks the builtin reproduces deliberately for byte compatibility:

  • indentation for level n is max(1,n) steps, not n
  • a concept name with interior digits is split at the wrong place when deciding whether it's a counted sibling

Both are documented rather than silently fixed, because changing either would alter existing analyzers' output files.

jsonparse also documents why it exists beyond convenience: the json2kbb Python pass needs Python on the machine — which the npm and pypi distributions do not provide — and it won't overwrite an existing .kbb, so editing the .json appears to do nothing until you delete it.

Version notes also record the 3.8.1 python-pass fix.

🤖 Generated with Claude Code

Engine side: VisualText/nlp-engine#712.
spec/KBFuncs.nlp
JsonKB becomes a one-line wrapper around the jsonwrite builtin. Its
output is byte-identical, so nothing downstream changes, but the pass
gets about 3x faster: serializing the KB is where a knowledge-base
analyzer spends most of its time. On the date-time analyzer the
thirteen-line output pass that calls JsonKB and SaveKB was 43.9% of
total runtime, all of it inside interpreted NLP++.
Kept as a wrapper rather than editing every analyzer's output.nlp.
Note that analyzers carry their OWN copy of KBFuncs.nlp, so an existing
analyzer picks this up when its copy is refreshed; newly created ones
get it from the template automatically.
JsonKBRecurse, JsonAttributes and JsonStr are left in place, with a note
saying why: an analyzer may call them directly (JsonStr is useful on its
own for escaping a string), and they document exactly what the builtin
reproduces byte for byte.
New pages
jsonwrite.md, jsonparse.md, including the two long-standing quirks the
builtin reproduces deliberately for byte compatibility -- the indent for
level n is max(1,n) steps, and a concept name with interior digits is
split at the wrong place when deciding whether it is a counted sibling.
Also records the 3.8.1 python pass fix in the version notes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ddehilster added a commit to VisualText/nlp-engine that referenced this pull request Aug 4, 2026
Bumped in this PR rather than as a follow-up, because the help pages and
the KBFuncs.nlp comment in VisualText/visualtext-files#204 already name
3.8.2 as the release that introduces jsonwrite and jsonparse. Leaving the
constant at 3.8.1 would have made both of those wrong.
A patch bump, following this repo's convention: 3.7.10, 3.7.12, 3.7.13
and 3.7.14 all shipped new features as patch releases within a minor line.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ddehilster
ddehilster merged commit 2211324 into VisualText:mainAug 4, 2026
1 check passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ddehilster