59
submitted 21 hours ago* (last edited 16 hours ago) by jay0072007@programming.dev to c/programming@programming.dev

Created a simple query language for JSON data.

Features:

  • Basic query selection
  • Fallback Mechanism
  • Wildcard support
  • Array Slices
  • Multiple Key Selection
  • Key Omission
  • Single Key Omission
  • Functions
  • Comparison Operators
  • Conditions
  • Configurable

Here's an example to get the list of adult friends:

$.friends[?(@.age >= 18)]

Runs in browsers, and Node.js

Documentation site: https://jqlite.vercel.app/

GitHub: https://github.com/Jay-Karia/jqlite

NPM Package: https://www.npmjs.com/package/jqlite-ts

⭐ Leaving a star on GitHub is much appreciated!

top 11 comments
sorted by: hot top controversial new old
[-] footfaults@lemmygrad.ml 1 points 58 minutes ago

But what about all those hours I spent torturing myself learning jq's filter syntax, and jmespath ?

[-] _Vi@programming.dev 5 points 14 hours ago* (last edited 14 hours ago)

At first I thought that it is like SQLite, but for JSON, not just "JQ-lite".


Speaking of JSON and queries, it is worth to mention DuckDB's JSON features. This allows you to use actual SQL to query JSON.

Here is example of a DuckDB analogue of $.orders[?(@.status.#equals('delivered'))][*].items from JQLite documentation:

duckdb -c "from (from demo.json select unnest(orders)->>'status' as status, cast(unnest(orders)->'items' as json[]) as items) select unnest(items) as delivered_items where status='delivered'"

┌─────────────────────────────────────────────────┐
│                 delivered_items                 │
│                      json                       │
├─────────────────────────────────────────────────┤
│ {"productId":"p1","quantity":1,"price":1299.99} │
│ {"productId":"p2","quantity":2,"price":1599.99} │
└─────────────────────────────────────────────────┘
[-] Azzu@lemm.ee 7 points 18 hours ago

https://jqlang.org/

I've been using that for all my JSON extraction and processing needs. Let me automate a bunch of my builds for JS stuff for FoundryVTT https://gitlab.com/foundry-azzurite/pings/-/blob/master/build/build.sh

[-] jay0072007@programming.dev 5 points 17 hours ago

Thanks for sharing the project! JQLite is aimed to run in browsers and node, but will definitely take inspiration from "jq".

[-] Azzu@lemm.ee 12 points 17 hours ago* (last edited 17 hours ago)

I just kinda wonder why when you're in a browser or node, you wouldn't just do

const json = {...};
json.friends.filter(f => f.age >= 18);

why learn another language when you already literally got the language to process JavaScript Object Notation right there.

[-] jay0072007@programming.dev 9 points 16 hours ago

100% agreed. It's just a learning/hobby project, to know more about parsers, and how languages work. Some of the features like Wildcard, Multiple key selection/omission comes handy, and might add more features like that.

[-] Azzu@lemm.ee 5 points 15 hours ago

Totally fair. Sounds fun :)

[-] SchwertImStein@lemmy.dbzer0.com 3 points 19 hours ago
[-] jay0072007@programming.dev 5 points 17 hours ago

That's a great project! JQLite is mainly focused on query-style approach. Also it's a hobby project for learning parsers and stuff.

[-] Thorry84@feddit.nl 3 points 19 hours ago

You might want to look into using some form of parameterized queries.

[-] jay0072007@programming.dev 3 points 18 hours ago

Thanks for your suggestion! It's definitely something I'll look into.

this post was submitted on 11 May 2025
59 points (92.8% liked)

Programming

20090 readers
94 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS