Skip to content

Add CanopyJsonVisitor for generic tree browsing (JSON export) - #23

Merged
noha merged 2 commits into
mainfrom
add-canopy-json-visitor
Jul 23, 2026
Merged

Add CanopyJsonVisitor for generic tree browsing (JSON export)#23
noha merged 2 commits into
mainfrom
add-canopy-json-visitor

Conversation

@noha

@noha noha commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Second of two planned HTTP endpoints (Canopy roadmap, HTTP Browse & Edit Handler): a CanopyVisitor that serialises any node (branch or leaf) to JSON, needed for the upcoming GET browse handler.

Required a small prerequisite fix: acceptCanopy: never returned the visitor's result (missing ^), which the stream-based CanopyPrometheusVisitor never needed but a value-building visitor does. Also added the previously-missing acceptCanopy: for CanopyCell/CanopyDictionaryAccessor - both leaf types could not be visited at all before (doesNotUnderstand), since only CanopyAccessor/ CanopyBranchNode implemented it. Both changes are behaviour-preserving for existing visitors (Canopy-Metrics-Tests: 12/12 still green).

Write-only accessors (no readSelector) serialise as JSON null rather than being omitted, unlike the Prometheus visitor - a browse client should still see the leaf exists.

CanopyMetricGroup/CanopyMetricMap (Canopy-Metrics) are not yet covered by this visitor - out of scope here to avoid a Core->Metrics dependency; can be added later as a Canopy-Metrics extension method if the browse endpoint ever needs to expose metrics domains too.

noha and others added 2 commits July 23, 2026 17:47
Second of two planned HTTP endpoints (Canopy roadmap, HTTP Browse & Edit
Handler): a CanopyVisitor that serialises any node (branch or leaf) to JSON,
needed for the upcoming GET browse handler.

Required a small prerequisite fix: acceptCanopy: never returned the visitor's
result (missing ^), which the stream-based CanopyPrometheusVisitor never
needed but a value-building visitor does. Also added the previously-missing
acceptCanopy: for CanopyCell/CanopyDictionaryAccessor - both leaf types could
not be visited at all before (doesNotUnderstand), since only CanopyAccessor/
CanopyBranchNode implemented it. Both changes are behaviour-preserving for
existing visitors (Canopy-Metrics-Tests: 12/12 still green).

Write-only accessors (no readSelector) serialise as JSON null rather than
being omitted, unlike the Prometheus visitor - a browse client should still
see the leaf exists.

CanopyMetricGroup/CanopyMetricMap (Canopy-Metrics) are not yet covered by
this visitor - out of scope here to avoid a Core->Metrics dependency; can be
added later as a Canopy-Metrics extension method if the browse endpoint ever
needs to expose metrics domains too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
NeoJSON isn't loaded/available in the target image - STON already is and
ships an explicit JSON-compatibility mode (STON toJsonString:) that produces
byte-identical output to what NeoJSONWriter produced for all our cases
(plain Dictionary/String/Number/Boolean/nil - no STON-specific class tags
involved here). No test changes needed, Canopy-Core-Tests: 60/60 still green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@noha
noha merged commit 4d17fa0 into main Jul 23, 2026
4 checks passed
@noha
noha deleted the add-canopy-json-visitor branch July 27, 2026 15:00
Sign up for free to 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