Examples
Print the help message
jstr --help
Print file content (single line)
jstr package.json
Print file content (with spaces)
jstr -s 2 package.json # 2 spaces
Copy file content
jstr -c package.json
Omit output fields
jstr -o name,version package.json
Map output fields
jstr -m '{"name":"foo"}' package.json
Print value of key using the callback parser
jstr package.json 'x => x.name'
Multi-line parser callback
jstr package.json "
function capitalize({ name }) {
const head = name.charAt(0)
const tail = name.slice(1)
return head.toUpperCase() + tail
}
"
Asynchronous parser callback
jstr package.json "async x => x.name"
Using ts-belt
jstr package.json "D.get('name')"
Reading from a piped command
echo '{"name":"foo"}' | jstr -i 'x => x.name'
Generating a CSV file
jstr users.json "flow(A.map(D.get('friends')), A.flat)" --csv > users.csv
Creating a text file using data from the JSON input
echo '{"name":"foo"}' | jstr -i "D.get('name')" > name.txt
Last updated