Yexp — an expression language for JSON
An expression language for JSON.
Compile once. Evaluate against any input.
expression.yexpsource → number
$.price * $.quantity evaluates to 150. INSIDE THE ENGINE
From expression to result.
Compile once. Run the same instructions against your data.
01 Expression & data
$.price * $.quantityINPUT AT $
{
"price": 50,
"quantity": 3
}02 Compiled instructions
00
LOAD $.price01
LOAD $.quantity02
MUL03
RETURN03 Result
50 × 3NUMBERInspect parsing
Binary · *
$.price$.quantity
TypeScript & JavaScriptZero runtime dependenciesMIT licensedApplication + CLI
01 / THE LANGUAGELess ceremony.
Less ceremony.
More meaning.
JavaScript-shaped expressions, with a few thoughtful additions for the way you actually work with data.
Explore the language ↗01
Find your way through JSON.
Nested properties, optional chaining, and a fallback when data is missing.
$.user.profile.name ?? "Anonymous"02
Keep only what matters.
Filter a collection in place. Project exactly the fields you need.
$.products[.price < 100][*].name03
Let one step feed the next.
Compose a transformation with pipes and familiar arrow functions.
$.users |> filter(.active) |> map(.name)02 / THE RUNTIMEWrite it once.
Write it once.
Run it again.
Compile an expression into a portable program. Cache it, serialize it, or evaluate it against the next input.
The VM runs bytecode with explicit data roots: $, $context, and $env. Your application decides what else it can access.
app.tsTYPESCRIPT
import { compile, evaluate } from '@cristianmartinez/yexp';
// An expression becomes a reusable program.
const total = compile('$.price * $.quantity');
// Same bytecode. Different input.
evaluate(total, { price: 50, quantity: 3 }); // 150
evaluate(total, { price: 25, quantity: 2 }); // 50↳ No generated JavaScript. No ambient globals.
03 / THE TERMINALA small tool.
A small tool.
In your toolchain.
JSON in. An expression. A result out.
The same language, right in your shell.
~/your-project — zsh
$ echo '{"name":"Ada"}' | \
npx @cristianmartinez/yexp-cli '.name'"Ada"↳ stdout