There are times when I want to create a data structure in Mirth, and output the contents of that data structure while debugging the code. Luckily, JSON.stringify() is available not only in modern browsers but also in Mirth.
var o = { mrn: '8675309', labs: [ 'blood bank', 'microbiology', 'toxicology' ] }; console.log(JSON.stringify(o, null, 't'));
However, there are any types of Mirth mapped variables, the JSON.stringify() method blows up on itself with a message similar to
DETAILS: Java class "[B" has no public instance field or method named "toJSON".
This is how we fix it.
Recent Comments