Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I would like to build an array of objects using twritejsonFields as below.
But when i set the type list as the transaction field type and run the job.
I get <<cannot convert from string to list>> .
yet I need transactions to be of type list and not string
Please can you help me
Hi @Richard Hall ,
input data 👇
output desired
you notice here that transactions is a json array so its value is not between "".
Fundamentally you have to treat your input data as Strings, Numbers, Booleans and nulls, contained in arrays and objects (JSON Objects). JSON is essentially just text. As such, you will need to extract this input data into rows like this.....
Cash, Code, DateAt, Identifiant, Validate
5000, Tx-1000, 2001-11-03T15:38:52.330+01:00, 1001, true
5000, Tx-1002, 2001-11-03T15:38:52.330+01:00, 1002, true
Your output will then build this up again. I have a question about your output because I can see a potential flaw in this structure. In your "data" objects, you have 2 sub-objects in the examples above. So you have 2 identifiant and valide entities in each. Looking at your input data I see that this is likely because your cash and dateAt values are the same. What if you have 3 the same? Would your data object grow to hold 3 sub-objects? If so, this may cause you problems. It might be better to have data as an array of JSON objects holding identifiant and valide.
Anyway, this structure may be difficult to build with a single tWriteJSONField component. They are really meant for simple structures. The subscription Talend product has Talend Data Mapper which would be better suited to this. Alternatively (and a favourite method of mine), you can use Java to build slightly more complicated structures. But the first issue you need to resolve is how you will extract your data from JSON and group it.