Hi I am working with Mule Studio and I want to create a Custom Transformer which will convert XML to Json using Google Gson Library. So in this case i have to add a Java Transformer component and i have to write a custom code for that. But the problem i am facing is i am overriding the method which accepts Input parameter as Object thats the only way i think or is their any other way which will accept Input Parameter as a XMl String. Please share a code to make it workable.
public class Transfomer extends AbstractTransformer
{
protected Object doTransform(Object src, String enc) throws TransformerException {
// TODO Auto-generated method stub
return null;
}
}
Take a look at an existing transformer: https://github.com/mulesoft/mule/blob/mule-3.x/modules/xml/src/main/java/org/mule/module/xml/transformer/XmlPrettyPrinter.java
registerSourceType(DataTypeFactory.create(org.dom4j.Document.class));
doTransform
method the genericObject src
is converted.