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.
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.
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.