Issue with tWriteJSONField output

Five Stars

Issue with tWriteJSONField output

I'm struggling with the tWriteJSONField component in Talend and I am hoping someone might be able to help me. I'm pushing data through the component into a tRESTClient object and the API has very specific requirements.
Using the tWriteJSONField I can extract the data required into the following format:
  {
   "client":{
       "firstName":"Bobby",
       "lastName":"Char",
       "homephone":[],
       "mobilephone1":[],
       "mobilephone2":[],
       "email":"example@test.com"
       },
   "addresses":
       {
       "line1":[],
       "city":[],
       "postcode":[]
       }
   }

But, what i actually need is the format like this (tested successfully in Postman):
{
   "client":{
        "firstName":"Bobby",
        "lastName":"Char",
        "homephone":"",
        "mobilephone1":"",
        "mobilephone2":"",
        "email":"example@test.com"
    },
"addresses":
}

Note how the NULL entries are string and not arrays, the second set of entries (addresses) are enclosed as an array (even if there will commonly only be one entry). I've been searching for days for a solution and it appears a common issue, but i am yet to find a solution. Can anyone help please?
Seventeen Stars

Re: Issue with tWriteJSONField output

I had similar problems and give up. Now I use the Jackson API and build the JSON documents with pure Java in a tJavaFlex.
I suggest you load the latest Jackson API jar with tLibraryLoad and build your own documents. the API is very easy.
Five Stars

Re: Issue with tWriteJSONField output

Hi,
@jlolling - thanks for getting back to me, i was beginning to fear that might be the case.
I'm afraid i'm still relatively new to Talend and am no java developer. Is the above approach going to be viable for me given my limited experience?
Many thanks!
Seventeen Stars

Re: Issue with tWriteJSONField output

I fear in this case you have not so friendly choices:
You can use the Talend Data Mapper - a highly complex tool which lets you transform various formats into others. Complex because it depends on a veritable training.
Using Talend as none-Java developer can sometimes be a pain!