Search code examples
jsontalend

Add data to a json file using Talend


I have the following JSON:

[
    {
        "date": "29/11/2021",
        "Name": "jack",

    },
    {
        "date": "30/11/2021",
        "Name": "Adam",

    },
        "date": "27/11/2021",
        "Name": "james",

    }
]

Using Talend, I wanna add 2 lines to have something like:

[
    {
        "company": "AMA",
        "service": "BI",
        "date": "29/11/2021",
        "Name": "jack",
        

    },
    {
        "company": "AMA",
        "service": "BI",    
        "date": "30/11/2021",
        "Name": "Adam",

    },
        "company": "AMA",
        "service": "BI",    
        "date": "27/11/2021",
        "Name": "james",

    }
]

Currently, I use 3 components (tJSONDocOpen, tFixedFlowInput, tJSONDocOutput) but I can't have the right configuration of components in order to get the job done !


Solution

  • If you are not comfortable with json .

    Just do these steps :

    1. In the metaData just create a FileJson like this then paste it in your job as a tFileInputJson

    enter image description here

    1. Your job design and mapping would be

    enter image description here

    1. In your tFileOutputJson don't forget to change in the name of the data block "Data" with ""