Announcement

Collapse
No announcement yet.

JSON.Stringify() does not work in mith 3.3.0.7801

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSON.Stringify() does not work in mith 3.3.0.7801

    Hi guys,
    im trying to convert the incoming data to JSON data, Im trying to convert this data using JSON.Stringify() . But it specifies that it cannot stringify the object, I'm just pasting my sample code here.

    Code:
    var obj={};
    obj.k={
    "fathername":msg['PID']['PID.6']['PID.6.1'],
    "mothername":msg['PID']['PID.6']['PID.6.2'],
    }
    var m= JSON.Stringify(obj);
    logger.info(m);
    can you guys help me out in this?

    Mirth Interface Engineer
    AWS DevOps

  • #2
    Checkout the new API for JsonUtil. I don't believe stringify is necessary any longer.

    Mirth Connect has always supported JSON, since you can call "JSON.parse" and "JSON.stringify" directly in JavaScript. However now in 3.3, we've added a new JSON data type to make working with it even easier!
    JSON-specific syntax highlighting and message tree structure
    The "msg" and "tmp" variables in filters/transformers will automatically be converted to/from JavaScript objects. No need to call parse or stringify!
    A new JsonUtil utility class was added, so you can easily pretty print JSON data before sending it out.

    Comment


    • #3
      You may need to do the following:
      "fathername":msg['PID']['PID.6']['PID.6.1'].toString()

      Comment


      • #4
        Thanks Guys

        Yeah, Thats a better improvement in mirth 3.3.0.7801, there is no need to include JSON.Stringify() function. Just including .toString() to th message and logging the object works for me. Thanks for the info guys.

        Mirth Interface Engineer
        AWS DevOps

        Comment


        • #5
          The reason why you needed to add toString() is because by default the E4X XML prototype does not implement toJSON, which is what stringify uses to convert an object to a JSON string. This was a problem even in earlier versions, not just 3.3. It will be addressed in 3.3.1: MIRTH-3796
          Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

          Nicholas Rupley
          Work: 949-237-6069
          Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


          - How do I foo?
          - You just bar.

          Comment

          Working...
          X