# `Jexata`
[🔗](https://github.com/Manuel1471/Jexata/blob/main/lib/jexata.ex#L1)

Compile JSONata expressions and evaluate them against native Elixir values.

See `README.md` and `docs/COMPATIBILITY.md` for supported syntax and known gaps.

# `input`

```elixir
@type input() :: json() | :undefined
```

# `json`

```elixir
@type json() ::
  nil
  | boolean()
  | number()
  | String.t()
  | [json()]
  | %{optional(String.t()) =&gt; json()}
```

# `result`

```elixir
@type result() :: json() | :undefined | :function
```

# `compile`

```elixir
@spec compile(String.t(), keyword()) ::
  {:ok, Jexata.Expression.t()} | {:error, Jexata.Error.t()}
```

Compiles a JSONata source string into an immutable expression.

  `max_source_bytes`, `max_tokens`, and `max_nesting` may be set as positive integers.
  

# `compile!`

```elixir
@spec compile!(String.t()) :: Jexata.Expression.t()
```

Like `compile/1`, but raises on errors.

# `evaluate`

```elixir
@spec evaluate(Jexata.Expression.t(), input()) ::
  {:ok, result()} | {:error, Jexata.Error.t()}
```

Evaluates a compiled expression against JSON-like Elixir data.

# `evaluate`

```elixir
@spec evaluate(Jexata.Expression.t(), input(), map()) ::
  {:ok, result()} | {:error, Jexata.Error.t()}
```

Evaluates a compiled expression with external variable bindings.

  Binding keys are variable names without the leading `$`, and values are JSON-like Elixir data.
  

# `evaluate`

```elixir
@spec evaluate(Jexata.Expression.t(), input(), map(), keyword()) ::
  {:ok, result()} | {:error, Jexata.Error.t()}
```

Evaluates with a positive `:max_function_depth` limit for recursive calls.

# `evaluate!`

```elixir
@spec evaluate!(Jexata.Expression.t(), input()) :: result()
```

Like `evaluate/2`, but raises on errors.

# `evaluate_bounded`

```elixir
@spec evaluate_bounded(Jexata.Expression.t(), input(), keyword()) ::
  {:ok, result()} | {:error, Jexata.Error.t()}
```

Evaluates in a separate BEAM process with time, heap, reductions, and result-size limits.

Options are `:timeout_ms` (default 1000), `:max_heap_words` (default 1,000,000),
`:max_result_bytes` (default 1,000,000), `:max_reductions` (disabled by default),
`:max_function_depth` (default 1024),
`:regex_match_limit` (default 100,000), `:regex_recursion_limit` (default 10,000),
and `:bindings` (default `%{}`). The result-size limit uses Erlang external-term
size as an estimate; it is not a JSON byte count. The process heap includes
the copied input and bindings. A separate watcher enforces the timeout even
if the caller exits. The optional reduction budget counts BEAM reductions,
including worker setup, and is checked when work completes and periodically
while it runs. It is not an exact JSONata step count.

# `run`

```elixir
@spec run(String.t(), input()) :: {:ok, result()} | {:error, Jexata.Error.t()}
```

Compiles and evaluates a JSONata expression in one call.

# `run`

```elixir
@spec run(String.t(), input(), map()) :: {:ok, result()} | {:error, Jexata.Error.t()}
```

Compiles and evaluates an expression with external variable bindings.

# `run`

```elixir
@spec run(String.t(), input(), map(), keyword()) ::
  {:ok, result()} | {:error, Jexata.Error.t()}
```

Compiles and evaluates with external bindings and evaluation options.

# `run!`

```elixir
@spec run!(String.t(), input()) :: result()
```

Like `run/2`, but raises on errors.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
