Four Stars

How to iterate over a JSON file and write in MySQL

Hi, guys.

First thing first, I'm working with some JSON files which contains the following structure:

{
   "id":"123wer",
   "owner_contactid":"123wer",
   "departmentid":"wer13",
   "agentid":"",
   "status":"A",
   "tags":[  
      "123",
      "abc",
      "def",
      "456"
   ],
   "subject":"Test"
}

 

At this point of my project, for each tag in the array "tag", I need to create a register on my database with this tag and the ID. It should look like that:

 

ID         | tag

"123wer" | "123",
"123wer" | "abc",
"123wer" | "def",
"123wer" | "456"

 

Can somebody help me to create this workflow on Talend? 

 

P.S.: another problem that I'm facing happens when I try to extract the tags in this array. For example, even using tags[*] on the tExtractJSONFields, this field is been extracted with the brackets ( [ "123", "abc""def", "456"] ). I wonder whether I need to remove them before iterate and write the registers on my database.

 

Thank you in advance

1 REPLY
Moderator

Re: How to iterate over a JSON file and write in MySQL

Hello,

We are working on your use case and then come back to you as soon as we can.

Thanks for your time.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.