Gathering detailed insights and metrics for @remy/node-jq
Gathering detailed insights and metrics for @remy/node-jq
Gathering detailed insights and metrics for @remy/node-jq
Gathering detailed insights and metrics for @remy/node-jq
npm install @remy/node-jq
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
216 Commits
3 Watching
4 Branches
1 Contributors
Updated on 09 Aug 2018
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-50%
1
Compared to previous week
Last month
-82.4%
6
Compared to previous month
Last year
-30.9%
311
Compared to previous year
node-jq is a wrapper for jq - a lightweight and flexible command-line JSON processor.
1npm install node-jq --save
Usually in your CLI with jq
you would run:
1jq ".abilities[].moves" bulbasaur.json
and you would get
1{ 2 "name": "heartgold-soulsilver", 3 "power": "10" 4} 5{ 6 "name": "platinum", 7 "power": "50" 8} 9{ 10 "name": "diamond-pearl", 11 "power": "99" 12}
With node-jq
you could run it programmatically and interact with the output as a JavaScript Object:
1const jq = require('node-jq') 2 3const filter = '.abilities[].moves' 4const jsonPath = '/path/to/bulbasaur.json' 5const options = {} 6 7jq.run(filter, jsonPath, options) 8 .then((output) => { 9 console.log(output) 10 /* 11 { 12 "name": "heartgold-soulsilver", 13 "power": "10" 14 }, 15 { 16 "name": "platinum", 17 "power": "50" 18 }, 19 { 20 "name": "diamond-pearl", 21 "power": "99" 22 } 23 */ 24 }) 25 .catch((err) => { 26 console.error(err) 27 // Something went wrong... 28 })
Description | Type | Values | Default |
---|---|---|---|
Type of input | string | 'file' , 'json' , 'string' | 'file' |
input: 'file'
Run the jq query against a JSON file.
1jq.run('.', '/path/to/file.json').then(console.log) 2// { 3// "foo": "bar" 4// }
input: 'file'
Run jq query against multiple JSON files.
1jq.run('.', ['/path/to/file.json','path/to/other_file.json']).then(console.log) 2// { 3// "foo": "bar" 4// } 5// { 6// "otherFoo": "andBar" 7// }
input: 'json'
Run the jq query against an Object.
1jq.run('.', { foo: 'bar' }, { input: 'json' }).then(console.log) 2// { 3// "foo": "bar" 4// }
input: 'string'
Run the jq query against a String.
1jq.run('.', '{ foo: "bar" }', { input: 'string' }).then(console.log) 2// { 3// "foo": "bar" 4// }
Description | Values | Default |
---|---|---|
Type of output | 'pretty' , 'json' , 'compact' , 'string' | 'pretty' |
output: 'pretty'
Return the output as a String.
1jq.run('.', '/path/to/file.json', { output: 'string' }).then(console.log) 2// { 3// "foo": "bar" 4// }
output: 'json'
Return the output as an Object.
1jq.run('.', '/path/to/file.json', { output: 'json' }).then(console.log) 2// { foo: 'bar' }
output: 'compact'|'string'
Return the output as a String.
1jq.run('.', '/path/to/file.json', { output: 'compact' }).then(console.log) 2// {"foo":"bar"} 3jq.run('.', '/path/to/file.json', { output: 'string' }).then(console.log) 4// {"foo":"bar"}
Description | Values | Default |
---|---|---|
Read input stream into array | true , false | false |
slurp: true
Read input stream into array.
1jq.run('.', ['/path/to/file.json','/path/to/other_file.json'], { output: 'json', slurp: true }).then(console.log) 2// [ 3// { 4// "foo": "bar" 5// }, 6// { 7// "otherFoo": "andBar" 8// } 9// ]
Description | Values | Default |
---|---|---|
Sort object keys in alphabetical order | true , false | false |
sort: true
Sorts object keys alphabetically.
1jq.run('.', ['/path/to/file.json'], { output: 'json', sort: true }).then(console.log) 2// { 3// "a": 2, 4// "b": 1 5// },
Why would you want to manipulate JavaScript Objects with jq
syntax in a node app, when there are tools like lodash?
The idea was to port jq
in node to be able to run it as-is. node-jq
doesn't try to replace Object
filters, maps, or transformations.
Our primary goal was to make jq
syntax available in Atom with atom-jq.
Other than that, jq
is an interesting CLI tool to quickly parse the response of an API, such as:
1curl 'https://jsonplaceholder.typicode.com/comments' | jq '.[].postId'
There are also people dealing with complex responses:
jq
?Seems hard to learn, but it really isn't.
jq
is like sed
for JSON
. Slice, filter, map and transform structured data in a simple and powerful way.
Take a look at this great introduction or a jq lesson.
You can check out the official manual and fiddle around in the online playground jqplay.org.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
107 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More