0

Let's say I have ....

val obj: MongoDBObject = getDbObj
println(obj)

prints out:

{ "_id" : "1234", "name":"Kevin", "age":"100" }

How can I convert obj to a JsValue?

Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384

1 Answers1

2

This is how you do it for Play 2.1 (documentation)

val dbo = MongoDBObject("id" -> "0001", "name" -> "Kevin", "age" -> "100") 
val json: JsValue = Json.parse(dbo.toString)
David Holbrook
  • 1,617
  • 14
  • 18