简体   繁体   中英

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

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?

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")),           
    }
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM