Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.

 

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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) 

View solution in original post

12 Replies
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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) 

Anonymous
Not applicable
Author


@lli 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! 0683p000009MACn.png

javvaji
Creator II
Creator II

HI @lli,

 

Can we get a sample job design how to do the above structure.

 

 

Thanks,

Bharath.

Anonymous
Not applicable
Author

This is still not very easy. The output component can use values as field names but the current version is not flexible enough to add per row one new attribute+object. I have in my current project a similar problem and will solve this by update the components in the next days.

Anonymous
Not applicable
Author

I can currently create this:

[ {
  "0" : {
    "firstname" : "John",
    "lastname" : "McCain"
  }
}, {
  "1" : {
    "firstname" : "Peter",
    "lastname" : "Fritzgerald"
  }
}, {
  "2" : {
    "firstname" : "Pablo",
    "lastname" : "De Los Santos"
  }
} ]
Anonymous
Not applicable
Author

I have solved the issue! In the next days I will test it if there is no unwanted impact to other parts and publish the new version.

There is no change within the configuration of a component.

{
  "0" : {
    "firstname" : "John",
    "lastname" : "McCain"
  },
  "1" : {
    "firstname" : "Peter",
    "lastname" : "Fritzgerald"
  },
  "2" : {
    "firstname" : "Pablo",
    "lastname" : "De Los Santos"
  }
}

0683p000009LyqY.png

javvaji
Creator II
Creator II

HI @lli,

Thanks for the reply. I will take this as reference and try to complete and let you know.

Once again thanks for the quick response.

 

Thanks,

Bharath.

Anonymous
Not applicable
Author

I have just published on Talend Exchange and Github the new version (14.0) of the tJSONDoc components which allows the described job design.

https://exchange.talend.com/#marketplaceproductoverview:marketplace=marketplace%252F1&p=marketplace%...

https://github.com/jlolling/talendcomp_tJSONDoc/releases