MIT License

项目介绍

TomWright/dasel 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 MIT License 许可证,目前获得 8.1k 个 Star、182 次 Fork。

仓库全名
TomWright/dasel
开源许可证
MIT License
Star 数
8.1k
Fork 数
182
未关闭 Issue
27

README 摘要

Dasel Dasel (short for Data-Select) is a command-line tool and library for querying, modifying, and transforming data structures such as JSON, YAML, TOML, XML, CSV, and KDL. It provides a consistent, powerful syntax to traverse and update data — making it useful for developers, DevOps, and data wrangling tasks. Features Multi-format support: JSON, YAML, TOML, XML, CSV, HCL, INI, KDL. Unified query syntax: Access…

完整内容见 GitHub 原始 README 或本页 。

常见问题

dasel 用什么语言开发?

主要使用 Go 编写,采用 MIT License 许可证,目前有 8.1k 个 Star。

dasel 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 dasel 的源码?

可以直接克隆仓库:git clone https://github.com/TomWright/dasel.git,默认分支为 master;安装与运行步骤见仓库 README。

dasel 最近还在维护吗?

仓库最近一次更新为 5 天前,当前有 27 个未关闭 Issue;Star 数为 8.1k,可作为社区活跃度的参考。

README

Gitbook Go Report Card PkgGoDev Test Build codecov Mentioned in Awesome Go GitHub Downloads Homebrew Formula Downloads GitHub License GitHub tag (latest by date) Homebrew tag (latest by date)

Dasel mascot

Dasel

Dasel (short for Data-Select) is a command-line tool and library for querying, modifying, and transforming data structures such as JSON, YAML, TOML, XML, CSV, and KDL.

It provides a consistent, powerful syntax to traverse and update data — making it useful for developers, DevOps, and data wrangling tasks.


Features

  • Multi-format support: JSON, YAML, TOML, XML, CSV, HCL, INI, KDL.
  • Unified query syntax: Access data in any format with the same selectors.
  • Query & search: Extract values, lists, or structures with intuitive syntax.
  • Modify in place: Update, insert, or delete values directly in structured files.
  • Convert between formats: Seamlessly transform data from JSON → YAML, TOML → JSON, etc.
  • Script-friendly: Simple CLI integration for shell scripts and pipelines.
  • Library support: Import and use in Go projects.

Installation

Homebrew (macOS/Linux)

brew install dasel

Go Install

go install github.com/tomwright/dasel/v3/cmd/dasel@master

Prebuilt Binaries

Prebuilt binaries are available on the Releases page for Linux, macOS, and Windows.

None of the above?

See the installation docs for more options.


Shell Completion

Dasel supports tab-completion for Bash, Zsh, Fish, and PowerShell. Generate and load the completion script for your shell:

# Bash
source <(dasel completion bash)

# Zsh
source <(dasel completion zsh)

# Fish
dasel completion fish | source

# PowerShell
dasel completion powershell | Out-String | Invoke-Expression

See the shell completion docs for permanent installation instructions.

Man Page

Generate and view the man page:

dasel man | man -l -

Basic Usage

Selecting Values

By default, Dasel evaluates the final selector and prints the result.

echo '{"foo": {"bar": "baz"}}' | dasel -i json 'foo.bar'
# Output: "baz"

Modifying Values

Update values inline:

echo '{"foo": {"bar": "baz"}}' | dasel -i json 'foo.bar = "bong"'
# Output: "bong"

Use --root to output the full document after modification:

echo '{"foo": {"bar": "baz"}}' | dasel -i json --root 'foo.bar = "bong"'
# Output:
{
  "foo": {
    "bar": "bong"
  }
}

Update values based on previous value:

echo '[1,2,3,4,5]' | dasel -i json --root 'each($this = $this*2)'
# Output:
[
    2,
    4,
    6,
    8,
    10
]

Format Conversion

cat data.json | dasel -i json -o yaml

Recursive Descent (..)

Searches all nested objects and arrays for a matching key or index.

echo '{"foo": {"bar": "baz"}}' | dasel -i json '..bar'
# Output:
[
    "baz"
]

Finds all values matching a condition anywhere in the structure.

echo '{"foo": {"bar": "baz"}}' | dasel -i json 'search(bar == "baz")'
# Output:
[
    {
        "bar": "baz"
    }
]


Documentation

Full documentation is available at daseldocs.tomwright.me.


Contributing

Contributions are welcome! Please see the CONTRIBUTING.md for details.


License

MIT License. See LICENSE for details.

Stargazers over time

Stargazers over time

评论

暂无评论