This document provides a comprehensive overview of all expression packs available in JSON Expressions and the expressions they contain.
Quick Start: Most users should start with the basePack which includes the most commonly used expressions. Add additional packs as needed for your specific use cases.
Choose packs based on your application's needs:
- Configuration & Rules: basePack + filteringPack
- Data Transformation: arrayPack + projectionPack
- Mathematical Computation: mathPack + aggregationPack
- String Processing: stringPack
- Object Manipulation: objectPack
- Date & Time Operations: temporalPack
Use case: Essential expressions for most applications. Includes data access, basic conditionals, comparisons, boolean logic, and common array operations.
When to use: Start here for almost all applications. This pack covers 80% of common use cases.
import { createExpressionEngine, basePack } from "json-expressions";
const engine = createExpressionEngine({ packs: [basePack] });$get- Access object properties by path (supports dot notation, wildcards, array paths)$prop- Fast simple property access (2.5x faster than$get, no path features)$identity- Return input unchanged (identity function)
$case- Multi-branch conditional with literal and predicate support$if- Simple if-then-else conditional
$eq- Test equality$gt- Test greater than$gte- Test greater than or equal$lt- Test less than$lte- Test less than or equal$ne- Test not equal
$filter- Filter array by predicate$filterBy- Filter array by object property criteria$map- Transform array elements
$exists- Test if object property exists$isEmpty- Test if value is empty$isPresent- Test if value is present (not null/undefined)$matchesAll- Test if object matches all property criteria (AND logic)$matchesAny- Test if object matches any property criteria (OR logic)
$debug- Debug expression evaluation with logging$default- Provide default value for null/undefined$pipe- Chain expressions in sequence
Use case: Mathematical calculations, arithmetic operations, and basic statistical functions.
When to use: Applications involving numerical computations, calculations, or mathematical transformations.
import { createExpressionEngine, mathPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [mathPack] });$abs- Absolute value of a number$add- Addition of numbers$divide- Division of numbers$modulo- Modulo operation$multiply- Multiplication of numbers$subtract- Subtraction of numbers
$count- Count elements in array$max- Find maximum value$mean- Calculate average$min- Find minimum value$sum- Sum of numbers
Use case: Basic comparison operations for WHERE clause logic and validation.
When to use: Applications focusing on filtering, validation, or conditional logic based on scalar comparisons.
import { createExpressionEngine, comparisonPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [comparisonPack] });$eq- Test equality$gt- Test greater than$gte- Test greater than or equal$lt- Test less than$lte- Test less than or equal$ne- Test not equal
$between- Test if value is within range$in- Test if value is in array$nin- Test if value is not in array
$exists- Test if object property exists$isEmpty- Test if value is empty$isPresent- Test if value is present (not null/undefined)
Use case: Array manipulation toolkit for data transformation and processing.
When to use: Applications that work extensively with arrays, lists, or collections requiring transformation, filtering, or manipulation.
import { createExpressionEngine, arrayPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [arrayPack] });$filter- Filter array by predicate$filterBy- Filter array by object property criteria$find- Find first matching element$map- Transform array elements
$concat- Concatenate multiple arrays$join- Join array elements into string$reverse- Reverse array order$unique- Remove duplicate elements
$pluck- Extract property values from object array
$coalesce- Get first non-null value
$groupBy- Group array elements by criteria
Use case: Object and dictionary operations for property manipulation and introspection.
When to use: Applications working with complex objects, needing property selection, merging, or object transformation.
import { createExpressionEngine, objectPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [objectPack] });$select- Select and transform object properties
$omit- Create object without specified properties$pick- Create object with only specified properties
$merge- Merge multiple objects
$fromPairs- Create object from key-value pairs$keys- Get object property names$pairs- Convert object to key-value pairs$values- Get object property values
Use case: String processing and transformation functions.
When to use: Applications involving text processing, formatting, or string manipulation.
import { createExpressionEngine, stringPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [stringPack] });$lowercase- Convert to lowercase$trim- Remove whitespace from ends$uppercase- Convert to uppercase
$replace- Replace text in string$split- Split string into array$substring- Extract substring
Use case: WHERE clause logic and data filtering operations.
When to use: Applications with complex filtering requirements, search functionality, or business rule evaluation.
import { createExpressionEngine, filteringPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [filteringPack] });$between- Test if value is within range$eq- Test equality$gt- Test greater than$gte- Test greater than or equal$lt- Test less than$lte- Test less than or equal$ne- Test not equal
$all- Test if all elements match predicate$any- Test if any element matches predicate$filter- Filter array by predicate$filterBy- Filter array by object property criteria$find- Find first matching element
$matchesAll- Test if object matches criteria
$exists- Test if object property exists$isEmpty- Test if value is empty$isPresent- Test if value is present (not null/undefined)
$matchesRegex- Test if string matches regex pattern
Use case: SELECT clause operations and data transformation for reshaping and projecting data.
When to use: Applications that need to transform, reshape, or project data into different formats or structures.
import { createExpressionEngine, projectionPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [projectionPack] });$concat- Concatenate multiple arrays$filter- Filter array by predicate$flatMap- Map and flatten results$join- Join array elements into string$map- Transform array elements$pluck- Extract property values from object array$unique- Remove duplicate elements
$lowercase- Convert to lowercase$substring- Extract substring$uppercase- Convert to uppercase
$case- Multi-branch conditional with literal and predicate support$if- Simple if-then-else conditional
$eq- Test equality$gt- Test greater than$gte- Test greater than or equal$in- Test if value is in array$lt- Test less than$lte- Test less than or equal$ne- Test not equal$nin- Test if value is not in array
Use case: Statistical and aggregation functions for data analysis and summarization.
When to use: Applications requiring statistical analysis, data summarization, or aggregation operations.
import { createExpressionEngine, aggregationPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [aggregationPack] });$count- Count elements in array$max- Find maximum value$min- Find minimum value$sum- Sum of numbers
$mean- Calculate average
$groupBy- Group array elements by criteria
Use case: Date and time manipulation, calculations, and formatting. All operations work with ISO 8601 strings.
When to use: Applications that need to work with dates and times - scheduling, expiration logic, date formatting, time-based business rules.
import { createExpressionEngine, temporalPack } from "json-expressions";
const engine = createExpressionEngine({ packs: [temporalPack] });$parseDate- Parse date strings with format patterns$formatDate- Format dates with custom patterns$isDateValid- Check if a date string is valid
$addDays- Add days to a date$addMonths- Add months to a date$addYears- Add years to a date$addHours- Add hours to a date$addMinutes- Add minutes to a date$subDays- Subtract days from a date$subMonths- Subtract months from a date$subYears- Subtract years from a date
$diffDays- Difference in days between two dates$diffMonths- Difference in months between two dates$diffYears- Difference in years between two dates$diffHours- Difference in hours between two dates$diffMinutes- Difference in minutes between two dates$diffSeconds- Difference in seconds between two dates$diffMilliseconds- Difference in milliseconds between two dates
$startOfDay- Get start of day (00:00:00)$endOfDay- Get end of day (23:59:59.999)$startOfMonth- Get first day of month$endOfMonth- Get last day of month$startOfYear- Get first day of year$endOfYear- Get last day of year
$isAfter- Check if first date is after second$isBefore- Check if first date is before second$isSameDay- Check if dates are on same day
$isWeekend- Check if date is Saturday or Sunday$isWeekday- Check if date is Monday-Friday
$year- Extract year from date$month- Extract month from date (1-12)$day- Extract day from date$hour- Extract hour from date (0-23)$minute- Extract minute from date$second- Extract second from date$dayOfWeek- Get day of week (0=Sunday, 6=Saturday)$dayOfYear- Get day of year (1-365/366)
- Expression Reference - Complete documentation for all expressions
- Quick Start Guide - Get started with JSON expressions
- Custom Expressions - Create your own expressions