web stats
Mirth Community - View Single Post - JSON Looping question
View Single Post
  #1  
Old 05-21-2019, 06:57 AM
tdickerson tdickerson is offline
Mirth Newb
 
Join Date: Aug 2016
Posts: 6
tdickerson is on a distinguished road
Default JSON Looping question

Hi - I have a question. I am pulling information from a database and sending out a JSON message.

The template looks like this:
"geneList": [{
"gene": ""
},
{
"gene": ""
},
{
"gene": ""
}
],

My code is this:
var geneListQuery = executeCachedQuery(dbConn, geneQuery);

var geneCount = 0;

while(geneListQuery.next()){

tmp['testDetails']['geneList'][geneCount]['gene'] = geneListQuery.getString('hgnc_symbol');

}
geneCount++;

The result I am getting is this:
"geneList" : [
{
"gene" : "ZRSR2"
},
{
"gene" : ""
},
{
"gene" : ""
}
],

There are approximately 600 genes to be listed, and it is only showing the last one. Can anyone help me on this??
Reply With Quote