title: How to loop over all the headers in hl7 message in mirth?
body: <p>I'm new to mirth and trying to loop over all the hl7 message headers in mirth,
  I know that I can loop over one header like this: </p>
  
  <pre><code>for each(var OBX in msg['OBX']) {
      logger.info('message OBX obj: ' + OBX['OBX.3']['OBX.3.2'].toString());
  }
  </code></pre>
  
  <p>but what I need is to loop over all the headers not one so I'm trying to do something like this: </p>
  
  <pre><code>for each(var header in msg) {
          logger.info('message header: ' + header.toString());
  }
  
  for each(var header in msg['HL7Message']) {
      logger.info('message header: ' + header.toString());
  }
  </code></pre>
  
  <p>but this is not working and also I can't convert the hl7 to json please help and many thanks in advance.</p>