
JSONata TransformItems
CertifiedTransform or query a JSON or ION file using JSONata
JSONata TransformItems
Transform or query a JSON or ION file using JSONata
JSONata is a query and transformation language for JSON data.
type: io.kestra.plugin.transform.jsonata.TransformItemsExamples
Transform a JSON file using a JSONata expression.
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.
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)
}
Properties
expression *Requiredstring
The JSONata expression to apply on the JSON object
from *Requiredstring
The file to be transformed
Must be a kestra:// internal storage URI.
Pebble expression referencing an Internal Storage URI e.g. {{ outputs.mytask.uri }}.
explodeArray booleanstring
trueSpecifies whether to split arrays into separate records
If the JSONata expression results in a JSON array and this property is set to true, then a record will be written for each element. Otherwise, the JSON array is kept as a single record.
maxDepth integerstring
1000The maximum number of nested evaluation levels allowed for the JSONata expression
Bounds how deeply the expression may nest while it is evaluated, which is what caps runaway recursive functions. The limit depends only on the expression, never on how many records are processed: the default of 1000 is far above what ordinary expressions reach, and a batch of 1,000,000 records needs no higher a value than a batch of 10 does. Raise it only for expressions with proven deep recursion needs — each level adds frames to the chain traversed by variable lookup, so very high values trade the clean error for a JVM StackOverflowError.
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.
Outputs
processedItemsTotal integer
The total number of items that was processed by the task
uri string
uriFile URI containing the result of transformation