Expr Lang playground
The playground evaluates Expr 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 . 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 . The expression gets the variables of schema for the creation of the element:
operation(create),elementType,document(the data without internal properties),previous(empty),changes,user({"id": null}) andfile(null). Values of geo properties are GeoJSON, as in rules; request them withPrefer: geometry=geojson, which is the default. - Raw JSON: a JSON object whose members are the variables, like the
parametersof search .
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 withexpression.timeoutInMilliseconds, see . - The search function
sleepis 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 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 .
- Rules see the exact numbers of the schema: properties of the type
numberare floats, also whole ones. The playground reads the input with the JSON parser of the browser, which does not keep the difference between52and52.0: whole numbers are integers, also when written as52.0, so e.g.type(document.latitude)returnsintinstead offloat.