0

http://www.playframework.com/documentation/2.1.x/ScalaJson

That document says the idiomatic style of json creation is:

import play.api.libs.json.Json
Json.obj( "key" -> "value )

However this fails to compile as String -> String is not String -> Json.JsValueWrapper

It appears that play provides the code needed for implicit conversions in play.api.libs.json.{DefaultReads, DefaultWrites}

How do I get these implicit conversions into scope?

1 Answer 1

1

You've misspelt your import statement; it should be import play.api.libs.json.Json (it's important to remember Scala is case-sensitive). Fixing that, the code works:

scala> :paste
// Entering paste mode (ctrl-D to finish)

import play.api.libs.json.Json
Json.obj("key" -> "value")

// Exiting paste mode, now interpreting.

import play.api.libs.json.Json
res0: play.api.libs.json.JsObject = {"key":"value"}

scala>
Sign up to request clarification or add additional context in comments.

2 Comments

That was a transcription error, not an error in the code I was running, however after trying again I'm unable to re-create the problem I've had.
It is however, a problem I've come across multiple times, so I'd really like to work out what I'm doing wrong

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.