Skip to main content
An expression is anything that produces a value: a literal, a variable, a property or element access, an operator applied to other expressions, or a resource function call. Use parentheses to group expressions.

Object and list literals

Object literals list key: value pairs in curly braces. List literals list values in square brackets. Both can be nested and both allow a trailing comma.
  • Object keys are bare identifiers. Quoted keys such as "brand": "Honda" aren’t supported.
  • Keys must be unique within a single object literal.
  • Values can be any expression, including variables and calculations: { total: price * quantity }.

String interpolation

Inside a string, ${expression} evaluates any expression and inserts the result:
Interpolated expressions can contain strings with their own interpolations: "a ${"b ${c}"}". Values are rendered as follows: To include a literal ${ in a string, escape the dollar sign: "Price: \${amount}".

Reading object properties

Use dot notation to read a property:
  • Reading a property that doesn’t exist returns null. It isn’t an error.
  • Reading a property of anything other than an object, such as a string or null, is an error.
Because a missing property is null, you can check whether an object has a value with != null:

Reading list elements

Use square brackets with a zero-based index to read a list element:
  • The index must be an integer.
  • An index outside the list is an error, for example List index 3 is out of bounds (list has 3 items).
Access can be chained: orders[0].items[2].price.

Not available

RequestScript is deliberately small. It has no built-in functions or methods, so there’s no way to get the length of a list or string, and no loops to iterate over a list. Logic that needs these is a good fit for a resource.