mardi 26 mai 2015

How to map JSON with nullable array properties to POJO using WildFly RestEasy

I have JSON

{
  "name": "volo",
  "friends": ["joe", "alex"]
}

and Java POJO

class Person {
  private String name;
  private Set<String> friends;

  //constructor, getters, setters
}

POST method:

@POST
@Consumes("application/json")
public Response createPerson(Person person) {
  //logic
}

This is work nice when POST or PUT request are coming and JSON is parsed to POJO, but when

"friends": null

WildFly RestEasy cannot parse JSON to POJO

Does anybody knows how to fix this with some annotation or additional setup?

Aucun commentaire:

Enregistrer un commentaire