net.liftweb.json.TypeHints

trait TypeHints

trait TypeHints

 extends ScalaObject


Type hints can be used to alter the default conversion rules when converting Scala instances into JSON and vice versa. Type hints must be used when converting class which is not supported by default (for instance when class is not a case class).

Example:

 class DateTime(val time: Long)

 val hints = new ShortTypeHints(classOf[DateTime] :: Nil) {
   override def serialize: PartialFunction[Any, JObject] = {
     case t: DateTime => JObject(JField("t", JInt(t.time)) :: Nil)
   }

   override def deserialize: PartialFunction[(String, JObject), Any] = {
     case ("DateTime", JObject(JField("t", JInt(t)) :: Nil)) => new DateTime(t.longValue)
   }
 }
 implicit val formats = DefaultFormats.withHints(hints)
 


Source: Formats.scala(94)

Direct Known Subclasses

ShortTypeHints, NoTypeHints, FullTypeHints,

 Fields

components.. def components List[TypeHints]
hints.. abstract val hints List[Class[Any]]
serialize.. def serialize PartialFunction[Any, JObject]

 Methods

!=.. final def !=(arg0 : Object) Boolean AnyRef
!=.. final def !=(arg0 : Any) Boolean Any
+.. def +(hints : TypeHints)
Adds the specified type hints to this type hints
TypeHints
==.. final def ==(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Object) Boolean AnyRef
asInstanceOf.. final def asInstanceOf[T0] T0 Any
classFor.. abstract def classFor(hint : String)
Return type for given hint
Option[Class[Any]]
clone.. protected def clone Object AnyRef
containsHint_?.. def containsHint_?(clazz : Class[Any]) Boolean
deserialize.. def deserialize PartialFunction[(String, JObject), Any]
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. def equals(arg0 : Any) Boolean AnyRef
finalize.. protected def finalize Unit AnyRef
getClass.. final def getClass Class[Any] AnyRef
hashCode.. def hashCode Int AnyRef
hintFor.. abstract def hintFor(clazz : Class[Any])
Return hint for given type
String
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
ne.. final def ne(arg0 : Object) Boolean AnyRef
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
toString.. def toString String AnyRef
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long) Unit AnyRef
Copyright (c) 2006-2010 WorldWide Conferencing, LLC. All Rights Reserved.