Jersey, how to POST a list of JSON objects?

前端 未结 5 1357
栀梦
栀梦 2021-02-05 22:25

I am building a RESTful web-service in Java using Jersey 1.11, and have problems implementing a method which consumes a list of JSON-ised entities. The single instance method wo

5条回答
  •  清酒与你
    2021-02-05 23:05

    Wrapper class works. MyEntity[] myEnts doesn't work.

    This is what I did and it worked.

    public String createBatch(@PathParam("someParam") String someParam,
                                                      String content)
    

    Use ObjectMapper to convert to List of objects.

    List entities = om.readValue(content, 
                                           new TypeReference>(){}).
    

提交回复
热议问题