Situation:
We have a large file that needs to be sent to an Adeptia web service provider and translated to an XML document that will be delivered to another server via HTTPS post. We want to do this via a web service because the various result messages received from the HTTPS post need to be returned to the calling system. We are considering sending the data to Adeptia in JSON format to reduce the size of the data. We are also considering using ZIP compression to further reduce the size. For this to work, we would need a JSON-to-XML conversion utility that we could call from a custom plugin.
Solution:
You can certainly do that by using the following code snippet in a Custom Plug-in. The plug-in attached will take the stream(inputStream) of previous defined activity in the Adeptia process flow and convert that stream into a JSON object.
JSON to XML
import org.json.JSONObject;
import org.json.XML;
String xml = XML.toString(new JSONObject({jsonString}));
Note – substitute actual JSON string in place of “{jsonString}”.
XML to JSON
import org.json.XML;
String jsonString = XML.toJSONObject({xmlString}).toString();
Note – substitute XML in place of “{xmlString}”.
Comments
0 comments
Article is closed for comments.