Get started with JSON Toolbox in 5 minutes.
npm install -g @mackan_eu/json-toolbox
Or use npx without installing:
npx @mackan_eu/json-toolbox exec json.format < data.json
echo '{"name":"Alice","age":30}' | json-toolbox exec json.format
Output:
{
"name": "Alice",
"age": 30
}
cat data.csv | json-toolbox exec csv.parse --header true
Input (data.csv):
name,age,city
Alice,30,Stockholm
Bob,25,Gothenburg
Output:
[
{"name": "Alice", "age": "30", "city": "Stockholm"},
{"name": "Bob", "age": "25", "city": "Gothenburg"}
]
cat > my-pipeline.json << 'EOF'
{
"name": "csv-to-sorted-json",
"version": "1.0.0",
"steps": [
{ "operator": "csv.parse", "params": { "header": true } },
{ "operator": "transform.sort", "params": { "key": "name" } },
{ "operator": "json.stringify", "params": { "indent": 2 } }
]
}
EOF
json-toolbox run my-pipeline.json < data.csv > output.json