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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
joefrancois
Contributor III
Contributor III

I need help to convert json record into field

Hello,

 

I am trying to extract multiple row from a JSON tRESTClient input with some static data inject in the row creation. My JSON input look like so:

 

[
{
"OrderID": 6675,
"FirstName": "John",
"LastName": "Doe",

"Address": "123 spring st",

"OrderItemList": [
{
"ItemID": "736940759",
"ItemQty": 1,
"ItemDesc": "Widget One",
"ItemUnitPrice": 68.99,

},
{
"ItemID": "736940858",
"ItemQty": 1,
"ItemDesc": "Widget Two",

"ItemUnitPrice": 37.99,

}
],
"PromotionList": [
{
"PromotionName": "Code",
"Coupon": "Code",
"DiscountAmount": 9.6
}
]

 

I am trying to get the following out put

 

 

OrderID FirstName LastName Address Coupon ItemID ItemQty ItemDesc ItemUnitPrice
6675 John Doe 123 spring st  Code 736940759 1 Fine Product 68.99
 6675 John   Doe  123 spring st  Code 736940858 1 Good Product 37.99
 6675  John  Doe  123 spring st Code 77777 1 Discount  -9.6

 

I have been pulling my hair out, any help would be greatly appreciated.

 

Regards,

Joseph

Labels (5)
11 Replies
vboppudi
Partner - Creator III
Partner - Creator III

Hi,

Please read json file as input like below

0683p000009LwZX.png

Then use tMap to split records into two pipelines like below

0683p000009LwwY.png

 

Then use tAggregate to get unique order for each coupon.

0683p000009LwzM.png

 

Then load aggregate and tMap output to tBufferout.

Use tBufferinput to read two sets of data and load into table/File.

0683p000009Lwvk.png

 

Regards,

 

joefrancois
Contributor III
Contributor III
Author

Thank you so much for the solution. I am new to Talend and would have never been able to figure this out on my own. I still however have one problem. I can't seem to figure out how to transform the DiscountAmount into a negative number. I keep on getting a compiling error "Detail Message: Type mismatch: cannot convert from Double to String". Any tip on how to resolve it?

 

Thank you again and regards,

Joseph