Skip to main content

JSONata

· 2 min read
Eduardo Marques

Hi all!

For any REST API, operations like querying, sorting, filtering are a must have. In the beginning I assumed that it was good enough for the client to fetch all the data, and perform these operations on their side. This was good enough for a PoC or a PET project, but far from ideal for a production application, not only because of the size of the data transferred, but also had security implications, as some sensitive data could be exposed.

I wondered for a while what would be the best and quickest solution for this. Implementing all of this came through my head, but then I thought, this is a common problem and I'm sure there are existing solutions for this.

I was right! I came across JSONata, a really powerful library that did everything what I was looking for and more!

All I had to do was add support for JSONata expressions for GET requests and it worked perfectly.

How does it work? GET requests accept a new parameter called jsonata that accepts encoded JSONata expressions.

If you want to take full advantage of this library check out the official documentation on their page, or, to get started quickly, check the READ (GET) documentation and the JSONata documentation.

I hope you find these expressions useful. If you have any questions don't hesitate to reach out, after all, feedback is what makes any product great!

Take care and until the next one!