【发布时间】:2018-11-23 04:13:34
【问题描述】:
我想在 dropwizard 中获取带有 Java/Jersey 对象列表的内容 JSON 正文
考虑json体
{
"tag1" : "value",
"parameter" : [
{
"name":"value1",
"content":"value2"
},
{
"name":"value1",
"content":"value2"
}
]
}
我尝试以
的身份接收请求 @POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response insertJob(
@PathParam("tag1")
String tag1,
@JsonProperty("parameter")
List<RequestParameter> parameter
) {
return Response.ok(parameter).build();
}
但我只收到"message": "Unable to process JSON"。当我将正文更改为仅列表时
[
{
"name":"value1",
"content":"value2"
},
{
"name":"value1",
"content":"value2"
}
]
和java代码
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response insertJob(
List<RequestParameter> parameter
) {
return Response.ok(parameter).build();
}
我能够接收列表中的内容。如果列表有标签,我如何获取内容
【问题讨论】: