0

I've got a bit stuck with trying to figure out how to process nested JSON in JAX-RS @POST method. I'm using JAX-RS 1.1 & Jersey 1.8 RI (Jackson 1.7.1) as provided in Netbeans 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. 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/

eg

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

....

}

Any assistance appreciated. thanks

  • I'm not sure if it helps but see my [recent question](http://stackoverflow.com/questions/27411148/consumes-doesnt-work-with-json). – Everv0id Dec 22 '14 at 06:58
  • Have tried simply using `Map`? This should work for unknown structures. You will of course need to make sure you have the json support enabled. That requires the `jersey-json` dependency, along with a simple configuration, as seen [here](http://stackoverflow.com/a/27355016/2587435) – Paul Samsotha Dec 22 '14 at 07:21
  • Hey thanks guys. I've just got it working by using InputStream as the input to the post method – Andrew Humphries Dec 22 '14 at 07:26
  • Why don't you post it as an answer. I don't think any one is going to message you. SO has no messaging capabilities. – Paul Samsotha Dec 22 '14 at 10:59

1 Answers1

0

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. Works a treat.