Adding Play JSON Library to sbt

24,021

Solution 1

Play 2.3 JSON with SBT >= 0.13.5

put into build.sbt:

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

Play 2.1

build.sbt:

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

scalaVersion := "2.10.2"

libraryDependencies += "play" % "play_2.10" % "2.1.0"

Play JSON is in Play 2.1 not an independent artifact.

Solution 2

Play 2.2 is out and can be added separately from rest of Play Framework. in build.sbt:

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

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.2.1"

Solution 3

This worked for me (scala 2.11)

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

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.0"

Solution 4

You can use the following to get the Play JSON library:

addSbtPlugin("play" % "play-json" % "2.2-SNAPSHOT")

You may also have to include the following resolver:

"Mandubian repository snapshots" at "https://github.com/mandubian/mandubian-mvn/raw/master/snapshots/"

Here's where I originally got the info: http://mandubian.com/2013/02/21/play-json-stand-alone/

Solution 5

One could check the Getting Started section of the GitHub repository and add the following to the build.sbt file:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.0-M1"
Share:
24,021

Related videos on Youtube

Kevin Meredith
Author by

Kevin Meredith

Scala developer Haskell student https://www.linkedin.com/pub/kevin-meredith/11/22a/334

Updated on July 09, 2022

Comments

  • Kevin Meredith
    Kevin Meredith almost 2 years

    How can I add the Play JSON library (play.api.libs.json) to my sbt project?

    When I added the following to my plugins.sbt file:

    addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
    

    I faced this error:

    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]  ::          UNRESOLVED DEPENDENCIES         ::
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]  :: play#sbt-plugin;2.1.0: not found
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    

    I did not find a resolver for this library, otherwise I would've added it and ran sbt update. Note that my resolvers includes http://repo.typesafe.com/typesafe/releases/.

    • Blankman
      Blankman almost 10 years
      Kevin, can you change your answer b/c now you can in play 2.2.
    • Kevin Meredith
      Kevin Meredith over 9 years
      Hi Blankman. I think that the below answer handles play 2.2, no?
    • Blankman
      Blankman over 9 years
      I can't edit and change the answer, it seems to be locked.
  • Kevin Meredith
    Kevin Meredith over 10 years
    Hmm I got a missing dependency error from adding the 1 liner. Any way to avoid the git link?
  • reggoodwin
    reggoodwin over 10 years
    Now available truly standalone as "com.typesafe.play" %% "play-json" % "2.2.0". See comment by Mandubian in that blog post link "since play 2.2, you don't need my repo anymore"
  • Stephen
    Stephen over 10 years
    Just what I wanted to find - Perfect timing on your answer!
  • Schleichardt
    Schleichardt about 10 years
    At the time of writing this was true, not it is an independent lib.
  • Kevin Meredith
    Kevin Meredith almost 10 years
    +1. After updating your build.sbt with @Carolis's answer, remember to reload in sbt.
  • Blankman
    Blankman over 9 years
    @JeroenKransen I can't change the answer, it is locked.
  • Brent Faust
    Brent Faust about 9 years
    Excellent. But only works with Scala 2.10 (see @Raul's answer for 2.11+ compatibility).
  • Brent Faust
    Brent Faust about 9 years
    The only answer thus far that works with Scala 2.11.
  • BradLaney
    BradLaney about 8 years
    Doesn't work for me. Using sbt 13.11. It cannot find com.typesafe.play#play-json_2.10;2.3.4. Probably due to me scala version being 2.10.5. I had to add the typesafe repo
  • Schleichardt
    Schleichardt about 8 years
    on Maven Central is this version: search.maven.org/…
  • yair
    yair about 8 years
    had to add the resolvers += ... line even for Play 2.3 and SBT > 0.13.5, and reload. Then worked.
  • ps0604
    ps0604 over 7 years
    I didn't need to add the resolvers line. By the way, current version is 2.5.4, not 2.3.0.