Sunday, January 9, 2022

FX: An interactive alternative to jq to process JSON

fx logo

fx example

* Function eXecution

Build Status Npm Version Brew Version

Command-line JSON processing tool

Features

  • Easy to use
  • Standalone binary
  • Interactive mode 🎉
  • Streaming support 🌊

Install

Or via Homebrew

Or download standalone binary from releases

Usage

Start interactive mode without passing any arguments.

Or by passing filename as first argument.

Pass a few JSON files.

cat foo.json bar.json baz.json | fx .message

Use full power of JavaScript.

$ curl ... | fx '.filter(x => x.startsWith("a"))'

Access all lodash (or ramda, etc) methods by using .fxrc file.

$ curl ... | fx '_.groupBy("commit.committer.name")' '_.mapValues(_.size)'

Update JSON using spread operator.

$ echo '{"count": 0}' | fx '{...this, count: 1}'
{
  "count": 1
}

Extract values from maps.

$ fx commits.json | fx .[].author.name

Print formatted JSON to stdout.

Pipe JSON logs stream into fx.

$ kubectl logs ... -f | fx .message

And try this:

Documentation

See full documentation.

Links

Related

License

MIT



from Hacker News https://ift.tt/2BvyYY0

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.