Reputation: 1415
I am trying to parse JSON using the Lift JSON library. I have imported the library using SBT by adding the following statement to my build.sbt file:
libraryDependencies +="net.liftweb" % "lift-json" % "2.0"
I start SBT and run the Scala interpreter using the "console" command.
I then run the following two statements:
import net.liftweb.json._
parse(""" { "numbers" : [1, 2, 3, 4] } """)
After the second statement I get the following error:
<console>:11: error: not found: value parse
parse(""" { "numbers" : [1, 2, 3, 4] } """)
To make sure it is not a problem with my project I have started a clean project and only imported the Lift JSON library. With the same result. I have even tried an alternative JSON library (json4s), but it gives exactly the same problem when it gets to the parse statement :-(
I am running the following versions: Scala 2.11.2 SBT 0.13.6 Lift JSON 2.0
Any suggestions?
Upvotes: 0
Views: 1790
Reputation: 41
From the 'scala repl' with scala version 2.11.6 and one of the later versions of lift-json (http://mvnrepository.com/artifact/net.liftweb/lift-json_2.11)
Running the example from the lift-json README.md file https://github.com/lift/lift/tree/master/framework/lift-base/lift-json/
You can also add the paranamer.jar file to classpath using the ":require" (shown below) as suggested in the lift-json README.md
$ scala
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :require lift-json_2.11-3.0-M5-1.jar
Added '<absolute path to>/lift-json/lift-json_2.11-3.0-M5-1.jar' to classpath.
scala> import net.liftweb.json._
import net.liftweb.json._
scala> parse(""" { "numbers" : [1, 2, 3, 4] } """)
res0: net.liftweb.json.JValue = JObject(List(JField(numbers,JArray(List(JInt(1), JInt(2), JInt(3), JInt(4))))))
Upvotes: 1
Reputation: 13859
Lift 2.0 is pretty old. Just use 2.5 instead. Afaict 2.0 doesn't actually have a parse
method in the json
package object.
Upvotes: 2