Hi,
Serialization feature is actually a very thin layer on top of
decompose and extract functions. So, one way to accomplish that is to
use directly those functions and map the field names.
So, instead of this:
write(x, out)
Try this:
val json = decompose(x) map {
case JField("firstname", x) => JField("fn", x)
case JField("lastname", x) => JField("ln", x)
case x => x
}
compact(render(json), out)
And instead of this:
read[Users](x)
Try this:
parse(x).extract[Users] map {
case JField("fn", x) => JField("firstname", x)
case JField("ln", x) => JField("lastname", x)
case x => x
}
Would that solve your issue?
Cheers Joni
On Feb 9, 6:27 am, harryh <[email protected]> wrote:
> A feature request. Right now I might have a case class like so:
>
> case class User(firstname: String, lastname: String)
>
> which serializes to something like:
>
> { "firstname" : "Harry", "lastname" : "Heymann" }
>
> but I happen to be serializing a lot of People and I hate to use 17
> bytes per item for the field names. I'd really prefer to only use 4:
>
> { "fn" : "Harry", "ln" : "Heymann" }
>
> It seems to me that through clever use of an implicit parameter I
> ought to be pass in a Map of field name -> shortened names. Thoughts?
>
> -harryh
--
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.