4

I have a bean that returns an XML string, which I want to convert to JSON.

The XmlJson data format appears to be deprecated in Camel 3. What is the best way to convert XML to JSON? There are no POJO classes that can be used as an intermediate representation.

Expected code:

rest().post("/hello")
  .route()
    .to("bean:myBean?method=methodThatReturnsXML")
    .unmarshal() // something with XML
    .marshal() // something with JSON

or

rest().post("/hello")
  .route()
    .to("bean:myBean?method=methodThatReturnsXML")
    .transform() // something
juanlumn
  • 6,155
  • 2
  • 30
  • 39
Cephalopod
  • 14,632
  • 7
  • 51
  • 70
  • Alternative workaround. Hope this might help. https://stackoverflow.com/questions/49021738/alternative-to-deprecated-xmljsondataformat-in-apache-camel – Mebin Joe Apr 10 '19 at 10:01
  • We have used https://github.com/apache/camel/blob/master/core/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java, in our project to convert XML response to Json Response. – darshgohel Apr 10 '19 at 10:22
  • @MebinJoe This is basically what I am looking for except that (I believe) I can't use JAXB because I don't have a POJO class. – Cephalopod Apr 10 '19 at 10:27
  • I have the same situation here. Did you was able to solve that? If yes, could you share? Thanks – vitorvr Nov 19 '19 at 14:23
  • @Vitor I ended up createn POJO classes as intermediate representation. I found no way to do a direct conversion – Cephalopod Nov 19 '19 at 16:21
  • @Cephalopod, same here. I didn't find any way to do that. Created POJO as well. Thanks. – vitorvr Nov 20 '19 at 17:11

0 Answers0