Skip to main content
Version: 1.0.0

Expressions

Expressions calculate values inside projections, function calls, and conditions.

Addition follows JavaScript

+ adds numbers or concatenates strings. For example, '3' + 2 produces '32', while '3' - 2 produces 1.

Arithmetic operators

OperatorOperation
+Addition or JavaScript string concatenation.
-Subtraction.
*Multiplication.
/Division.
unary -Negation.
select {
subtotal: price * quantity,
total: price * quantity + shipping,
refund: -amount
} from 'orders.json'

Precedence

JQL evaluates expressions in this order:

  1. Parentheses
  2. Unary minus
  3. Multiplication and division
  4. Addition and subtraction
select {
first: price + tax * quantity,
second: (price + tax) * quantity
} from 'orders.json'

Operators at the same level are evaluated from left to right.

Value conversion

Arithmetic follows JavaScript conversion rules. Subtraction, multiplication, division, and unary minus convert their operands with Number(...). Numeric strings can therefore participate in calculations.