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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
kakooo16
Creator
Creator

create two nested arrays

I'm having a problem using twriteJsonField component as it does not allow to specify Multiple loop element

my input is as below :

-----------------------------------------------

|Line_year | action | group | comment |

-----------------------------------------------

| 2012 | Action1 | group1| comment1|

|2020 | Action2| group2| comment2|

------------------------------------------------

Now , i want to generate this json :

_____________________________________________________

{

  "line_list":[

   {

     "line_year":"2012",

     "comment_list":[

      {

        "action":"Action1",

        "group":"group1",

        "comment":"comment1"

      }

     ]

   },

   {

     "line_year":"2020",

     "comment_list":[

      {

        "action":"Action2",

        "group":"group2",

        "comment":"comment2"

      }

     ]

   }

  ]

}

___________________________________________________________

How could i acheive this please ?

Labels (2)
4 Replies
Anonymous
Not applicable

Hi Team,

 

 tWriteJsonField does not support multiple loop elements.

 

That being said, One way to create complex json is using custom components like these here:

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

 

Best,

Yussef

kakooo16
Creator
Creator
Author

could you help do that ?

 

Anonymous
Not applicable

There are a couple of ways you can approach this.

 

  1. You can use Talend Data Mapper....but this is restricted to licensed versions
  2. You can take a look at @Jan Lolling​'s JSON components. He went through these in the post we last discussed modifying JSON on
  3. You can do this in a step by step way, using multiple tWriteJSONField components (one to deal with the inner loop and another to deal with the outer loop, then merging the content)
  4. You can use some Java, in a similar way to how I built a solution using the JSONObject, JSONArray, etc, classes. This was demo'd in the last conversation we had on this.
kakooo16
Creator
Creator
Author

Could you give me an example on how to acheive that , i have datamapper .

​​

Any solution would be appreciated . ​