Cool, thanks Joni.  I'll give it a try.

On Thu, Oct 1, 2009 at 2:36 AM, Joni Freeman <freeman.j...@gmail.com> wrote:

>
> Hi,
>
> I pasted this to scala console and it worked. I am pretty sure that
> the problem is that your case classes are inner classes. Inner classes
> get one extra implicit constructor parameter, a reference to the outer
> class (same way as in Java). You need to move those case classes away
> from enclosing class (to an object or package etc.).
>
> The error message is very bad in this case. I will fix it.
>
> Cheers Joni
>
> On Oct 1, 7:49 am, Lincoln <linxbet...@gmail.com> wrote:
> > Hi, I've been playing around with lift-json and I keep running into basic
> > problems.  I'm hoping someone can point out my mistake.
> > I'm using "net.liftweb" % "lift-json" % "1.1-M5"
> >
> > Here's the code I'm trying to run:
> >
> > implicit val formats = net.liftweb.json.DefaultFormats
> > case class Name(first: String, last: String)
> > case class User(name: Name, email: String)
> > import net.liftweb.json.JsonParser._
> > val u = {
> > import JsonDSL._
> > ("name" ->
> > ("first" -> "Lincoln") ~
> > ("last" -> "Hochberg")
> > ) ~
> > ("email" -> "linxbet...@gmail.com")}
> >
> > val json = JsonDSL.pretty(JsonAST.render(u))
> > val jsonAST = JsonParser.parse(json)
> > val user = jsonAST.extract[User]
> >
> > This blows up with the following exception:
> >
> > net.liftweb.json.MappingException: Parsed JSON values do not match with
> > class constructor
> > args=
> > arg types=
> > constructor=public
> > pkg.TestSpec$$anonfun$1$$anonfun$apply$1(pkg.TestSpec$$anonfun$1)
> > at
> >
> net.liftweb.json.Extraction$.net$liftweb$json$Extraction$$fail(Extraction.scala:151)
> > at net.liftweb.json.Extraction$.newInstance$1(Extraction.scala:72)
> > at net.liftweb.json.Extraction$.build$1(Extraction.scala:84)
> > at net.liftweb.json.Extraction$$anonfun$1.apply(Extraction.scala:84)
> > at net.liftweb.json.Extraction$$anonfun$1.apply(Extraction.scala:84)
> >         at scala.List.flatMap(List.scala:1132)
> > at net.liftweb.json.Extraction$.build$1(Extraction.scala:84)
> > at net.liftweb.json.Extraction$$anonfun$1.apply(Extraction.scala:84)
> > at net.liftweb.json.Extraction$$anonfun$1.apply(Extraction.scala:84)
> > at scala.List.flatMap(List.scala:1132)
> > at net.liftweb.json.Extraction$.build$1(Extraction.scala:84)
> > at net.liftweb.json.Extraction$.extract0(Extraction.scala:109)
> > at net.liftweb.json.Extraction$.extract(Extraction.scala:60)
> > at net.liftweb.json.JsonAST$JValue.extract(Json.scala:109)
> > at
> >
> com.hotpotato.core.ops.TestSpec$$anonfun$1$$anonfun$apply$1.apply(TestSpec.scala:48)
> > at
> >
> com.hotpotato.core.ops.TestSpec$$anonfun$1$$anonfun$apply$1.apply(TestSpec.scala:14)
> > at
> >
> org.specs.specification.ExampleExecution$$anonfun$3$$anonfun$apply$1.apply(Example.scala:207)
> > at org.specs.specification.Example.execute(Example.scala:121)
> > at
> >
> org.specs.specification.ExampleLifeCycle$class.executeTest(ExampleLifeCycle.scala:20)
> > at org.specs.Specification.executeTest(Specification.scala:28)
> > at org.specs.specification.Sus.executeTest(Sus.scala:147)
> > at
> >
> org.specs.specification.ExampleExecution$$anonfun$3.apply(Example.scala:207)
> > at
> >
> org.specs.specification.ExampleExecution$$anonfun$3.apply(Example.scala:194)
> > at
> >
> org.specs.specification.ExampleExecution$$anonfun$2.apply(Example.scala:185)
> > at org.specs.specification.ExampleExecution.execute(Example.scala:227)
> > at org.specs.specification.Example.execute(Example.scala:117)
> > at org.specs.specification.Example.errors(Example.scala:143)
> > at org.specs.specification.Sus$$anonfun$successes$1.apply(Sus.scala:122)
> > at org.specs.specification.Sus$$anonfun$successes$1.apply(Sus.scala:122)
> > at scala.List.filter(List.scala:859)
> > at org.specs.specification.Sus.successes(Sus.scala:122)
> > at
> >
> org.specs.Specification$$anonfun$successes$1.apply(Specification.scala:84)
> > at
> >
> org.specs.Specification$$anonfun$successes$1.apply(Specification.scala:84)
> > at scala.List.flatMap(List.scala:1132)
> > at org.specs.Specification.successes(Specification.scala:84)
> > at
> >
> sbt.impl.SpecsRunner.sbt$impl$SpecsRunner$$reportSpecification(TestFrameworkImpl.scala:140)
> > at sbt.impl.SpecsRunner.runTest(TestFrameworkImpl.scala:123)
> > at sbt.BasicTestRunner.run(TestFramework.scala:38)
> > at
> >
> sbt.TestFramework$$anonfun$7$$anonfun$apply$8.runTest$1(TestFramework.scala:136)
> > at
> >
> sbt.TestFramework$$anonfun$7$$anonfun$apply$8$$anonfun$apply$9.apply(TestFramework.scala:147)
> > at
> >
> sbt.TestFramework$$anonfun$7$$anonfun$apply$8$$anonfun$apply$9.apply(TestFramework.scala:147)
> > at sbt.NamedTestTask.run(TestFramework.scala:57)
> > at
> >
> sbt.ScalaProject$$anonfun$sbt$ScalaProject$$toTask$1.apply(ScalaProject.scala:167)
> > at
> >
> sbt.ScalaProject$$anonfun$sbt$ScalaProject$$toTask$1.apply(ScalaProject.scala:167)
> > at sbt.TaskManager$Task.invoke(TaskManager.scala:62)
> > at sbt.impl.RunTask.runTask(RunTask.scala:78)
> > at sbt.impl.RunTask.sbt$impl$RunTask$$runIfNotRoot(RunTask.scala:63)
> > at sbt.impl.RunTask$$anonfun$runTasksExceptRoot$3.apply(RunTask.scala:49)
> > at sbt.impl.RunTask$$anonfun$runTasksExceptRoot$3.apply(RunTask.scala:49)
> > at sbt.Distributor$Run$Worker$$anonfun$2.apply(ParallelRunner.scala:130)
> > at sbt.Distributor$Run$Worker$$anonfun$2.apply(ParallelRunner.scala:130)
> > at sbt.Control$.trapUnit(Control.scala:19)
> > at sbt.Distributor$Run$Worker.run(ParallelRunner.scala:130)
> >
> > Any ideas?
> >
> > Thanks,
> > Lincoln
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to