web stats
Mirth Community - View Single Post - JSON Looping question
View Single Post
  #4  
Old 05-21-2019, 01:53 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,005
agermano is on a distinguished road
Default

Your first issue is that your counter needs to be incremented inside the while loop instead of after if you're using an index (which isn't necessary, see below.)

The += operator appends to an XMLList, but doesn't work with javascript arrays.

You have to create a new object each time.

I would change your template to an empty array:

Code:
"geneList": [],
And then try this:

Code:
var geneListQuery = executeCachedQuery(dbConn, geneQuery);

while(geneListQuery.next()){
    tmp['testDetails']['geneList'].push({
        gene: geneListQuery.getString('hgnc_symbol')
    });
}
Reply With Quote