scala - problems with handeling Json request in play -
i'm trying make server can handle http requests json. sorry if haver. i'm still new this. so, made function takes jsvalue , working it.
def find(info: jsvalue) = { val req = search.makerequest("person",info) val result = db.withconnection { implicit c => sql(req).as(person *) } json.tojson(result) }
then this:
val test = json.parse("""{"name":"john"}""") person.find(test)
it works fine. try call function http request:
routes file:
get /findperson controllers.personcontroller.findperson(info: string)
controller:
def findperson(info: string) = action { ok(person.find(json.parse(info))) }
actual request:
http://localhost:9000/findperson?info="""{"name":"john"}"""
i get:
exception: malformed json: got sequence of jsvalue outside array or object.
can tell me how right? please.
although agree @ryan unusual thing want do, think problem having message says, "malformed json". remember url parameter not source code, it's simple string. there's no need escape quotation marks. try using url:
http://localhost:9000/findperson?info={"name":"john"}
Comments
Post a Comment