How to convert XML Pipeline to JSON?

Hi everyone.

We would like to know about how to convert the XML generated by Software AG Designer.

See the example below:

<IDataXMLCoder version="1.0">
  <record javaclass="com.wm.util.Values">
    <value name="IFRESULT">Z</value>
    <value name="IFMESSAGE">Great</value>
  </record>
</IDataXMLCoder>

Is there a way to convert the above information to JSON?

We are currently developing a Python program that will try to do this conversion. But, first, we would like to know if this already exists.

Thanks in advance :smiley:

if you have a document structure in IS, just call pub.json:documentToJSONString to have the json string.

1 Like

Hi Renan

Yes. webMethods Java API comes with “com.wm.util.coder.XMLCoderWrapper” class which can be used to achieve what you are seeking. It is a 2 step process:

  • Write a java service (sample below) to convert your XML decoder file into proper IData
  • Convert IData into JSON using the “pub.json:documentToJSONString” service like Tong advised or if comfortable with Java it can be converted to JSON in same java service above using “com.wm.util.coder.IDataJSONCoder” class.

If my understanding is correct, you are expecting response something like in the image file attached.


  IDataMap pipeMap = new IDataMap(pipeline);
		String pipeXML = pipeMap.getAsString("pipeXML");
		com.wm.util.coder.XMLCoderWrapper xmlCoder = new com.wm.util.coder.XMLCoderWrapper();
		try{
			IData pipeData = xmlCoder.decode(new ByteArrayInputStream(pipeXML.getBytes(StandardCharsets.UTF_8)));
			pipeMap.put("pipeData", pipeData);
		}catch(Exception e){
			throw new ServiceException(e);
		}

2 Likes

Thanks Prasad, very interesting code to convert the xml to IData!

@Renan, Add the below import statements for the above code to work.

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import com.softwareag.util.IDataMap;

1 Like

All of you are great!!

Thank you so much! This was exactly what we are searching for. It would be tough if we tried to do this using Python.

Have a great day!