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: 
inico
Contributor
Contributor

Translate JSON item fields (names and values) into XML tags and values

Hi,

I have the implement the following: job data comes in JSON format and is transferred to another system in XML format.

A simplified sample of input looks like this:

 

[
   {
         "job": {
         "title": "test job",
         "items": [
            {
               "item": {
                  "type": "list",
                  "name": "MGR_MAIL",
                  "value": [
                     "manager@company.com"
                  ]
               }
            },
            {
               "item": {
                  "type": "string",
                  "name": "JOB_TYPE",
                  "value": "permanent"
               }
            },
            {
               "item": {
                  "type": "date",
                  "name": "JOB_START_DATE",
                  "value": "2018-08-07T20:00:00.000Z"
               }
            }
         ]
      }
   }
]

 

The output should be something like this:

 

<Data>
    <Job>
	<JobTitle>"test job"</JobTitle>
	<JOB_TYPE>"permanent"</JOB_TYPE>
        <JOB_START_DATE>2018-08-07</JOB_START_DATE> 
        <ManagerInfo>
            <MGR_MAIL>
                <EmailAddress>"manager@company.com"</EmailAddress> 
            </MGR_MAIL>
        </ManagerInfo>
    </Job>
</Data>

 

I am struggling with translating the item names and values into XML tags and values.

The number of items is around 40, and may not be always the same.

There are two situations:

1. Item name in json corresponds to the xml tags.
2. Item name in json does not correspond to the xml tags.

Could anyone provide some guidance how to deal with either of these cases?

Please see attached what I tried. It is not elegant, and I'm not sure how to proceed with the results in tLogRow_3 to transpose them. After that, I plan to merge with tLogRow_2 in a tMap, and write to tAdvancedOutputXML.

Regards,

Jo

Labels (4)
0 Replies