TransformItems
TransformItems
type: "io.kestra.plugin.transform.jsonata.TransformItems"
Transform or query a JSON data using JSONata language.
JSONata is a sophisticated query and transformation language for JSON data.
Examples
Transform JSON payload using 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: get_discounted_price
type: io.kestra.plugin.transform.jsonata.TransformItems
from: "{{ outputs.http_download.uri }}"
expression: $sum(products.(price-(price*discountPercentage/100)))
- 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)))
}
Properties
explodeArray
- Type: boolean
- Dynamic: ✔️
- Required: ✔️
- Default:
true
Specifies whether to explode 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.
expression
- Type: string
- Dynamic: ✔️
- Required: ✔️
The JSONata expression to apply on the JSON object.
from
- Type: string
- Dynamic: ✔️
- Required: ✔️
The file to be transformed.
Must be a
kestra://
internal storage URI.
maxDepth
- Type: integer
- Dynamic: ✔️
- Required: ✔️
- Default:
1000
The maximum number of recursive calls allowed for the JSONata transformation.
Outputs
processedItemsTotal
- Type: integer
- Required: ❌
The total number of items that was processed by the task.
uri
- Type: string
- Required: ❌
- Format:
uri
File URI containing the result of transformation.
Definitions
Was this page helpful?