jaxrs-csv

A JaxRs extension to manage text/csv media type

License

License

Categories

Categories

CSV Data Data Formats
GroupId

GroupId

io.github.binout
ArtifactId

ArtifactId

jaxrs-csv
Last Version

Last Version

0.9
Release Date

Release Date

Type

Type

jar
Description

Description

jaxrs-csv
A JaxRs extension to manage text/csv media type
Project URL

Project URL

https://github.com/binout/jaxrs-csv
Source Code Management

Source Code Management

https://github.com/binout/jaxrs-csv

Download jaxrs-csv

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.binout/jaxrs-csv/ -->
<dependency>
    <groupId>io.github.binout</groupId>
    <artifactId>jaxrs-csv</artifactId>
    <version>0.9</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.binout/jaxrs-csv/
implementation 'io.github.binout:jaxrs-csv:0.9'
// https://jarcasting.com/artifacts/io.github.binout/jaxrs-csv/
implementation ("io.github.binout:jaxrs-csv:0.9")
'io.github.binout:jaxrs-csv:jar:0.9'
<dependency org="io.github.binout" name="jaxrs-csv" rev="0.9">
  <artifact name="jaxrs-csv" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.binout', module='jaxrs-csv', version='0.9')
)
libraryDependencies += "io.github.binout" % "jaxrs-csv" % "0.9"
[io.github.binout/jaxrs-csv "0.9"]

Dependencies

compile (1)

Group / Artifact Type Version
com.fasterxml.jackson.dataformat : jackson-dataformat-csv jar 2.4.1

provided (1)

Group / Artifact Type Version
javax.ws.rs : javax.ws.rs-api jar 2.0.1

test (7)

Group / Artifact Type Version
org.testng : testng jar 6.8
org.assertj : assertj-core jar 3.2.0
org.jboss.arquillian.testng : arquillian-testng-container jar
org.jboss.shrinkwrap.resolver : shrinkwrap-resolver-impl-maven jar
org.apache.openejb : arquillian-tomee-embedded jar 1.7.2
org.apache.openejb : tomee-jaxrs jar 1.7.2
com.github.kevinsawicki : http-request jar 5.5

Project Modules

There are no modules declared in this project.

Jaxrs-csv

A JAX-RS provider to manage text/csv media type

MessageBodyWriter/Reader

The project provides an instance of MessageBodyReader and MessageBodyWriter for text/csv.

Example of resource

@Path("/persons")
public class PersonResouce {

    private static List<Person> repository = new ArrayList<>();

    @GET
    @Produces("text/csv")
    public Response get() {
        return Response.ok(repository).build();
    }

    @POST
    @Consumes("text/csv")
    public Response post(List<Person> persons) {
        repository.addAll(persons);
        return Response.ok().build();
    }
}

CSV Schema configuration

  • Define order of CSV columns :

@CsvSchema(columns = { "firstName", "lastName", "age" })
public class Person {

    private String firstName;
    private String lastName;
    private int age;
}
  • Default CSV separator is : ;. If you want to use another separator, you can override it :

@CsvSchema(separator=',',
           columns = { "firstName", "lastName", "age" })
public class Person {

    private String firstName;
    private String lastName;
    private int age;
}
  • You can skip the first row during parsing (default is false). Needed to support CSV-like file formats that include additional non-data content before real data begins)

@CsvSchema(separator=',',
           columns = { "firstName", "lastName", "age" },
           skipFirstDataRow = true)
public class Person {

    private String firstName;
    private String lastName;
    private int age;
}

TODO

  • Configure CSV Schema

    • header or not

    • default value for null java value

Versions

Version
0.9