Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Json input and output json with product total

Hi Team,

I have a json file of book details and their prices i should load this json as it is and extra parameter as totol sum of trasaction as in json

{
"INVOICE_NUMBER":"KAR_1569850659236",
"CUSTOMER_ID":"CUST_46437",

"CUSTOMER_NAME":"Dhana",
"CITY":"karimnagar",
"product_details":[
{"PRODUCT_CODE":"5636716025251602","PRODUCT_NAME":"Rice - Raw, Sona Masoori","QUANTITY":3,"PRODUCT_UNIT_PRICE":564,"TOTAL":1692},
{"PRODUCT_CODE":"6283957770775252","PRODUCT_NAME":"Organic Kasoori Methi","QUANTITY":3,"PRODUCT_UNIT_PRICE":22,"TOTAL":66},
{"PRODUCT_CODE":"7465557075258007","PRODUCT_NAME":"Urad Dal Whole White","QUANTITY":2,"PRODUCT_UNIT_PRICE":105,"TOTAL":210}],

"TOTAl":?
}

 

how can i generate this json with total calculated.

 

Please suggest any idea.

I tried may approaches ...but didn't work.

 

Thanks in advance

 

Labels (3)
4 Replies
Anonymous
Not applicable
Author

Hi,

 

    You will have to first calculate the aggregated data for each invoice number. You can read the json data and send the total price for each item as input to taggregaterow component. Store the data in a tHashOutput for interim storage.

 

    In the next subjob, read the file again and join it with data from tHashInput using a tMap. Once the data is merged, you can convert the data back to JSON using tFileOutputJSON.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Anonymous
Not applicable
Author

Hi Nikhil,

 

Thank you for the quck reply but the the invoice number and the other data are generating on fly and taking random product to invoice to create a dummy invoice bill kind of trasaction..how is it possible to read the data again.

please let me know in case any approach or suggest the above approach how is it possible.

 

Thanks again...

Anonymous
Not applicable
Author

Hi,

 

    You have mentioned the input is a file in your previous post. So you can store the interim data after creating the invoice number as a temporary file.

 

    If the data volume is not too high, you can also store them in Hash components.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Anonymous
Not applicable
Author

Hi nikhil,

 

Thank you! I will try this approach and get back to you about the results.