简体   繁体   English

在JAX-RS POSt方法中处理嵌套JSON

[英]Processing nested JSON in JAX-RS POSt method

I've got a bit stuck with trying to figure out how to process nested JSON in JAX-RS @POST method. 我在尝试弄清楚如何在JAX-RS @POST方法中处理嵌套的JSON时有些困惑。 I'm using JAX-RS 1.1 & Jersey 1.8 RI (Jackson 1.7.1) as provided in Netbeans 7.1. 我正在使用Netbeans 7.1中提供的JAX-RS 1.1和Jersey 1.8 RI(Jackson 1.7.1)。

I'd like to implement something like in the below link, and create a structure of nested HashMaps but am not sure how to correctly access the ObjectMapper for this version of Jersey/Jackson and also what type I should pass in to my POST method to do this. 我想在下面的链接中实现类似的功能,并创建一个嵌套的HashMaps结构,但不确定如何正确访问此版本的Jersey / Jackson的ObjectMapper,以及我应该传递给POST方法的类型做这个。 I've been searching through documentation/Google all afternoon but have not been able to find anything. 我整个下午都在搜索文档/谷歌,但找不到任何东西。

https://djna.wordpress.com/2010/03/12/json-strings-no-rest-using-the-jackson-parser/ https://djna.wordpress.com/2010/03/12/json-strings-no-rest-using-the-jackson-parser/

eg 例如

@POST
@Path("/doStuff")
@Consumes(MediaType.APPLICATION_JSON)
public Response doStuff(<???> input) {

.... ....

}

Any assistance appreciated. 任何帮助表示赞赏。 thanks 谢谢

I got it working. 我知道了 Used an InputStream as the method parameter and then used the stream in place of the from file in the code on the link. 使用InputStream作为方法参数,然后使用流代替链接上代码中的from文件。 Works a treat. 工作请客。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM