Skip to content

Instantly share code, notes, and snippets.

@voronaam
Created January 29, 2014 20:22
Show Gist options
  • Save voronaam/8696202 to your computer and use it in GitHub Desktop.
Save voronaam/8696202 to your computer and use it in GitHub Desktop.
JSON type mapper for Squeryl
trait XsnTypeMode extends PrimitiveTypeMode {
import com.codahale.jerkson.Json._
import scala.collection.mutable.HashMap
import scala.language.implicitConversions
implicit val jsonTEF = new NonPrimitiveJdbcMapper[String,HashMap[String, Any],TString](stringTEF, this) {
def convertFromJdbc(v: String) = if(v == null) null else parse[HashMap[String, Any]](v)
def convertToJdbc(v: HashMap[String, Any]) = if(v == null) null else generate(v)
override def sample = new HashMap[String, Any]()
}
implicit def mapToTE(s: HashMap[String, Any]) = jsonTEF.create(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment