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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Creating arrays in JSON with Talend

I was able to create this JSON strucure in Talend (with tWriteJSONField):

{
  "rootTag": {
    "authentication": {
      "token": "blablba"
    },
    "payload": {
      "update": {
        "liso": "AT",
        "dlyr": "2017",
        "delAutoModSave": "Y",
        "updateDateTime": "Y"
      }
    }
  }
}

But I don't know how to create this structure in Talend:

{
  "authentication": {
    "token": "blabla"
  },
  "payload": {
    "update": [
      {
        "liso": "AT",
        "dlyr": "2017",
        "delAutoModSave": "Y",
        "updateDateTime": "Y"
      }
    ]
  }
}

I need this to be a payload for the call to the service, How can I create the mention JSON structure with Talend?

 

Labels (3)
2 Replies
Anonymous
Not applicable
Author

Hi,

 

1-You should flag this checkbox in tWriteJsonField component:

0683p000009Lrp8.png

2-Regarding bracket issue, there is a JIRA bout it: https://jira.talendforge.org/browse/TDI-39421

 

If you have only one update line, you will get:

{
"authentication": {
"token": "blablba"
},
"payload": {
"update": {
"liso": "AT",
"dlyr": "2017",
"delAutoModSave": "Y",
"updateDateTime": "Y"
}
}
}

 

But if you have two lines, you will get:

{
"authentication": {
"token": "blablba"
},
"payload": [
{
"liso": "AT",
"dlyr": "2017",
"delAutoModSave": "Y",
"updateDateTime": "Y"
},
{
"liso": "AT",
"dlyr": "2017",
"delAutoModSave": "Y",
"updateDateTime": "Y"
}
]
}

 

3-You could use Data Mapper to get your expected structure (Even with a single update line).

 

Regards.

 

Eric

 

Anonymous
Not applicable
Author

I need it for one line. So the only option is tHmap.

Aha I see the available options:

1) Use JSON string and tReplace to correct "wrong" node types
2) Use tXmlMap to build a DOM
3) Use tJSONDocOutput from Talend Exchange
4) Use Platform / TDM