Dasel
What is Dasel?
Dasel is a powerful command-line interface (CLI) tool designed for querying and updating data structures. It supports various formats including JSON, YAML, TOML, and XML, making it an indispensable utility for developers working with configuration files, APIs, and data manipulation tasks. Dasel allows you to easily select, modify, and convert data directly from your terminal.
Key Features and Usage
Dasel simplifies complex data operations with intuitive commands. Below are common use cases:
Querying Data
Retrieve specific values from your data files using the select
command. You can specify the file, its format, and the path to the desired value.
# Retrieve a value from a JSON file
dasel select -f data.json -p json -r string .path.to.value
Updating Data
Modify existing values or add new ones to your data structures with the put
command. This is useful for configuration management and dynamic data updates.
# Update a value in a YAML file
dasel put string -f data.yaml -p yaml .path.to.value "newValue"
Converting Data Formats
Seamlessly convert data between different formats like JSON to YAML or vice versa using the convert
command.
# Convert a JSON file to YAML
dasel convert -f data.json -p json -t yaml
Deleting Data
Remove specific keys or elements from your data structures using the delete
command.
# Delete a key from a JSON file
dasel delete -f data.json -p json .path.to.remove
Advanced Queries
Dasel supports querying nested data and specific elements within arrays or lists.
# Query nested data in a TOML file
dasel select -f data.toml -p toml .section.key
# Extract a specific list item from an XML file
dasel select -f data.xml -p xml .parent.child[0]