DBIx-Struct
view release on metacpan or search on metacpan
lib/DBIx/Struct.pod view on Meta::CPAN
# one field and more data in output
print $json->encode($user->TO_JSON("username",
{url => "http://site.com/login"})
); # {"username":"cruks","url":"http://site.com/login"}
# just add more data in output
print $json->encode($user->TO_JSON({url => "http://site.com/login"}));
# {"url":"http://site.com/login","username":"cruks","id":1}
=head4 B<JSON> type support
Fields with datatype 'json' or 'jsonb' can be transparently used as perl-structures.
my $row = one_row(table => $id);
# table is like
# id | integer | not null default nextval('table_id_seq'::regclass)
# settings | jsonb |
# row is like
# id | settings
# ----+-----------------------------------------------------------------
# 1 | {"limits": {"low": 15, "max": 100}}
( run in 1.229 second using v1.01-cache-2.11-cpan-0a6323c29d9 )