Six Stars

How to create a JSON nested where the objects have different names

Hello guys!

 

I have the following table structure and I'd like to create a JSON file using the tWriteJSONField.

 

FirstName | LastName
John      | McCain
Peter     | Fitzgerald
Pablo     | De Los Santos

 

My JSON should be something like that below. The name of the nest could be created using the Numeric.sequence function I suppose.

{
    "0" : {
        "FirstName" : "John",
        "LastName" : "McCain"
    },
    "1" : {
        "FirstName" : "Peter",
        "LastName" : "Fitzgerald"
    },
    "2" : {
        "FirstName" : "Pablo",
        "LastName" : "De Los Santos"
    }
}

 

Thanks for helping me.

 

 

  • Data Integration
1 ACCEPTED SOLUTION

Accepted Solutions
Seventeen Stars

Re: How to create a JSON nested where the objects have different names

You can do such things - and more - with the component tJSONDocOutput. Get them in Talend Exchange or Github: https://github.com/jlolling (more up-to-date) 

3 REPLIES
Community Manager

Re: How to create a JSON nested where the objects have different names

Hello
The element name must be defined before the job execution and it can't be a variable, so it is impossible to generate a json string like you showed with tWriteJsonField.

Regards
Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Seventeen Stars

Re: How to create a JSON nested where the objects have different names

You can do such things - and more - with the component tJSONDocOutput. Get them in Talend Exchange or Github: https://github.com/jlolling (more up-to-date) 

Six Stars

Re: How to create a JSON nested where the objects have different names


jlolling wrote:

You can do such things - and more - with the component tJSONDocOutput. Get them in Talend Exchange or Github: https://github.com/jlolling (more up-to-date) 


Thanks a milion! Smiley Happy