Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All ,
iam new to talend try to learn things any help would be much appreciated
Iam trying to read multiple json objects present in single file in to a table by dividing the values through textractJsonfield component
My current job is picking only first json value and writing the same to database below is the flow i used
tfileInputDelimeted --> textractJsonFields ---> db
my file format is as below :
{tranid:"1212", "user":{"name":"123","addr":"786 rt"}}
{tranid:"1213", "user":{"name":"345","addr":"4234 iu"}}
my input file has the json objects as above .. if its like array i was able to read all the data thrgh extractjson component with no issues ,but the real thing comes up when its not an array of objects and it is reading only the first object which is tranid:1212 data
I have written a job where this works. It looks like below. You can see the result of running it as well (I added an extra row of data to the data you supplied)....
My tExtractJSONField was configured like this....
Does that point you towards where your job needs to be updated? If not, can you post more details about your job?
Hi Thanks for the reply ..
I have tried the smae earlier but it was reading only the first object of json not the second one .. what properties you defined for the component of extractjsonfield to loop for the second json object ??
as the below two json objects are seperatly flowing in how you looped through them ?? for tranid 1212 and tranid 1213??
{tranid:"1212", "user":{"name":"123","addr":"786 rt"}}
{tranid:"1213", "user":{"name":"345","addr":"4234 iu"}}
The looping in this case isn't down to the tExtractJSONFields component. The looping is actually handled by the tFileInputDelimited. Each JSON file is on a different row of the file. So the tFileInputDelimited is returning a row for each JSON snippet. I suspect that maybe your tFileInputDelimited may need its row separator changed. Mine is set to the default of "\n".
Sorry for the delayed response .. but some how in my case i was parsing the json objects and is reading only the first json value until or unless they are bounded together as json array .. if its a json aray it is able to loop all the elements
Can you please provide me the exact json file you are trying to read ???
My file looks exactly like this.....
{tranid:"1212", "user":{"name":"123","addr":"786 rt"}}
{tranid:"1213", "user":{"name":"345","addr":"4234 iu"}}
{tranid:"1233", "user":{"name":"33545","addr":"4w3234 iu"}}
Each row is a ew JSON String. I assumed that is how yours is.