passing javascript object from one channel to other channel in mirth -
in channel a getting xml input.incoming xml mentioned below:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <bookstore> <books> <book> <title>springinaction</title> <noofcopies>10</noofcopies> </book> <book> <title>hibernateinaction</title> <noofcopies>8</noofcopies> </book> <book> <title>jsfinaction</title> <noofcopies>5</noofcopies> </book> <book> <title>strutsinaction</title> <noofcopies>9</noofcopies> </book> <book> <title>jspinaction</title> <noofcopies>4</noofcopies> </book> </books> </bookstore>
i parsing xml in edit transformer of source , making javascript object , putting javascript object channel map this:
var book=new object(); book.title = msg['books']['book'][0]['title'].tostring(); book.copies = msg['books']['book'][0]['noofcopies'].tostring(); logger.info("book "+book); channelmap.put("book",book);
now want pass javascript object other channel b destination of channel a , channel b receives javascript object input , rest of processing .is possible in mirth?
i using mirth version 2.2.1.5861.
before saving channel variable, serialize (json object).
in channel destination, write out "book" variable.
so this:
in transformer
var book=new object(); book.title = msg['books']['book'][0]['title'].tostring(); book.copies = msg['books']['book'][0]['noofcopies'].tostring(); logger.info("book "+book); var jbook = json.stringify(book); channelmap.put("jbook",jbook );
in destination template
${jbook}
then on receiving channel
var book = json.parse(msg.tostring());
i have not verified code, should give coding strategy.
also: please see our healthcareit project proposal @ area51.stackexchange. question ask.
Comments
Post a Comment