How to process a JSON payload with drop wizard?
Check out Jackson.
ObjectMapper mapper = new ObjectMapper();Thing impl = mapper.readValue(username, Thing.class);
As long as username
is valid JSON and maps to Thing
, this should work.
Note: You may have to annotate the class members or methods of Thing
. For example in my case I had to manage circular references using com.fasterxml.jackson.annotation.JsonManagedReference
. But you can read up about this and other annotations in the API documentation.