Settings

Theme

Show HN: Dop, Awk-like processing for JSON/YAML/TOML with Lua

github.com

2 points by dhuan_ 6 days ago · 1 comment · 1 min read

Reader

dop reads JSON, YAML, or TOML from stdin, walks the structure field by field, and lets you transform values with Lua. It can also query nested paths and convert between formats.

It weights just 800kb and you don't need Lua installed in your pc.

A few examples:

echo '{"list":[1,2,3]}' | dop -e ' if type(VALUE) == "number" then set(VALUE * 2) end ' # => {"list":[2,4,6]}

echo '{"data":{"some_list":[1,2,3]}}' | dop -q data.some_list # => [1,2,3]

What I wanted was: - something simpler to reason about for non-trivial transforms - one tool for JSON/YAML/TOML - embedded scripting without needing Lua installed separately

Repo: https://github.com/dhuan/dop

Any feedback is welcome.

ifh-hn 5 days ago

This use case is definitely why I use nushell. It's not 800kb but it does a lot more and the syntax is excellent.

Not to take away from you're achievement though. But it'd have to be something very good to budge me from nushell.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection