All Projects → mwh → jqjs

mwh / jqjs

Licence: MIT license
Pure-JavaScript implementation of the jq JSON query language

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Labels

Projects that are alternatives of or similar to jqjs

Jqaas
jq as a service
Stars: ✭ 22 (-43.59%)
Mutual labels:  jq
Pyjq
A Python binding for ./jq
Stars: ✭ 133 (+241.03%)
Mutual labels:  jq
Jq Web
jq in the browser with emscripten.
Stars: ✭ 188 (+382.05%)
Mutual labels:  jq
Jq Mode
Emacs major mode for editing jq queries.
Stars: ✭ 70 (+79.49%)
Mutual labels:  jq
Jqr
R interface to jq
Stars: ✭ 123 (+215.38%)
Mutual labels:  jq
Json Splora
GUI for editing, visualizing, and manipulating JSON data
Stars: ✭ 1,818 (+4561.54%)
Mutual labels:  jq
Jqplay
A playground for jq, written in Go
Stars: ✭ 444 (+1038.46%)
Mutual labels:  jq
ycat
Command line processor for YAML/JSON files using Jsonnet
Stars: ✭ 21 (-46.15%)
Mutual labels:  jq
Oq
A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
Stars: ✭ 132 (+238.46%)
Mutual labels:  jq
Emuto
manipulate JSON files
Stars: ✭ 180 (+361.54%)
Mutual labels:  jq
Okurl
OkHttp Kotlin command line
Stars: ✭ 77 (+97.44%)
Mutual labels:  jq
Yq
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
Stars: ✭ 1,688 (+4228.21%)
Mutual labels:  jq
Tmux 1password
🔑 Access your 1Password login items within tmux!
Stars: ✭ 167 (+328.21%)
Mutual labels:  jq
Java Jq
Lightweight Java wrapper around JQ, a flexible JSON processor available for multiple platforms
Stars: ✭ 37 (-5.13%)
Mutual labels:  jq
jq-tutorial
Interactive exercises for learning jq
Stars: ✭ 109 (+179.49%)
Mutual labels:  jq
Aws
A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.
Stars: ✭ 493 (+1164.1%)
Mutual labels:  jq
Node Jq
Node.js wrapper for jq
Stars: ✭ 147 (+276.92%)
Mutual labels:  jq
json to paths
Distill a JSON document into a collection of paths both for 'jq' and 'xpath'
Stars: ✭ 65 (+66.67%)
Mutual labels:  jq
jsqry-cli2
Small CLI tool (similar to jq) to query JSON using sane DSL
Stars: ✭ 21 (-46.15%)
Mutual labels:  jq
Jackson Jq
jq for Jackson Java JSON Processor
Stars: ✭ 178 (+356.41%)
Mutual labels:  jq

jqjs is a JavaScript implementation of the jq query language. It implements the core language features in pure JavaScript.

The main entry point to jqjs is the compile function, which turns a jq program string into a generator function:

import jq from './jq.js'
let filter = jq.compile(".x[].y")
for (let v of filter({x:[{y:2}, {y:4}]}) { ... }

The module also has a prettyPrint function for rendering an object to text.

Features

jqjs supports most of the core jq language features, but lacks functions and some of the advanced functionality. It also uses JavaScript strings as backing, so does not have jq proper's Unicode support.

  • Identity: .
  • Object Identifier-Index: .foo, .foo.bar
  • Generic Object Index: .[<string>]
  • Array Index: .[2]
  • Array/String Slice: .[10:15]
  • Array/Object Value Iterator: .[]
  • Comma: ,
  • Pipe: |
  • Parentheses: (...)
  • Array Construction: [...]
  • Object Construction: { ... } including shorthand { user, title } and computed keys { (.x): true }
  • Recursive Descent: ..
  • Addition, subtraction, multiplication, division, and modulo, including the overloaded type operations.
  • Named functions
    • Built-in functions
      • tostring, tonumber, path, length, keys, has, in, type, del
      • empty, select, arrays, objects, booleans, numbers, strings, nulls
      • map, map_values, add, sort, sort_by, explode, implode, split, join
      • to_entries, from_entries, with_entries
      • range/1, range/2, range/3
      • any/0, any/1, any/2, all/0, all/1, all/2
      • contains, inside
      • the others
    • User-defined functions
    • Mathematical functions
  • String interpolation: \(foo)
  • Format strings and escaping: @text, @json, @html, @uri, @csv, @tsv, @sh, @base64, @base64d
    • Format interpolations: @uri "https://google.com/search?q=\(.x)"
  • Equality checks: ==, !=
  • Comparisons: <, >, <=, >=
    • Correct sorting order for unequal types (null < 7, [] < {})
  • Conditionals: if A then B else C
  • Alternative operator: //
  • Try-catch: try EXP catch EXP
    • Error Suppression operator ?
  • Regular expressions
  • Variable/Symbolic Binding Operator ... as $identifier | ...
  • Reduce: reduce .[] as $item (0; . + $item)
  • foreach: foreach .[] as $item (...;...;...)
  • Recursion: recurse(.children[])
  • I/O (unlikely to make sense here)
  • Update-assignment: .posts[].comments |= . + ["Another"]
  • Arithmetic update-assignment: +=, -=, *=, /=, %=, //=
  • Plain assignment: (.a,.b) = range(2)
  • Modules with import and include

Performance

Not great.

The intention is to be semantically correct first and to have clear code second. Performance improvements sit after that, if at all. Executing a program may reëvaluate parts of it or traverse the object multiple times where that makes things simpler, and internally evaluation happens by tree-walking the input syntax.

Demonstration

demo.html is a live demo of how to use jqjs that lets you enter a jq program and an input JSON value and see the output JSON values it produces.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].