Argyll Expressions#

Argyll Expressions is a language for querying and transforming JSON with JavaScript-style syntax.

Take a list of orders.

{
  "orders": [
    {"id": "A", "paid": true,  "quantity": 3, "price": 3.95},
    {"id": "B", "paid": false, "quantity": 1, "price": 6.50}
  ]
}
ExpressionResult
orders[0].id"A"
orders[0].quantity * orders[0].price11.85
orders[1].paid && orders[1].quantity > 0false

To get the total for every paid order, pipe the array through filter and map.

orders
  | filter order: order.paid
  | map order: {
      id: order.id,
      total: order.quantity * order.price,
    }
[{"id": "A", "total": 11.85}]

Use It in Go#

Argyll Expressions is designed to work directly with the values Go’s encoding/json produces when it unmarshals JSON into an any.

Evaluate an expression directly, or compile it once and reuse it across inputs. Compiled expressions support concurrent evaluation.

go get github.com/kode4food/argex@latest

Bind a Go function to make it available inside an expression.

→ Use Argyll Expressions from Go

→ Use the command line