Playframework Scala Async controller for JSON request -
i trying write async playframework controller receives post request , creates new object in database:
def register = action(bodyparsers.parse.json) { request => val businessinforesult = request.body.validate[businessinfo] businessinforesult.fold(errors =>{ badrequest(json.obj("status"-> "error", "message"->jserror.tojson(errors))) //error on line }, businessinfo=> { //save object ok(json.obj("status" ->"ok", "message" -> ("place '"+ businessinfo.businessname +"' saved.") )) //error on line }) }
however, keeps throwing error below:
reference json ambiguous; imported twice in same scope import play.libs.json , import play.mvc.bodyparser.json asynccontroller.scala
the errors thrown @ line 108 , 105 correspond lines commented //error on line
above (lines badrequest(..) , ok(..))
how fix issue? can using new jsvalue(map(..)) wondering if there's other way.
thank help.
rather json
, want call play.libs.json
. problem here that, considering imports in file, have 2 objects / classes called json
, compiler can't choose 1 should use. calling play.libs.json
, you'll give compiler enough information.
Comments
Post a Comment