Camel Route:
<camelContext xmlns="http://camel.apache.org/schema/spring"> <dataFormats> <xmljson id="xmljson" /> </dataFormats> <route id="route1"> <from uri="file:C:/Users/User1/InputXML"/> <to uri="activemq:queue:MyThread1"/> </route> <route id="route2"> <from uri="activemq:queue:MyThread1"/> <marshal ref="xmljson"/> <bean ref="com.test.OutputProcessor"/> </route> </camelContext>
XML input:
<?xml version="1.0" encoding="UTF-8"?> <Message> <to> Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </Message>
Actual output:
{"to":" Tove","from":"Jani","heading":"Reminder","body":"Don't forget me this weekend!"}
I want to configure this output. I want to add some mote attributes to converted json. For example, I want json output as
{ "inputs":[ { "inputname":"to", "inputValue":"Tove" }, { "inputname":"from", "inputValue":"jani" }, { "inputname":"heading", "inputValue":"Reminder" }, { "inputname":"body", "inputValue":"Don't forget me this weekend!" } ] }
How can this be achieved?
json xml xml-parsing apache-camel
Kmrgtm
source share