Can I use the JSON library without installing Play?

In mine 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 I use in the code import play.api.libs.json._, but the compiler gives the error message "not found: object play". Obviously, I did not install the game. Can I use the library play-jsonwithout installing Play?

+4
source share
1 answer

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 play play-json without Play. If it does not work in your project, try restarting SBT or performing a cleanup, reboot, upgrade, compilation in SBT.

+8
source

All Articles