lift-json 2.4M1 parsing option classes?

128 views
Skip to first unread message

tcc

unread,
Jul 12, 2011, 1:23:25 AM7/12/11
to Lift
When parsing case classes with a List of Option[String], the option
classes get flatten out.

For case class Library(name:String, docs:List[Option[String]])
when I parse and extract it, i get:
Library(test,List(1, 2))
but I expect:
Library(test,List(Some(1), Some(2)))

The test unit is at https://gist.github.com/1077437

Is this the expected behavior or a bug in lift-json 2.4M1?

Antonio Salazar Cardozo

unread,
Jul 12, 2011, 1:28:34 AM7/12/11
to lif...@googlegroups.com
I believe in lift-json, a None is basically defined as the absence of a value. As such, in a List, the absence of a value simply means there is no entry in the list. The result is a `flattened' structure as you see -- because there is no alternate representation for Some/None.

However, I believe if you use Box, lift-json serializes the Full/Emptyness thereof.
Thanks,
Antonio

Joni Freeman

unread,
Jul 12, 2011, 2:16:44 AM7/12/11
to lif...@googlegroups.com
Hi,

Looks like a bug. The extracted type must be the same type as given to
the extract function. Please file a ticket.

Cheers Joni

tcc

unread,
Jul 12, 2011, 11:06:18 AM7/12/11
to Lift
Thanks, I filed a ticket as:
https://www.assembla.com/spaces/liftweb/tickets/1071-lift-json-flattens-option-types-unexpectedly

On Jul 11, 11:16 pm, Joni Freeman <joni.free...@reaktor.fi> wrote:
> Hi,
>
> Looks like a bug. The extracted type must be the same type as given to
> the extract function. Please file a ticket.
>
> Cheers Joni
>
>
>
>
>
>
>
> On Mon, 2011-07-11 at 22:23 -0700, tcc wrote:
> > When parsing case classes with a List of Option[String], the option
> > classes get flatten out.
>
> > For case class Library(name:String, docs:List[Option[String]])
> > when I parse and extract it, i get:
> > Library(test,List(1, 2))
> > but I expect:
> > Library(test,List(Some(1), Some(2)))
>
> > The test unit is athttps://gist.github.com/1077437

Matt Farmer

unread,
Sep 26, 2015, 3:05:01 PM9/26/15
to Lift, tommy....@gmail.com
Wanted to follow up here and let you folks know we just delivered a fix that should be released as a part of 3.0-M7.

Cheers,
Reply all
Reply to author
Forward
0 new messages