Created
January 29, 2014 20:22
-
-
Save voronaam/8696202 to your computer and use it in GitHub Desktop.
JSON type mapper for Squeryl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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