Setting the file. One moment.
Subchapter 2.2
references/grammar.mdMarkdown4 KBView on GitHub
The mapping language uses Extended Backus-Naur Form (EBNF) to describe the complete JSONSelection grammar.
JSONSelection ::= NamedSelection*
SubSelection ::= "{" NamedSelection* "}"
NamedSelection ::= (Alias | "...")? PathSelection | Alias SubSelection
Alias ::= Key ":"
PathSelection ::= Path SubSelection?
VarPath ::= "$" (NO_SPACE Identifier)? PathTail
KeyPath ::= Key PathTail
AtPath ::= "@" PathTail
ExprPath ::= "$(" LitExpr ")" PathTail
PathTail ::= "?"? (PathStep "?"?)*
NonEmptyPathTail ::= "?"? (PathStep "?"?)+ | "?"
PathStep ::= "." Key | "->" Identifier MethodArgs?
Key ::= Identifier | LitString
Identifier ::= [a-zA-Z_] NO_SPACE [0-9a-zA-Z_]*
MethodArgs ::= "(" (LitExpr ("," LitExpr)* ","?)? ")"
LitExpr ::= LitOpChain | LitPath | LitPrimitive | LitObject | LitArray | PathSelection
LitOpChain ::= LitExpr (LitOp LitExpr)+
LitOp ::= "??" | "?!"
LitPath ::= (LitPrimitive | LitObject | LitArray) NonEmptyPathTail
LitPrimitive ::= LitString | LitNumber | "true" | "false" | "null"
LitString ::= "'" ("\\'" | [^'])* "'" | '"' ('\\"' | [^"])* '"'
LitNumber ::= "-"? ([0-9]+ ("." [0-9]*)? | "." [0-9]+)
LitObject ::= "{" (LitProperty ("," LitProperty)* ","?)? "}"
LitProperty ::= Key ":" LitExpr
LitArray ::= "[" (LitExpr ("," LitExpr)* ","?)? "]"
NO_SPACE ::= !SpacesOrComments
SpacesOrComments ::= (Spaces | Comment)+
Spaces ::= (" " | "\t" | "\r" | "\n")+
Comment ::= "#" [^\n]*# Direct field selection
id
name
email
# Field aliasing (when renaming)
firstName: name.first
lastName: name.last# Array sub-selection
$.results {
id
name
}
# Nested sub-selection
user {
profile {
avatar
}
}
# First item from array
$.items->first {
id
title
}# Chain methods with ->
name->slice(0, 10)
items->filter(@.active)->first
numbers->map(@->mul(2))# Dot notation for nested fields
user.profile.name
# Optional chaining with ?
user?.profile?.name
# Variable paths
$args.id
$this.userId
$batch.id# Must use $() wrapper
$(1)
$(true)
$("hello")
$({"key": "value"})
$([1, 2, 3])
# Literal with method
$([a, b, c])->joinNotNull(',')# Null coalescing (fallback for null or undefined)
name ?? "Unknown"
# Undefined coalescing (fallback only for undefined, preserves null)
value ?! "default"# WRONG - No + operator
fullName: firstName + " " + lastName
# CORRECT - Use joinNotNull
fullName: $([firstName, lastName])->joinNotNull(' ')# WRONG - No bracket indexing
firstItem: items[0]
# CORRECT - Use methods
firstItem: items->first
thirdItem: items->get(2)
slice: items->slice(0, 3)# WRONG - Missing $() wrapper
body: "{ a: $args.a }"
# CORRECT - Use $() for literal objects
body: "$({ a: $args.a })"# WRONG - No == operator
isActive: status == "active"
# CORRECT - Use eq method
isActive: status->eq("active")# WRONG - No ternary operator
result: condition ? a : b
# CORRECT - Use ?? or ?! operators
result: value ?? "default"
result: value ?! "fallback"# WRONG - Unnecessary when selecting from root
$ {
id
name
}
# CORRECT - Direct field selection
id
name