3

I am currently working with Apache Camel and I am creating a route in which I am parsing XML and enriching it with JSON string. So far so good. After enrichment I am joining JSON strings. First idea was to use ArrayList and the other one was to use string separated by comma. This was no problem, but I need to return JSON object which is then used by REST

Here is piece of my class:

public class MyBean {

private String jsonStrings;
List<String> jsonStringsArray = new ArrayList<String>();

public void addEnrichSourceToString(Exchange exchange) {
    Boolean isCompleted = (Boolean) exchange.getProperty("CamelSplitComplete");
    String incomingString = exchange.getIn().getBody(String.class);

    this.jsonStringsArray.add(exchange.getIn().getBody(String.class));
    this.jsonStrings += incomingString + ",";

    if (isCompleted) {
        this.jsonStrings = "{\"MyNode\": [" + this.jsonStrings.substring(4, this.jsonStrings.length() - 1) + "]}";
        exchange.getOut().setBody(this.jsonStrings);
    }
}
}

Thanks a lot

Jamalissimo
  • 127
  • 3
  • 13

1 Answers1

-3

I don't see any question here. If you want to know how to unmarshal to a POJO, just read the camel json page. It has enough details.

Also, see this thread on stackoverflow.

Community
  • 1
  • 1
U2one
  • 381
  • 2
  • 6