We can use apache camel, camel is a very easy and extensible solution to this,
This will give json objects, after which we can parse the json objects, then get the values.
XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();
xmlJsonFormat.setEncoding("UTF-8");
xmlJsonFormat.setForceTopLevelObject(true);
xmlJsonFormat.setTrimSpaces(true);
xmlJsonFormat.setRootName("newRoot");
xmlJsonFormat.setSkipNamespaces(true);
xmlJsonFormat.setRemoveNamespacePrefixes(true);
// xmlJsonFormat.setExpandableProperties(Arrays.asList("d", "e"));
from("file:sftpdata/x12files")
.log("Before unmarshal with SmooksDataFormat:").log("${body}")
.unmarshal(new SmooksDataFormat("smooks-config1.xml"))
.log("After unmarshal with SmooksDataFormat:").log("${body}")
.marshal(xmlJsonFormat)
.log("After marshalling with Json library:").log("${body}")
.process(new X12Processor()).log("X12 file processed")
.to("mock:result");
source
share