TransformItems
Transform or query a JSON data using JSONata.
JSONata is a query and transformation language for JSON data.
yaml
type: "io.kestra.plugin.transform.jsonata.TransformItems"
Transform a JSON file using a JSONata expression.
yaml
id: jsonata_example
namespace: company.team
tasks:
- id: http_download
type: io.kestra.plugin.core.http.Download
uri: https://dummyjson.com/products
- id: get_product_and_brand_name
description: "String Transformation"
type: io.kestra.plugin.transform.jsonata.TransformItems
from: "{{ outputs.http_download.uri }}"
expression: products.(title & ' by ' & brand)
- id: get_total_price
description: "Number Transformation"
type: io.kestra.plugin.transform.jsonata.TransformItems
from: "{{ outputs.http_download.uri }}"
expression: $sum(products.price)
- id: sum_up
description: "Writing out results in the form of JSON"
type: io.kestra.plugin.transform.jsonata.TransformItems
from: "{{ outputs.http_download.uri }}"
expression: |
{
"total_products": $count(products),
"total_price": $sum(products.price),
"total_discounted_price": $sum(products.(price-(price*discountPercentage/100)))
}
Calculate the total price per order from a JSON file.
yaml
id: jsonata
namespace: company.team
tasks:
- id: extract
type: io.kestra.plugin.core.http.Download
uri: https://huggingface.co/datasets/kestra/datasets/resolve/main/json/orders.json
- id: jsonata
type: io.kestra.plugin.transform.jsonata.TransformItems
from: "{{ outputs.extract.uri }}"
expression: |
Account.Order.{
"order_id": OrderID,
"total": $round($sum(Product.(Price * Quantity)), 2)
}
Dynamic
YES
The JSONata expression to apply on the JSON object.
Dynamic
YES
The file to be transformed.
Must be a kestra://
internal storage URI.
Dynamic
YES
Default
1000
Dynamic
YES
Default
true
The total number of items that was processed by the task.
Format
uri
File URI containing the result of transformation.