Skip to content

edwardbr/CanopyJSON

Repository files navigation

#[[ Copyright (c) 2026 Edward Boggis-Rolfe All rights reserved. ]]

CanopyJSON

A standalone multi-language library that adds a generic JSON object type to the Canopy RPC IDL type system.

Purpose

IDL type systems are strongly typed by design, which is the right default — but some domains genuinely require runtime flexibility. A canonical example is configuring an LLM request: the set of parameters, model hints, and provider-specific options is open-ended and evolves independently of any interface version. Encoding each variant as a distinct IDL type would be impractical.

json::v1::object solves this by introducing a well-defined generic value type that can hold null, booleans, numbers, strings, arrays, and maps — anything expressible in JSON — while still flowing cleanly through a strongly-typed Canopy interface as a first-class parameter or return value.

Serialisation

The type is deliberately serialisation-aware:

  • JSON marshalling — serialises to and from pure JSON text, so the wire format is human-readable and interoperable with any JSON-capable consumer.
  • Binary marshalling — serialises to a compact binary encoding (via YAS), preserving type fidelity and maximising throughput for performance-sensitive paths.

The same json::v1::object value round-trips correctly through both paths, so callers can choose the transport that suits their latency and interoperability requirements without changing the interface.

Project layout

CanopyJSON/
├── interface/               # Language-agnostic IDL definitions
│   └── json/json.idl
└── c++/                     # C++ language binding
    ├── include/
    │   └── json/json_dom.h  # json::v1::object, map, array + yas serialisers
    └── tests/               # C++ test suite

Additional language bindings can be added as siblings to c++/ without disturbing the shared interface/ layer.

Building (C++)

Requires Canopy as a sibling directory (../Canopy).

cmake --preset Debug    # configure + enable tests
cmake --build build_debug
build_debug/output/json_test

About

Generic JSON value type for Canopy IDL interfaces — pure-JSON wire format for interoperability, binary for performance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors