NAME

DBIO::InflateColumn::Serializer::JSON - JSON Inflator

VERSION

version 0.900000

SYNOPSIS

package MySchema::Table;
use base 'DBIO::Core';

__PACKAGE__->load_components('InflateColumn::Serializer');
__PACKAGE__->add_columns(
  'data_column' => {
    'data_type' => 'VARCHAR',
    'size'      => 255,
    'serializer_class'   => 'JSON',
    'serializer_options' => { allow_blessed => 1, convert_blessed => 1, pretty => 1 },    # optional
  }
);

Then in your code...

my $struct = { 'I' => { 'am' => 'a struct' } };
$obj->data_column($struct);
$obj->update;

And you can recover your data structure with:

my $obj = ...->find(...);
my $struct = $obj->data_column;

The data structures you assign to "data_column" will be saved in the database in JSON format.

Any arguments included in serializer_options are passed to the JSON::MaybeXS constructor used for serialization and deserialization.

DESCRIPTION

JSON backend for DBIO::InflateColumn::Serializer. Loaded automatically when a column declares serializer_class => 'JSON'.

METHODS

get_freezer

Called by DBIO::InflateColumn::Serializer to get the routine that serializes the data passed to it. Returns a coderef.

get_unfreezer

Called by DBIO::InflateColumn::Serializer to get the routine that deserializes the data stored in the column. Returns a coderef.

COLUMN INFO

serializer_class => 'JSON'

Selects this backend.

serializer_options => \%opts

Passed verbatim to JSON::MaybeXS->new.

size => $n

Optional. If set, the serialised payload is checked against size on deflate; over-long payloads throw.

DEPENDENCIES

JSON::MaybeXS. Not a hard dependency of DBIO; install separately.

AUTHOR

DBIO & DBIx::Class Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.