Expression Syntax Reference
Complete syntax reference for TinySystems expressions.
Basic Syntax
Expression Delimiters
{{expression}}All expressions are enclosed in double curly braces.
Root Reference
$The $ symbol references the root of the input data.
Grammar (BNF)
expression := "{{" expr "}}"
expr := primary | binary | unary | ternary | call
primary := path | literal | "(" expr ")"
path := "$" accessor*
accessor := "." identifier | "[" expr "]"
binary := expr operator expr
unary := "!" expr
ternary := expr "?" expr ":" expr
call := identifier "(" args? ")"
args := expr ("," expr)*
literal := string | number | boolean | null
string := "'" characters "'" | "\"" characters "\""
number := integer | float
boolean := "true" | "false"
null := "null"
identifier := letter (letter | digit | "_")*Path Expressions
Dot Notation
Access object properties:
$.property
$.parent.child
$.deeply.nested.propertyBracket Notation
Access with computed keys or special characters:
$["property"]
$["property with spaces"]
$[$.dynamicKey]Array Access
Access array elements:
$.array[0] // First element (0-indexed)
$.array[1] // Second element
$.array[-1] // Last element
$.array[-2] // Second to lastCombined Access
Mix notations:
$.users[0].name
$.data["field-name"][0]
$.items[$.index].valueLiterals
Strings
'single quotes'
"double quotes"Numbers
42 // Integer
3.14 // Float
-17 // Negative
1.5e10 // ScientificBooleans
true
falseNull
nullOperators
Arithmetic
| Operator | Description | Example |
|---|---|---|
+ | Addition | {{$.a + $.b}} |
- | Subtraction | {{$.a - $.b}} |
* | Multiplication | {{$.a * $.b}} |
/ | Division | {{$.a / $.b}} |
% | Modulo | {{$.a % $.b}} |
Comparison
| Operator | Description | Example |
|---|---|---|
== | Equal | {{$.a == $.b}} |
!= | Not equal | {{$.a != $.b}} |
> | Greater than | {{$.a > $.b}} |
< | Less than | {{$.a < $.b}} |
>= | Greater or equal | {{$.a >= $.b}} |
<= | Less or equal | {{$.a <= $.b}} |
Logical
| Operator | Description | Example |
|---|---|---|
&& | Logical AND | {{$.a && $.b}} |
|| | Logical OR | {{$.a || $.b}} |
! | Logical NOT | {{!$.a}} |
String
| Operator | Description | Example |
|---|---|---|
+ | Concatenation | {{'Hello ' + $.name}} |
Operator Precedence
From highest to lowest:
()- Parentheses!- Unary NOT*,/,%- Multiplicative+,-- Additive>,<,>=,<=- Relational==,!=- Equality&&- Logical AND||- Logical OR? :- Ternary
Conditional (Ternary) Operator
condition ? valueIfTrue : valueIfFalseExamples:
{{$.active ? 'yes' : 'no'}}
{{$.count > 0 ? $.count : 0}}
{{$.type == 'admin' ? 'Full Access' : 'Limited'}}Function Calls
functionName(arg1, arg2, ...)Examples:
{{now()}}
{{RFC3339($.timestamp)}}
{{string($.count)}}
{{upper($.name)}}Expression Types
Pure Expressions (No Quotes)
Return typed values:
yaml
count: {{$.count}} # Returns number
active: {{$.isActive}} # Returns boolean
items: {{$.array}} # Returns array
user: {{$.data}} # Returns objectString Interpolation (With Quotes)
Always return strings:
yaml
countStr: "{{$.count}}" # Returns string "42"
message: "Hello {{$.name}}" # Returns string
url: "api/{{$.id}}/data" # Returns stringSpecial Cases
Default Values
{{$.value || 'default'}}
{{$.count || 0}}
{{$.items || []}}Null Coalescing
{{$.user != null ? $.user.name : 'Anonymous'}}String in Expression
Use single quotes for strings within expressions:
{{$.role == 'admin'}}
{{$.type != 'test'}}
{{'prefix_' + $.id}}Escaping
Literal Curly Braces
To output literal {{:
\{\{not an expression\}\}Quotes in Strings
"He said 'hello'"
'She said "hi"'
"Escaped \"quote\""Whitespace
Whitespace inside expressions is ignored:
{{ $.name }}
{{$.name}}
{{ $.count + 1 }}
{{$.count+1}}All equivalent.
Validation Rules
Valid Expressions
{{$}}
{{$.name}}
{{$.items[0]}}
{{$.a + $.b}}
{{$.active ? 'yes' : 'no'}}
{{now()}}Invalid Expressions
{{}} // Empty
{{.name}} // Missing $
{{$name}} // Missing dot
{{$.items[}} // Unclosed bracket
{{$.a +}} // Incomplete operationEdge Configuration Format
In edge configurations:
yaml
# Pure expression - type preserved
count: {{$.items.length}}
# Interpolated string
message: "Count is {{$.items.length}}"
# Static value
constant: 42
# Object construction
user:
id: "{{$.userId}}"
name: "{{$.userName}}"Quick Reference
| Pattern | Example | Result |
|---|---|---|
| Root | {{$}} | Entire input |
| Property | {{$.name}} | Property value |
| Nested | {{$.a.b.c}} | Deep property |
| Array index | {{$.arr[0]}} | First element |
| Negative index | {{$.arr[-1]}} | Last element |
| Bracket access | {{$['key']}} | Property by string |
| Dynamic key | {{$[$.key]}} | Property by variable |
| Addition | {{$.a + $.b}} | Sum |
| Comparison | {{$.a == 1}} | Boolean |
| Logical | {{$.a && $.b}} | Boolean |
| Ternary | {{$.a ? 1 : 2}} | Conditional |
| Function | {{now()}} | Function result |
| Default | {{$.x || 'default'}} | Fallback |
| Interpolation | "Hi {{$.n}}" | String |