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!
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} │ └─────────────────────────────────────────────────┘
That’s actually great to query JSON with SQL! But as you can see the example from DuckDB is quite complex and unreadable as well.
And I have made this project for learning purpose and to challenge myself.
However, Thanks for sharing the project.