4

In my build.sbt:

lazy val commonSettings = Seq(
  version := "1.0.0",
  scalaVersion := "2.11.6"
)
lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    name := "myapp",
    libraryDependencies ++= Seq(
      "com.typesafe.play" % "play-json_2.11" % "2.3.4",
      "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
      "junit" % "junit" % "4.12" % "test"
    )
  )
resolvers ++= Seq("Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/")

It compiles well. Now in code I use import play.api.libs.json._ but the compiler gives error saying "not found: object play". Obviously I did not install play. Is it possible to use play-json library without installing Play?

Stephan Rozinsky
  • 553
  • 2
  • 6
  • 21

1 Answers1

8

Consider this simple sbt project:

build.sbt

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-json" % "2.3.4"
)

resolvers ++= Seq("Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/")

Then you can run:

sbt console
import play.api.libs.json._
Json.parse("{}")
> res0: play.api.libs.json.JsValue = {}

Yes, you can have play-json without Play. If it is not working in your project, try restarting SBT or do clean, reload, update, compile in SBT.

Zeimyth
  • 1,389
  • 12
  • 19