No announcement yet.

Why does Connect 3.9 generate XML instead of JSON? How to send custom JSON?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Why does Connect 3.9 generate XML instead of JSON? How to send custom JSON?

    Hi all, another newbie joining the forum, trying to get a handle on his awesome tool.

    I read pages over pages of docs, presentations and forum posts, but I still have some questions. I hope I can find some answers here.

    Use case 1: write HL7v2 as JSON to file

    I created a channel with source "TCP Listener" and destination "File Writer"
    The "data types" are HL7-HL7 for source and HL7-JSON for destination.
    I put ${message.rawData} and ${message.transformedData} into "Template".
    But instead of HL7v2 and JSON I get HL7v2 and XML in the file???

    Use case 2: forward HL7v2 as custom JSON message with HTTP

    Instead of writing the full message, I would like to hand pick some values like case-id and send it via HTTP.
    How would I structure this? Would I choose HL7-HL7 for source and HL7-JSON for destination in "Set Data Types"?
    Would I then use "Transformer" or "Response Transformer" to build an empty JSON message?
    How would I add "msg['PV1']['PV1.19']['PV1.19.1']"?
    What should be placed in HTTP "Content" to send?

    Use case 3: forward HL7v2 selectively

    I would like to to send messages depending on department to different HTTP servers.
    I imagine I can just create a destination filter for this?
    Any special requirements when combining with use case 2 (filter + custom message)?

    In general I think I am missing the big picture. What is the internal format between source/destination? Is it always the same?
    When I set "Summary" "Set Data Types", does this have an impact on internal communication?
    Is the input always "msg" and the output always "tmp" for (Response) Transformer? Is there an output for Filters besides true/false?
    Can I put logic in the "Template" or "Content" field of destinations? Or should that only be in (Response) Transformer?


  • #2
    Question 1, you have to build the transformation, mirth doesn't "convert" from one format to another like that.

    Question 2, you answered your own question 1 really. On the source tab you consume HL7, in its transformer you can build (transform) fields as needed that then get sent to destinations. So you set datatypes like the below screenshot. Be mindful transforms can be done elsewhere of course.

    Screen Shot 2020-07-28 at 9.04.54 PM.png

    Question 3, Destination Set Filtering works well for that.

    I'd take the mirth classes if you can. There are plenty of forum examples and YouTube videos that show this stuff.

    Attached Files
    Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
    Diridium Technologies, Inc.


    • #3
      Hi Pacmano,

      thanks for your response. I might seem lazy, but I searched the forum again, read about 50 messages and nothing solves the basic JSON question for me.

      1. It would be great to have another forum called "Examples" where people can post working examples, this would make it a lot faster to find best practice and reduce messages here.

      2. I changed the datatypes to HL7-JSON JSON-JSON and still get XML. I can't wrap my head around this, it doesn't make sense to me.

      3. Could you post a link to a good example or supply the probably 5 lines of transform code needed to create a selective JSON to forward?
      What would I put into the "Content" field? I am happy to write JS, not sure about all those maps.

      Thanks again!


      • #4
        Seriously, how hard did you look? even has a channel to download that you can import. In the destination transformer it builds a JSON object right there.

        Post #6 on that thread.
        Last edited by pacmano; 07-29-2020, 09:05 AM.
        Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
        Diridium Technologies, Inc.