web stats
Format for JSON outbound template with array - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2017, 09:36 AM
pacmano pacmano is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 99
pacmano is on a distinguished road
Default Format for JSON outbound template with array

Oversimplified:

The source, a document on disk decimal encoded as follows:

Code:
[ 12, 34, 45 ]
I need to insert this document into a JSON outbound template:

Code:
{
"File": 0       // File: "0" has no effect either 
}
But I don't want quotes around the value,

This is correct:

Code:
{
"File": [ 12, 34, 45 ]  
}
This is not correct:

Code:
{
"File": "[ 12, 34, 45 ]"  
}
I currently use:

Code:
tmp['File'] = connectorMessage.getRawData();
This does insert double quotes around the value.

What am I missing?
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com
Reply With Quote
  #2  
Old 07-17-2017, 11:35 AM
Shamil Shamil is offline
OBX.3 Kenobi
 
Join Date: May 2013
Posts: 159
Shamil is on a distinguished road
Default

getRawData() returns the raw content, as a string. And that's exactly what you are getting.
Reply With Quote
  #3  
Old 07-17-2017, 11:55 AM
pacmano pacmano is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 99
pacmano is on a distinguished road
Default

Quote:
Originally Posted by Shamil View Post
getRawData() returns the raw content, as a string. And that's exactly what you are getting.
Well...that was a hint. The fix:

Code:
tmp['File']= JSON.parse(connectorMessage.getRawData());
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:41 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation