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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Create array inside JSON

Hi,

I created a JSON file using tWriteJSONfield.

Currently, I got the following format:

 

{
"url": "http://google.com",
"findings": {
"id": "1",
"type": "1",
"sub_type": "7",
"cul": [],
"or": "3",
"date": "05-05-2015",
"num": []
}
}

 

 

and need the following ("findings" data should be inside an array):

{
"url": "http://google.com",
"findings": [{
"id": "1",
"type": "1",
"sub_type": "7",
"cul": [],
"or": "3",
"date": "05-05-2015",
"num": []
}]
}

 

 

How can I do that?

Attached is a screenshot of my Json tree.

 

Thanks,

Emma

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

OK, I have built the following dummy structure.....

 

{"rootTag":{"newColumn1":"IH4IST","newColumn2":[{"newColumn3":"IqGyhp","newColumn4":"ULsg8G"}]}}

....using this configuration.....

0683p000009Lt8Z.png

 

Basically, add an element called "element", assign it a class of object and add your fields to that element. That should do it.

View solution in original post

5 Replies
Anonymous
Not applicable
Author

Take a look at this webpage:  

https://help.talend.com/reader/KxVIhxtXBBFymmkkWJ~O4Q/50PMKM8mz4A5fAL~FQcLHw?section=twritejsonfield...

 

Notice the @class attribute and the "array" in the "static value" column? You need to make use of these. You will need to play around with this functionality until you "get it", but it is worth spending a few hours doing this to get it to sink in 🙂

Anonymous
Not applicable
Author

Thank you,

I defined "findings" as @class  = array, and added the sub-element "element" and defined it as "loop element", I managed to get "findings" as an array,

But without the element names (id, type, sub_type, cul, or, date, num):

 

{
"url": "http://google.com",
"findings": [
"1",
"1",
"7",
[],
"3",
"05-05-2015",
null,
[]
]
}

 

Do you know how to display the element names inside the array?

 

Thanks.

Anonymous
Not applicable
Author

OK, I have built the following dummy structure.....

 

{"rootTag":{"newColumn1":"IH4IST","newColumn2":[{"newColumn3":"IqGyhp","newColumn4":"ULsg8G"}]}}

....using this configuration.....

0683p000009Lt8Z.png

 

Basically, add an element called "element", assign it a class of object and add your fields to that element. That should do it.

Anonymous
Not applicable
Author

Thank you, It works 0683p000009MACn.png

Gattuchaitanya
Contributor
Contributor

@rhall  Could you please let me know how to configure multiple array objects

my expected output is as below

{
"_id": "123",
"cabins": [
{
"cabin_Id": "12434",
"name": "Cabin 1"
},
{
"cabin_Id": "8765",
"name": "Cabin 3"
}
],
"country": "FR",
"departments": [
{
"dept_id": "123",
"name": "Computers"
},
{
"dept_id": "345",
"name": "arch"
}
]
}