ManuelGarcia
Hi everyone!
I originally started using JSONata for a few dynamic JSON evaluations in pipelines at work. The expressions were useful, but the supporting code gradually grew beyond those initial cases. I organized it into a standalone Elixir library, added tests and documentation, and published it in case it helps someone with a similar problem.
Jexata compiles JSONata expressions and evaluates them against Elixir maps and lists. A small example:
data = %{
"orders" => [
%{"product" => "Book", "price" => 20},
%{"product" => "Pen", "price" => 30}
]
}
{:ok, 50} = Jexata.run("$sum(orders.price)", data)
For expressions used repeatedly, you can compile once and evaluate them against different documents.
Version 1.0.0 supports paths, predicates, grouping, sorting, higher-order functions, regex, date and number formatting, and immutable transforms. It also offers bounded evaluation for expressions supplied by users, with configurable time and resource limits.
Why I built it
My use case was transforming data that was already in memory: JSON payloads moving through pipelines, where the expression could vary without changing the Elixir code around it. I wanted a reusable way to select fields, filter records, aggregate values, and build new documents.
Jexata is written in Elixir and does not need a JavaScript runtime in production. It also works alongside tools such as Ecto: I would still use the database to filter or aggregate large tables, then use Jexata when I need to transform the resulting document.
Compatibility and performance
I tested version 1.0.0 against the JSONata.js v2.2.0 reference suite: 1,676 of 1,679 cases pass. The three remaining differences involve the order of keys in input objects, since native Elixir maps do not retain JSON source order. I’ve documented that limitation rather than presenting the library as a perfect drop-in replacement.
I also compared 64 expressions with JSONata.js, checking results before comparing timings. Results matched for 63 expressions; on that recorded Apple Silicon run, Jexata had a lower median time in 61 of those 63. For example, filtering 1,000 orders took about 109 µs with Jexata and 791 µs with JSONata.js in that benchmark. These are measurements of the public APIs on one machine, not a general performance guarantee; short JavaScript evaluations also include its async API cost.
Try it
defp deps do
[{:jexata, "~> 1.0"}]
end
This began as a practical tool for my own pipelines. I’d love to hear whether it fits any of your use cases, and especially where the API or documentation could be clearer.
You can find the package on Hex. The benchmark report includes the exact workloads, timing ranges, and methodology. The README in the repository has more examples, from simple paths to larger transformations.
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #security
- #elixirconf-eu
- #api
- #forms
- #performance









