JQLite

JQLite - The query language for JSON

Created a simple query language in Typescript,

however this is not any replacement for existing tools, but a side/learning project.

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 name of all the products which has a price greater than 1500

$.products[?(@.price > 1500)][*].name

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

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

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

30 points · 4 comments · view on lemmy.world

4 Comments

HelloRoot@lemy.lol · 10 pts · 1y (1 reply)

I prefer the native js/ts approach that is readable by humans and doesn't need an extra dependency:

const result = data.products
  .filter(p => p.price > 1500)
  .map(p => p.name);
eager_eagle@lemmy.world · 2 pts · 1y

Forget the dependency, I don't want another language in my code.

ptman@sopuli.xyz · 4 pts · 1y (1 reply)

There exists JSONPath

sxan@midwest.social · 2 pts · 1y

Yeah, but the implementations are really sparse. JQuery sucked all of the air out of the room.

I much prefer JSONPath, although it's a little rough in some areas where JSON's design doesn't align 1:1 with XML and XPath.

Do you use it? Is there a good CLI tool for it? Every few years I get mighty sick of jq and go looking for an alternative, and I haven't found a good JSONPath implementation yet.