java - Is it possible to let Play Framework 1 handle a sent JSON in a post request? -
is possible let play framework 1 handle sent json in post request? developer connecting backend not send in key/value pairs ampersand separator, wants send in json. problem data null, i.e name
null. possible achieve?
what have far:
controller
public static void mymethod(string name) { logger.info(name); }
routes file
post /test application.mymethod
and send request header content-type: application/json
, data in body { "name": "a name" }
i did not find auto binding did this:
mymodel mymodel = new gsonbuilder().create().fromjson(new inputstreamreader(request.body), mymodel.class);
and worked perfectly!
Comments
Post a Comment