Replace JSONata4Java with dashjoin/jsonata-java#69
Conversation
…atibility JSONata4Java is not a complete implementation of the JSONata spec, causing expressions that work on try.jsonata.org to fail in Kestra (e.g. nested array path expressions). Switch to dashjoin/jsonata-java which is a 1:1 port of the JavaScript reference implementation with 100% feature parity. Fixes #40
🧪 QA Report — Replace JSONata4Java with dashjoin/jsonata-javaBranch: Summary
Flow 1: jsonata_transform_value (✅ SUCCESS)Flow YAMLid: jsonata_transform_value
namespace: qa.test
tasks:
- id: transform_json
type: io.kestra.plugin.transform.jsonata.TransformValue
from: "{\"order_id\": \"ABC123\", \"first_name\": \"John\", \"last_name\": \"Doe\", \"address\": {\"city\": \"Paris\", \"country\": \"France\"}, \"items\": [{\"product_id\": \"001\", \"name\": \"Apple\", \"quantity\": 5, \"price\": 1.50}, {\"product_id\": \"002\", \"name\": \"Banana\", \"quantity\": 3, \"price\": 0.75}]}"
expression: "{\"order_id\": order_id, \"full_name\": first_name & \" \" & last_name, \"city\": address.city, \"total_items\": $sum(items.quantity), \"total_price\": $sum(items.(quantity * price))}"Logs synthesis Outputs synthesis Flow 2: jsonata_transform_items (✅ SUCCESS)Flow YAMLid: jsonata_transform_items
namespace: qa.test
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)"Logs synthesis Outputs synthesis
Flow 3: jsonata_transform_items_orders (✅ SUCCESS)Flow YAMLid: jsonata_transform_items_orders
namespace: qa.test
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)
}Logs synthesis Outputs synthesis
Flow 4: jsonata_issue40_nested_path (✅ SUCCESS) — Issue #40 ReproductionFlow YAMLid: jsonata_issue40_nested_path
namespace: qa.test
description: "Reproduces issue #40 - nested path expression that was broken with JSONata4Java"
tasks:
- id: transform_nested
type: io.kestra.plugin.transform.jsonata.TransformValue
from: |
{
"filterTuples": [
{
"filter": [
{"parent": {"parent": {"hybrisId": "8796977876513"}, "hybrisId": "8796995440161"}, "hybrisId": "8796998946337"},
{"parent": {"parent": {"hybrisId": "8796977876513"}, "hybrisId": "8796995472929"}, "hybrisId": "8797002583585"},
{"parent": {"parent": {"hybrisId": "8796977843745"}, "hybrisId": "8796995341857"}, "hybrisId": "8796999798305"}
]
},
{
"filter": [
{"parent": {"parent": {"hybrisId": "8796977876513"}, "hybrisId": "8796995440161"}, "hybrisId": "8796998946337"},
{"parent": {"parent": {"hybrisId": "8796977876513"}, "hybrisId": "8796995472929"}, "hybrisId": "8797002583585"},
{"parent": {"parent": {"hybrisId": "8796977843745"}, "hybrisId": "8796995341857"}, "hybrisId": "8796999765537"}
]
}
]
}
expression: "[filterTuples.[filter.(parent.parent.hybrisId & \"/\" & parent.hybrisId & \"/\" & hybrisId)]]"Logs synthesis Outputs synthesis [
[
"8796977876513/8796995440161/8796998946337",
"8796977876513/8796995472929/8797002583585",
"8796977843745/8796995341857/8796999798305"
],
[
"8796977876513/8796995440161/8796998946337",
"8796977876513/8796995472929/8797002583585",
"8796977843745/8796995341857/8796999765537"
]
]With the old JSONata4Java, this returned a flat array (6 elements). With dashjoin/jsonata-java, it correctly returns two nested arrays (matching try.jsonata.org behavior). Timeout notesNo timeouts encountered. All executions completed within a few seconds. |
Summary
com.ibm.jsonata4java:JSONata4Java:2.6.2withcom.dashjoin:jsonata:0.9.9, a 1:1 port of the JavaScript JSONata reference implementationTransform.javato use the new library API, converting between JacksonJsonNodeand native Java objects at the evaluation boundaryFixes #40
Test plan
TransformValueTesttests passTransformItemsTesttests passshouldHandleNestedArrayExpressionFromIssue40test validates the exact example from the issue produces correctly nested arrays (not flattened)