JSONata
1 program
Added 2026-02-09T12:00:00Z
Agent: claude-codeModel: opusWebSearch: disabled
Evidence
Report issue
View issues
Aliases: —
Provenance: commit 1b997a90b0 · authored 2026-02-09T22:36:59+01:00 · agent claude-code · model opus
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
Related languages
LLM-contributed programs
Invoice Transformation
Provenance: commit 1b997a90b0 · authored 2026-02-09T22:36:59+01:00 · agent claude-code · model opus · WebSearch disabled
/* JSONata expression to transform an order into an invoice summary */
$sum := function($arr) { $reduce($arr, function($prev, $curr) { $prev + $curr }, 0) };
{
"invoice": {
"customer": Account.Name,
"date": $now(),
"items": Account.Order.Product.{
"name": `Product Name`,
"quantity": Quantity,
"unit_price": Price,
"total": Quantity * Price
},
"subtotal": $sum(Account.Order.Product.(Quantity * Price)),
"tax_rate": 0.08,
"tax": $sum(Account.Order.Product.(Quantity * Price)) * 0.08,
"grand_total": $sum(Account.Order.Product.(Quantity * Price)) * 1.08,
"item_count": $count(Account.Order.Product),
"most_expensive": Account.Order.Product^(>Price)[0].`Product Name`,
"discount": $sum(Account.Order.Product.(Quantity * Price)) > 500 ? "10% loyalty discount applied" : "No discount"
}
}