
Research
/Security News
DuckDB npm Account Compromised in Continuing Supply Chain Attack
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
@2017takeda/jt-cli
Advanced tools
jt
is a powerful command-line tool for querying and transforming JSON data using JSONata, a lightweight query and transformation language for JSON.
npm install -g @2017takeda/jt-cli
brew install jt
# Query from file
jt '<jsonata-expression>' input.json
# Query from stdin
cat data.json | jt '<jsonata-expression>'
# With explicit input format
jt -i yaml '<jsonata-expression>' data.yaml
# Format conversion without JSONata query (new!)
jt data.json -o yaml
cat data.yaml | jt -c
The JSONata expression is now optional. When omitted, jt
acts as a format converter, parsing the input and outputting it in the specified format.
# Convert JSON to YAML
jt data.json -o yaml
# Convert YAML to JSON
jt config.yaml -o json
# Convert JSON to compact format
cat data.json | jt -c
# Convert JSON Lines to YAML
jt events.jsonl -o yaml
# Extract all names from an array of objects
echo '[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]' | jt '$.name'
# Output: ["Alice", "Bob"]
# Filter objects where age > 25
echo '[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]' | jt '$[age > 25]'
# Output: [{"name": "Alice", "age": 30}]
# Transform data structure
echo '{"users": [{"first": "John", "last": "Doe"}]}' | jt 'users.{"fullName": first & " " & last}'
# Output: [{"fullName": "John Doe"}]
# Sum all values
echo '[{"value": 10}, {"value": 20}, {"value": 30}]' | jt '$sum(value)'
# Output: 60
jt
supports multiple input formats:
-i yaml
or --input yaml
)-i jsonl
or --input jsonl
)-i csv
or --input csv
)# YAML input
jt -i yaml '$.users.name' config.yaml
# JSON Lines input
jt -i jsonl '$.event' events.jsonl
# CSV input
jt -i csv '$[age > 25]' users.csv
Control output formatting with the -o
or --output
option:
-c
or --compact
flag for minified JSON# Compact JSON output
jt -c '$.users' data.json
# YAML output
jt -o yaml '$.config' settings.json
# CSV output (for arrays of objects)
jt -o csv '$' users.json
Use the -r
or --raw-string
flag to output raw strings without quotes:
# Extract string value without quotes
echo '{"name": "Alice", "age": 30}' | jt -r '$.name'
# Output: Alice (instead of "Alice")
# Works with numbers and booleans too
echo '{"count": 42, "active": true}' | jt -r '$.count'
# Output: 42 (as string)
# Multiline strings are output with actual newlines
echo '{"text": "Line 1\nLine 2"}' | jt -r '$.text'
# Output:
# Line 1
# Line 2
# Arrays and objects are still output as JSON
echo '{"list": [1, 2, 3]}' | jt -r '$.list'
# Output: [1, 2, 3]
This option is useful for:
jq -r
for those familiar with that tool# String manipulation
echo '{"name": "john doe"}' | jt '{"name": $uppercase(name)}'
# Output: {"name": "JOHN DOE"}
# Date handling
echo '{"date": "2023-12-01"}' | jt '{"year": $substring(date, 0, 4)}'
# Output: {"year": "2023"}
# Group and aggregate
echo '[{"dept": "sales", "salary": 50000}, {"dept": "sales", "salary": 60000}]' | \
jt 'dept{dept: $sum(salary)}'
# Output: {"sales": 110000}
JSONata is a powerful query language designed specifically for JSON. Key features include:
$.users[0].name
$.users[age > 21]
$.users.{"fullName": firstName & " " & lastName}
$sum($.items.price)
$uppercase()
, $substring()
, $now()
, etc.For complete JSONata documentation, visit jsonata.org.
jt
provides clear, actionable error messages:
# Invalid JSON input
echo '{invalid}' | jt '$'
# Error: Invalid JSON input at position 1: Unexpected token 'i'
# Invalid JSONata expression
echo '{}' | jt '$undefined('
# Error: Invalid JSONata expression: Unexpected token '(' at position 11
# Clone repository
git clone https://github.com/TAKEDA-Takashi/jt-cli.git
cd jt-cli
# Use the recommended Node.js version (if using nvm)
nvm use # This will use the version specified in .nvmrc (Node.js 24)
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
This project follows Test-Driven Development (TDD) practices:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run with coverage
npm run test:coverage
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature
)git commit -m 'feat: add amazing feature'
)git push origin feature/amazing-feature
)This project uses CODEOWNERS to define responsibilities for different parts of the codebase. Code owners are automatically requested for review when pull requests modify files they own.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
JSONata query and transformation tool for the command line
We found that @2017takeda/jt-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socketβs new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.