I use play json library to process json objects in Scala. In order to get a field id
from the json object, I run this code:
val id = json \ "id"
Then I want to convert id
into a String. I tried id.get.toString
but instead of doi:10.1186-s13612-016-0045-3
I got JsDefined("doi:10.1186-s13612-016-0045-3")
How to convert it into a String?
Slightly shorter:
(json \ "id").as[String]
Try
(json \ "id").as[JsString].value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With