Rick Cogley's Tech Logr

Short Technical Laser Bursts %%

RC Logr 20210412 164458

Thursday, 29 Apr, 2021

🗓 "Showa Day" in Japan

Wow, « dasel » from Tom Wright @tomwright1993, is a truly cool tool. It uses a standard DAta SELector syntax, so you can learn it once, then use it for converting and querying files of various oft-used types. 🆒

It lets you do something similar to jq or yq, but it supports JSON, YAML, TOML, XML or CSV. Say you have a simple json file which you need in yaml. Just do this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
> dasel select -f website.json
{
  "ErrorDocument": {
    "Key": "404.html"
  },
  "IndexDocument": {
    "Suffix": "index.html"
  },
  "RoutingRules": [
    {
      "Condition": {
        "KeyPrefixEquals": "/"
      },
      "Redirect": {
        "ReplaceKeyWith": "index.html"
      }
    }
  ]
}

Easily convert to yaml like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
> dasel select -f website.json -p yaml
ErrorDocument:
  Key: 404.html
IndexDocument:
  Suffix: index.html
RoutingRules:
- Condition:
    KeyPrefixEquals: /
  Redirect:
    ReplaceKeyWith: index.html

And boom.

RC Logr 20210412 164458 - Wow, « dasel » from Tom Wright … Rick Cogley
Back to Home Tweet Link