You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Brice Frisco (Jira)" <ji...@apache.org> on 2023/03/13 20:24:00 UTC
[jira] [Created] (CAMEL-19143) Bindy - Add option to automatically quote field if it contains chosen separator during marshalling
Brice Frisco created CAMEL-19143:
------------------------------------
Summary: Bindy - Add option to automatically quote field if it contains chosen separator during marshalling
Key: CAMEL-19143
URL: https://issues.apache.org/jira/browse/CAMEL-19143
Project: Camel
Issue Type: New Feature
Components: camel-bindy
Affects Versions: 3.20.1
Reporter: Brice Frisco
Attachments: image-2023-03-13-15-14-28-952.png
Given a POJO such as:
{code:java}
@CsvRecord(generateHeaderColumns = true, separator = ",")
public class SomeOutput {
@DataField(columnName = "hello", pos = 1)
private String hello = "Hello,";
@DataField(columnName = "world", pos = 2)
private String world = "World!";
// getters and setters
}{code}
And a route such as:
{code:java}
from("timer://test?repeatCount=1")
.setBody(constant(new SampleOutput()))
.marshal(CSV_FORMAT)
.log("${body}"); {code}
Bindy produces this output:
{code:java}
hello,world
Hello,,World! {code}
Which looks like the following in CSV format:
!image-2023-03-13-15-14-28-952.png!
Fields which contain the chosen separator are not automatically escaped or quoted. One workaround to this is to add `quoting=true` to the `CsvRecord`, which will quote all fields.
I think it would be nice if an option existed that would quote fields only when it is necessary, which can reduce the file size. This method of dynamic quoting is the way it is handled by default in Excel on Windows systems.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)