Annotation Interface JsonBody


Binds the body payload into POJO via json-lib.

On a web-bound doXyz method, use this method on a parameter to get the content of the request data-bound to a bean through JSONObject.fromObject(Object) and inject it as a parameter. For example,

 @JsonResponse
 public Point doDouble(@JsonBody Point p) {
   Point pt = new Point();
   pt.x = p.x*2;
   pt.y = p.y*2;
   return pt;
 }

 public static class Point { public int x, y; }
 
Request:
 POST ..../double
 Content-Type: application/json

 {"x":10,"y":5}
 
Response:
 200 OK
 Content-Type: application/json;charset=UTF-8

 {"x":20,"y":10}
 
Author:
Kohsuke Kawaguchi
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class