Core syntax reference for J-Expr, the JSON expression syntax for HashQL.
J-Expr maps JSON types to expression semantics:
| JSON Type | J-Expr Meaning |
|---|---|
| String | Path/identifier |
| Array | Function call |
| Object | Data constructor (with # keys) |
Strings are parsed as paths or identifiers.
Access nested fields:
"vertex.id"
"vertex.id.entity_id"
"entity.properties.name"Use :: for namespacing:
"Std::String"
"Std::Collections::HashMap"Rooted paths start with :: (absolute reference):
"::core::types::String"
"::graph::head::entities"
"::graph::tmp::decision_time_now"Arrays represent function calls: [function, arg1, arg2, ...]
["add", {"#literal": 1}, {"#literal": 2}]
["not", {"#literal": true}]
["concat", {"#literal": "hello"}, {"#literal": " world"}]["::graph::head::entities", ["::graph::tmp::decision_time_now"]]
["::core::math::sqrt", {"#literal": 16}]["add", ["multiply", { "#literal": 2 }, { "#literal": 3 }], { "#literal": 4 }]Use : prefix for named/labeled arguments.
Object syntax:
["greet", { ":name": { "#literal": "Alice" }, ":greeting": { "#literal": "Hello" } }]Shorthand string syntax:
["func", ":varName"] // References variable "varName" as labeled argument["==", "left", "right"]
["!=", "left", "right"]
[">", {"#literal": 5}, {"#literal": 3}]
["<", "a", "b"]
[">=", "x", {"#literal": 0}]
["<=", "y", {"#literal": 100}]["and", {"#literal": true}, {"#literal": false}]
["or", "condition1", "condition2"]
["not", "flag"]["add", {"#literal": 1}, {"#literal": 2}]
["sub", {"#literal": 5}, {"#literal": 3}]
["multiply", {"#literal": 2}, {"#literal": 3}]
["div", {"#literal": 10}, {"#literal": 2}]["::graph::head::entities", ["::graph::tmp::decision_time_now"]][
"filter",
"entities",
[
"fn",
{ "#tuple": [] },
{ "#struct": { "entity": "_" } },
"_",
["==", "entity.draft_id", { "#literal": null }],
],
]Use dotted paths:
"vertex.id.entity_id"
"entity.properties.name"[
"let",
"entities",
["::graph::head::entities", ["::graph::tmp::decision_time_now"]],
[
"filter",
"entities",
[
"fn",
{ "#tuple": [] },
{ "#struct": { "e": "_" } },
"_",
["==", "e.archived", { "#literal": false }],
],
],
][
"let",
"value",
{ "#literal": 42 },
[
"if",
[">", "value", { "#literal": 0 }],
[
"if",
["<", "value", { "#literal": 100 }],
{ "#literal": "in range" },
{ "#literal": "too high" },
],
{ "#literal": "too low" },
],
][
"let",
"x",
{ "#literal": 1 },
[
"let",
"y",
{ "#literal": 2 },
["let", "z", ["add", "x", "y"], ["multiply", "z", { "#literal": 2 }]],
],
]- Special Forms - Control flow (
if,let,fn,type,use, etc.) - Data Constructors - Typed data (
#literal,#struct,#tuple,#list,#dict) - Type DSL - Type annotation syntax
- Expression parser:
libs/@local/hashql/syntax-jexpr/src/parser/ - String/path parser:
libs/@local/hashql/syntax-jexpr/src/parser/string/ - Array parser:
libs/@local/hashql/syntax-jexpr/src/parser/array/