2

I'm new to Scala and SBT.

I'm following this example: Play Framework

import play.api.libs.json.Json

val json: JsValue = Json.parse("""
{ 
"user": {
"name" : "toto",
"age" : 25,
"email" : "toto@jmail.com",
"isAlive" : true,
"friend" : {
  "name" : "tata",
  "age" : 20,
  "email" : "tata@coldmail.com"
 }
} 
}
""")

How do you put the dependency for this library in the build.sbt file?

I'm using the Intellij scala IDE community edition.

Thanks

scalauser
  • 449
  • 1
  • 12
  • 23

1 Answers1

3

This should already be included in a Play application. No need to add anything to the build.sbt file.

Here's how to create a new application: https://www.playframework.com/documentation/2.3.x/NewApplication

For information, here's the build.sbt that gets generated automatically when creating the app this way:

name := """app-name"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws
)

Hope this helps.

EDIT: Following your comment, according to this post, the dependency would be:

resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"    
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.4"
Community
  • 1
  • 1
dangig
  • 179
  • 7
  • Thanks @dangig , I have the community edition of Intellij which doesn't have the Play Plug-in. I just want to use the this library: **play.api.libs.json._** I have a basic SBT project set up. Can I add the dependency to the build.sbt file? This is my build.sbt file? organization := "scala" name := "HelloSBT" version := "1.0" scalaVersion := "2.9.2" – scalauser Feb 05 '15 at 08:57
  • You may try this: resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/" and then: libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.4" Source: http://stackoverflow.com/questions/19436069/adding-play-json-library-to-sbt – dangig Feb 05 '15 at 14:25
  • I've modified the answer to include this information. – dangig Feb 05 '15 at 14:39