Handle an array of POJO in JSON via jersey

255 views Asked by At

My server receives a JSON array via POST

[{"name" : "foo", "price" : 15.0, "time" : 123130283812}, {"name" : "bar", "price" : 15.8, "time" : 123130283812}]

I want my method to handle this parameter so I create

private static class PriceInfo {
    @FormParam("name")
    public String name;
    @FormParam("price")
    public Double price;
    @FormParam("time")
    public Long time;
}

@POST
@Path("handlePrice")
public Map handlePrice(@FormParam("prices") List<PriceInfo> prices) {
}

When I try to start the server, I get the following complaint

SEVERE: Missing dependency for method public java.util.Map com.blah.foo.PriceHandler.handlePrice(java.util.List) at parameter at index 0 SEVERE: Method public java.util.Map com.blah.foo.PriceHandler.handlePrice(java.util.List), annotated with POST of class com.blah.foo.PriceHandler, is not recognized as a valid resource method.

I am missing something fundamental? Shouldn't jersey see my PriceInfo class and dive into it?

0

There are 0 answers