minus-square_Vi@programming.devtoProgramming@programming.dev•JQLite - The query language for JSONlinkfedilinkarrow-up5·edit-219 days agoAt 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} │ └─────────────────────────────────────────────────┘ linkfedilink
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} │ └─────────────────────────────────────────────────┘