use utf8;
use strict;
use warnings;
use base 'DBIx::Class';
use JSON::MaybeXS;
{
my $self = shift;
if ($self->can("as_json")) {
return $self->as_json();
}
my $hint = $self->json_hint;
my %json = ();
foreach my $column (@{$hint->{ }}) {
$json{$column} = $self->get_column($column);
}
foreach my $column (@{$hint->{ }}) {
$json{$column} = $self->get_column($column) // "";
}
foreach my $column (@{$hint->{ }}) {
$json{$column} = $self->get_column($column) ? JSON::MaybeXS::true : JSON::MaybeXS::false;
}
foreach my $relname (keys %{$hint->{ }}) {
my $key = $hint->{ }->{$relname};
$json{$relname} = [ map { $_->$key } $self->$relname ];
}
foreach my $relname (keys %{$hint->{ }}) {
my $key = $hint->{ }->{$relname};
$json{$relname} = { map { $_->$key => $_ } $self->$relname };
}
return \%json;
}
1;