Skip to main content

Expr Lang playground

The playground evaluates Expr Lang expressions in the browser. It runs the same code as the API, compiled to WebAssembly: the same version of Expr Lang, the same handling of numbers and the same functions, including the geo functions. Nothing is sent to a server.

Unlike the API, the playground uses the input as written: geo values written as WKT stay strings, while rules in the API always get GeoJSON, and whole numbers are integers, also when written as 52.0. A rule can therefore behave differently here, seedifferences to the API.

Runs on every change, Ctrl+Enter runs as well.
OutputLoading the engine…
Variables of the expression

Input types

  • Element: paste an element as the API returns it, e.g. the response of GET /<uuid>. The expression gets the variables of schema rules for the creation of the element: operation (create), elementType, document (the data without internal properties), previous (empty), changes, user ({"id": null}) and file (null). Values of geo properties are GeoJSON, as in rules; request them with Prefer: geometry=geojson, which is the default.
  • Raw JSON: a JSON object whose members are the variables, like the parameters of search expressions.

JSON files can be loaded with the button or dropped onto the input. Copy link puts the expression and the input into the address, so that it can be shared; the examples of the Expr pages open the playground this way.

Differences to the API

  • Evaluations are stopped after 3 seconds. Expr Lang has no loops, and its memory budget stops expressions which allocate too much, but nested closures over lists, e.g. all(list, {all(list, {all(list, {true})})}) for a long list, can run for a long time. The API limits the runtime of expressions with expression.timeoutInMilliseconds, see configuration.
  • The search function sleep is not available, and the limit of positions per call of a geo function is the default of 1,000.
  • The input is used as written. The API turns values of geo properties which were written as WKT into GeoJSON before rules see them; in the playground, a WKT string stays a string, and the geo functions fail on it. Write geo values as GeoJSON, or convert them in the expression with geoFromWkt.
  • Rules see the exact numbers of the schema: properties of the type number are floats, also whole ones. The playground reads the input with the JSON parser of the browser, which does not keep the difference between 52 and 52.0: whole numbers are integers, also when written as 52.0, so e.g. type(document.latitude) returns int instead of float.