简体   繁体   English

如何在Mirth Connect中查看通道的源部分中包含对象的javascript数组的内容

[英]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: 我在Mirth 3.5.1的通道源中有一个包含对象的javascript数组,而数组包含一些对象,例如:

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. 现在,在仪表板屏幕下方的服务器日志中,我无法使用logger.info()来查看Array1对象的内容。

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. 您可能还需要确保所有对象都使用JavaScript而不是Java对象,因为JSON.stringify要求对象实现toJSON方法。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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