Here are the imports I am using:
import com.novus.salat._
import com.novus.salat.global.ctx
import net.liftweb.json._
import com.mongodb.casbah.Imports._
I have two case classes:
case class BigThing (thing: Thing )
case class Thing(x:Int, y:Int)
My grater correctly produces a DBObject with the names of the fields when grating a Thing alone:
implicit val formats = DefaultFormats
val t = parse("""{"x":5, "y":6}""").extract[Thing]
println("t " + t)
val dboT = grater[Thing].asDBObject(t)
println("dboT " + dboT)
This prints:
t Thing(5,6)
dboT { "_typeHint" : "Thing" , "x" : 5 , "y" : 6}
But when grating a BigThing, the Thing's field names are turned into an array:
val bt = parse(""" { "thing": {"x":5, "y":6} } """).extract[BigThing]
println("bt " + bt)
val dboBt = grater[BigThing].asDBObject(bt)
println("dboBt " + dboBt)
This prints:
bt BigThing(Thing(5,6))
dboBt { "_typeHint" : "BigThing" , "thing" : [ 5 , 6]}
Is this a bug? I am doing something wrong?
My build.sbt field is this:
name := "hello"
resolvers ++= Seq(
"ScalaNLP Maven2" at "http://repo.scalanlp.org/repo",
"Spray repo" at "http://repo.spray.cc/",
"Typesafe repo" at "http://repo.typesafe.com/typesafe/releases/",
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
libraryDependencies ++= Seq(
"com.novus" %% "salat-core" % "1.9.1-SNAPSHOT",
"cc.spray" %% "spray-json" % "1.1.1",
"com.mongodb.casbah" % "casbah_2.9.1" % "2.1.5-1",
"net.liftweb" %% "lift-json" % "2.5-SNAPSHOT"
)