[Dbix-class] RFC: DBIx::Class::JSON

Nilson Santos Figueiredo Junior acid06 at gmail.com
Sat Sep 16 01:46:49 CEST 2006


On 9/15/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> I think what I'd like to see is a general serialization interface that plugins
> can be written for. Something like
>
> __PACKAGE__->load_components(qw/Serializer/);
> __PACKAGE__->serialization_options({ follow_rels => ... });
>
> ...
>
> $obj->serialize_to('JSON');
> $obj->serialize_to('XML');
>
> etc.
>
> How does that look to you guys?

Looks good. The main problem I think is how to properly serialize
everything (e.g. DateTime objects). Also, how'd you restrict what
fields would be serialized or not?

Sometimes besides serializing plain columns or relationships you might
also want to serialize the value of a method call on the given object,
so I think there should be a way of doing this too when using this
generic serialization interface.

As I understand, "serialization plugins" would be under a default
namespace, say, DBIx::Class::Serializer::JSON for JSON, etc. Maybe it
might make sense to define serializer for each column. This way, it'd
be easy to handle cases such as arbitrary inflated objects.

Maybe, I could try starting this stuff over the weekend or maybe at
$work on Monday.

-Nilson Santos F. Jr.



More information about the Dbix-class mailing list