ef-labs / vertx-jersey

Run jersey in vert.x
MIT License
150 stars 47 forks source link

Add support for usage of JsonObjects and JsonArrays on REST endpoints #31

Closed ianestrachan closed 9 years ago

ianestrachan commented 9 years ago

Includes MessageBodyReaders and MessageBodyWriters to allow JsonObjects and JsonArrays to be used directly, for example: @POST @Consumes(MediaType.APPLICATION_JSON) public void doSomething(JsonObject obj)

Also includes custom serializers and deserializers for Jackson in a separate module to allow POJO parameters with JsonObject and JsonArray fields, for example:

//POJO class:
public class User {
    private JsonObject fields;
    public JsonObject getFields() { return fields; }
    public void setFields(JsonObject fields) { this.fields = fields; }
}

//And in the resource:
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void doSomething(User user) {
  //...
}

Finally, includes some examples in the example module demonstrating the use of POJOs as REST endpoint parameters.