[Lift] serializing and deserializing a json object through Lift-JSON

2010-02-10 Thread Ali
Dear All,
 I am wondering would you please tell me how can I use lift-json (2.0
snapshots) to serialize and deserialize the following scala case
classes.

case class Plan( plan:Option[Action] )
case class Game( game:Map[String,Plan])
case class Action(id:Int, subAction : Option[Action])


val game = new Game(Map(a-new Plan(new Some(new Action(1,None)
implicit val formats = net.liftweb.json.DefaultFormats

game must beEqualTo( Serialization.read[Game]
(Serialization.write(game)))

Test fails.

Cheers,
-A

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.



Re: [Lift] serializing and deserializing a json object through Lift-JSON

2010-02-10 Thread Justin Reardon
Sometimes the serialization code needs a helping hand, using:

implicit val format = 
Serialization.formats(ShortTypeHints(List(classOf[Plan], classOf[Action], 
classOf[Game])))

instead of the defaults makes it work here.

Cheers,
Justin Reardon

On 2010-02-10, at 11:42 , Ali wrote:

 Dear All,
 I am wondering would you please tell me how can I use lift-json (2.0
 snapshots) to serialize and deserialize the following scala case
 classes.
 
 case class Plan( plan:Option[Action] )
 case class Game( game:Map[String,Plan])
 case class Action(id:Int, subAction : Option[Action])
 
 
 val game = new Game(Map(a-new Plan(new Some(new Action(1,None)
 implicit val formats = net.liftweb.json.DefaultFormats
 
 game must beEqualTo( Serialization.read[Game]
 (Serialization.write(game)))
 
 Test fails.
 
 Cheers,
 -A
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to lift...@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.
 

-- 
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@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.