JSON++ Terminology
This document defines the canonical terms used throughout the JSON++ documentation. When describing JSON++ behaviour, always prefer these terms over informal alternatives such as templating or rendering.
Structural Reuse
JSON++ provides structural reuse mechanisms that allow configurations to be constructed from reusable fragments. Structural reuse consists of two categories:
-
Structural composition, which combines configuration documents:
-
Inheritance (
$extends) -
Inclusion (
$includes)
-
-
Expression evaluation (
eval:), which computes configuration values dynamically.
Structural reuse ├─ structural composition │ ├─ inheritance ($extends) │ └─ inclusion ($includes) └─ expression evaluation (eval:)
Structural Composition
Structural composition is the subset of structural reuse that combines configuration documents structurally.
JSON++ provides two structural-composition constructs: inheritance ($extends) and inclusion ($includes).
Inheritance ($extends)
Inheritance is the mechanism by which an object declares that it is a specialisation of one or more parent objects. The current object inherits every field from its parents and may override any of them with its own values.
Precedence direction: base → derived.
Parent (base) objects supply defaults; the derived object’s own fields take precedence over all inherited fields.
When multiple parents are listed, earlier entries in the $extends array take precedence over later ones.
{
"$extends": ["base.json", "fallback.json"],
"key": "this value overrides whatever base.json or fallback.json define"
}
Priority from highest to lowest: current object → first parent → … → last parent.
Inclusion ($includes)
Inclusion is the mechanism by which an object pulls in one or more external fragments that are applied on top of the including object. Unlike inheritance, where the current object overrides its parents, inclusion gives higher priority to the included fragments.
Precedence direction: included fragments → including object.
The including object provides the starting values; the included fragments are then applied on top, overriding those values.
When multiple fragments are listed, later entries in the $includes array take precedence over earlier ones.
{
"$includes": ["platform-defaults.json", "security-policy.json"],
"log_level": "warn"
}
Priority from highest to lowest: last fragment → … → first fragment → current object’s own fields.
Coexistence with $extends.
When both keys are present in the same object, $extends is resolved first and $includes is applied on top.
The full priority order from highest to lowest is:
$includes (later entries) → $includes (earlier entries) → current object → $extends (earlier entries) → $extends (later entries)
Expression Evaluation (eval:)
Expression evaluation is the mechanism by which string values or keys prefixed with eval: are replaced by the result of evaluating the suffix as a jq expression.
The expression is evaluated against the current JSON root after all structural composition has been resolved.
{
"version": "eval:string:\"v\" + (.major | tostring)",
"count": "eval:number:.items | length"
}
Expression evaluation applies to both values and keys. When a key expression evaluates to an array of strings, one key–value pair is emitted per element.
Escaping Meta Keywords (raw:)
Escaping is the mechanism by which a string value or key prefixed with raw: is passed through to the output with the prefix stripped, without any evaluation.
This is the guaranteed way to preserve a value or key that would otherwise be interpreted as an eval: expression or as a JSON++ reserved keyword such as $extends, $includes, or $local.
In practice, jq++ keeps inheritance-time control keywords in the $… namespace and treats new keyword families as a major-version compatibility concern, so accidental collisions should remain rare.
{
"message": "raw:eval:this is not an expression",
"raw:$extends": "this key appears verbatim in the output"
}