Hi,
Type hints should not be needed in this case since the Map is not used
in a polymorphic way. But the work-around Justin showed should work.
Actually it seems that it is enough to put type info just to Action to
make serialization work:
implicit val format =
Serialization.formats(ShortTypeHints(List(classOf[Action]))
Anyway, I added a ticket for this defect:
http://www.assembla.com/spaces/liftweb/tickets/341-Type-hints-are-needed-in-JSON-serializization-for-non-polymorphic-Map-
Cheers Joni
On Feb 10, 7:49 pm, Justin Reardon <[email protected]> wrote:
> 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.