Search code examples
arraysjsonresttalend

Talend JSON field need to create arrays in 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":"[email protected]"

        },
    "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":"[email protected]"

     },
 "addresses":[
     {
         "line1":"",
         "city":"",
         "postcode":""
     }]
 }

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?


Solution

  • there is no solution for this issue you have to manipulate json by editing json in String Format