-1

I have this variable in scala with

val id: Option[(String, JsValue)]= Some((studentId,{"courseId":"765"}))

I want to retrieve that id 765 but I am not able to make it happen. Thank you in advance.

cbley
  • 4,538
  • 1
  • 17
  • 32

1 Answers1

3

Please refer this to know more about play json basics.
Here is a quick but dirty way
val cid = id.map{ jscid => (jscid._2 \ "courseId").as[String]}.get
It will give you
cid: String = 765.
Beware of .as and .get . Put your validation and error handling.

asanand
  • 404
  • 3
  • 8