how to see content of a javascript array including objects at source section of a channel in Mirth Connect

1k views Asked by At

I have a javascript array including objects and arrays comprise some objects in my channel source in Mirth 3.5.1.For instance:

var sql= "SELECT prop1,prop2,prop3,prop4,prop5,prop6 from ANYTABLE";

var res = dbConn.executeCachedQuery(sql);

var Array1 = [];

Obj1 = {
  Prop1: res.getString("Prop1"),
  Prop2: res.getString("Prop2"),
  Prop3: res.getString("Prop2"),

  Array2:[
    {
      Prop4:res.getString("Prop4"),           
      Prop5:res.getString("Prop5"),           
      Prop6:res.getString("Prop6"),           
    }
  ]
}

Array1.push(Obj1);  

logger.info(Array1)  //??

Now I could not achieve to see contents of the objects of Array1 using logger.info()in my server log placed under the dashboard screen.

Are there any solutions or trick to do it?

1

There are 1 answers

0
Nick Rupley On BEST ANSWER

Convert it to a string first:

logger.info(JSON.stringify(Array1));

You may also need to ensure all the objects at JavaScript rather than Java objects, since JSON.stringify requires objects to implement a toJSON method.

Obj1 = {
  Prop1: String(res.getString("Prop1")),
  Prop2: String(res.getString("Prop2")),
  Prop3: String(res.getString("Prop3")),

  Array2: [
    {
      Prop4: String(res.getString("Prop4")),           
      Prop5: String(res.getString("Prop5")),           
      Prop6: String(res.getString("Prop6")),           
    }
  ]
}