Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is there a way to use conditions based on TFileInputJson and based on conditions pass json values to separate jobs.
Attached a pic
I need to pass json values based on condition to either in order 1 path or in order 2 path.
Hi, I figure out the answer for this removing expected block.
Thank you
Hello,
To understand your requirement very well, could you please elaborate your case with an example with input and expected output values?
Best regards
Sabrina
Im trying to figure out a way to use textractjson with a json object like below.
{
"site_id": "003",
"purchase_order_details": [
{
"item": "2285542",
"purchase_order_details_notes": [
{
"note_line": "1"
}
]
}
],
"purchase_order_allowances": [
{
"amount": "23.5"
},
{
"amount": "23.7"
}
]
}
The issue was when using textractjson if one of the arrays in above obj "purchase_order_details" or "purchase_order_allowances" becomes null then the whole object becomes null when extracting.
So i need to check whether "purchase_order_details" and "purchase_order_allowances" arrays are not null and do the flow as in the picture.
If not if one of the array is null then to pass the information conditionally to another textractjsonfield component.
@Xiaodi Shi @Shicong Hong Hi both,
If im using above json object and im getting the below log file.
My issue is if im using below json format(without the array)
Im not getting the result if the json array is null. How to handle this situation.
Thank you
Hi
If the file does not contain purchase_order_details item, means the array is null. My idea is to read the whole file content as a string using tFileInputRullRow, then check the string whether it contains "purchase_order_details" substring, set the result to a global variable (boolean type) which used to trigger different processing. eg:
tFileInputFullRow--main--tJavaRow--runIf1---tFileInputJson1....
--runIf2---tFileInputJson2....
on tJavaRow:
if(input_row.content.contains("purchase_order_details"){
globalMap.put("toRead_purchase_order_details", true);
}
set the conditon of runIf1 as:
(boolean)globalMap.get("toRead_purchase_order_details")
tFileInputJson1: read the json file with purchase_order_details array.
Can you try and let me know if you have any questions.
Regards
Shong
Hi @Shicong Hong
Thanks for the reply. I think this is not a good solution, cause there can be scenarios where "purchase_order_details" is mapped to null in json document. So in that case reading from the raw file is not a good solution. Anyhow thank you for the idea.
Thank you
Heshan
"purchase_order_details" node always exist in the file even though the value is null?
If you dont have the node in the json is same as the node exist in the json with value as null. Both of those scenario can happen. Its because the json is so dynamic.
Thank you for the reply
Hi @Shicong Hong , @Xiaodi Shi
If I can do below then my task is also complete.
I have below complex input json.
/////////////////////////////////input///////////////////////////////
{
"site_id": "003",
"purchase_order_details": [
{
"item": "2285542",
"purchase_order_details_notes": [
{
"note_line": "1"
}
]
}
],
"expected": {
"errorCode": "200"
},
"drop_ship_address": {
"cust_order_no": "2377709"
},
"purchase_order_allowances": [
{
"amount": "23.5"
}
]
}
/////////////////////////////////input///////////////////////////////
I need the below json format. Input may or maynot have "expected" block. But for the output json I need to omit "expected" block from the json
/////////////////////////////////output///////////////////////////////
{
"site_id": "003",
"purchase_order_details": [
{
"item": "2285542",
"purchase_order_details_notes": [
{
"note_line": "1"
}
]
}
],
"drop_ship_address": {
"cust_order_no": "2377709"
},
"purchase_order_allowances": [
{
"amount": "23.5"
}
]
}
/////////////////////////////////output///////////////////////////////
So far I have been using tJSONDocInput and tJSONDocOutput to figure out a solution.
Thank you
Hi, I figure out the answer for this removing expected block.
Thank you