-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom_func uses properties from two arrays of objects #201
Comments
|
Actually, i figured out a different way by using Input JSON:
Schema:
Output by
The key is the use of The javascript code (flattened in the schema) is:
The code is fairly self-explanatory. Let me know if you have any further questions. |
@tb-artomu shameless plug here: please consider being a sponsor to the project, one time or recurring, big or small, equally appreciated! Thanks! |
OK, Thank you for your answer. |
input data
{
"count":7,
"next":"xxx",
"previous":"xxx",
"results":[
{
"order_reference":"T3008659677",
"order_date":"2023-01-06T12:37:37",
"test_flag":true,
"supplier":"https://XXXX",
"currency_code":"GBP",
"subtotal":"1.40",
"tax":"8.40",
"total":"9.80",
"items":[
{
"url":"https://items",
"part_number":"RESKU1",
"supplier_sku_reference":"SUSKU1",
"line_reference":"1",
"quantity":3
},
{
"url":"https://items2",
"part_number":"RESKU2",
"supplier_sku_reference":"SUSKU2",
"line_reference":"2",
"quantity":1
}
],
"goods":[
{
"g_url":"https://goods",
"g_part_number":"RESKU1",
"g_supplier_sku_reference":"SUSKU1",
"g_line_reference":"1",
"g_quantity":3
},
{
"g_url":"https://goods2",
"g_part_number":"RESKU2",
"g_supplier_sku_reference":"SUSKU2",
"g_line_reference":"2",
"g_quantity":1
}
]
}
]}
expected output:
eg: use concat func = > iterm_url_number = items.url + “_” + g_part_number
How to write schema?Is there a sample?
{
"parser_settings": {
"version": "omni.2.1",
"file_format_type": "json"
},
"transform_declarations": {
"FINAL_OUTPUT": {
"object": {
"datas": {
"array": [{
"xpath": "/results/",
"object": {
"iterms_list": { "array": [ { "xpath": "items/", "object": {
"iterm_url": {
"xpath": "url"
},
"iterm_url_number": {
"custom_func": {
"name": "concat",
"args": [
{"xpath": "url"},
{"const": "_"},
{"xpath": "../goods//g_part_number"}
]
}
}
}} ] },
"goods_list": { "array": [ { "xpath": "goods/", "object": {
"iterm_part_number": {
"xpath": "g_part_number"
}
}} ] }
}
}]
}
}
}
}
}
The text was updated successfully, but these errors were encountered: