bettio
I am pleased to announce an initial release ExJSONPath.
ExJsonPath is an Elixir library which allows to query maps (JSON objects) and lists (JSON arrays), using JSONPath expressions.
We decided to implement ExJSONPath while working on Astarte Flow, since we wanted to allow users to query arbitrary JSON objects from their pipelines code.
ExJsonPath allows to query deserialized JSON files [1] using expressions similar to the following:
ExJsonPath.eval(store, "$.store.book[?(@.price > 20)].title")
{:ok, ["The Lord of the Rings"]}
ExJsonPath is not tied to JSON at all, the same kind of JSONPath expression can be used on any Elixir map or list.
Right now, the only hard requirement is that keys must be strings.
Hope you’ll find this useful ![]()
Let me know if you have any request/question/feedback.
[1]:
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
Trending in Announcing
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
New
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application.
This library uses Erlang esaml to provide
plug enabl...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly.
One of i...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Other Trending Topics
I am seeing a lot of aplications of Argumentum ad Vericundiam in software discussions. They do link some piece of writing and point us to...
New
Hey folks,
I just published a post about Hologram’s funding and where the project goes next - the short version:
Curiosum as Main Spons...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
I was thinking since Goatmire Elixir turned out pretty good I should maybe do another one. 30th of Sep - 2nd of Oct this year./
The firs...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #graphql
- #elixirconf-us
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
Looks interesting. I took a quick look at the code and it seems you’re recursing the structure manually. I’m wondering if it would make sense to convert to an
Accesspattern instead, so it could be used withget_in,put_in, … all by implementing one transformation from the JSONPath format to a list ofAccessaccessors.bettio
Thanks for the feedback
I’ll try to focus on your advice as soon as I finished writing more tests. I need to write them since JSONPath is not “strongly specified” so I want to ensure a consistent (and stable) behaviour across different library releases.
gregvaughn
Is JSONPath widely used in general? I first encountered it in some other libraries as I was doing some background search before writing my first library, path_express, which more closely adheres to
Kernel.get_in/2. I’ve used xpath before and I assume some equivalent ideas. I’m on the fence on whether my library should be more or less JSON focused instead ofget_infocused. I hope your insight can help in my decisions.bettio
I know there are several software around that use it (e.g. kubectl).
The syntax is quite well known and there are tutorials, several tools (that allows users to test their expressions) and libraries in several languages.
So it was my first choice since it doesn’t require people to learn a new syntax.
I think you should focus your library to a specific use-case, my use-case was to allow people to write JSON templates and pipelines for arbitrary JSON inputs. As a side effect several kind of maps and lists are now supported by my JSONPath library.
I think I will add support to protocols and funs so I can extend my library to use-cases outside JSON.
koolquark
Hi,
Is there any support for regex matching in filter expressions ?