apacheapache-camel

Exporting key value pairs in CSV using Camel


I am trying to export a java object into CSV file using Camel CSV documentation. I can see example

Map<String, Object> body = new HashMap<String, Object>();
body.put("foo", "abc");
body.put("bar", 123);

... through this route ...

from("direct:start").
marshal().csv().
to("mock:result");

This prints abc,123 But i want both keys and Values in my CSV. Can you please help me on this..


Solution

  • You need to set the option autogenColumns to true so the keys is outputted as well. Read the documentation