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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Merge two strings from a Json loop into one

I am trying to merge two strings from a Json loop into one. I have the following components in play at present. 

 

tFileInputJson-->tMap-->tFileOutputDelimited. 

 

My input json document looks like

{
"columns": {
"source": "config",
"column_details": [{
"columnname": "col2",
"datatype": "float"
},
{
"columnname": "col3",
"datatype": "integer"
}
]
}

}

 

I would like to create a string in tFileOutputDelimited as 

"The result set is

convert col2 to float

convert col3 to integer"

 

However due to the loop XPath query parameter being set to "/columns/column_details" in tFileInputJson and creating the string in tMap with columnname and datatype. I get the following output 

The result set is

convert col2 to float

The result set is

convert col3 to integer

 

Any help is appreciated. Thanks

Labels (3)
1 Solution

Accepted Solutions
Jesperrekuh
Specialist
Specialist

Look at the tJavaFlex component, you have to code some java but pretty easy.
Something like below (didnt test the java code).

 

Basicly in the Pre part you set: 

String fullString = "The result set is ";

In the Main part (this will loop over all the rows) , you set :

fullString = fullString + "convert " + row.columnname + " to " + row.datatype + "\n"

 

View solution in original post

1 Reply
Jesperrekuh
Specialist
Specialist

Look at the tJavaFlex component, you have to code some java but pretty easy.
Something like below (didnt test the java code).

 

Basicly in the Pre part you set: 

String fullString = "The result set is ";

In the Main part (this will loop over all the rows) , you set :

fullString = fullString + "convert " + row.columnname + " to " + row.datatype + "\n"