DBIx::...::JSON(3pm)
β¨ NAME β¨
DBIx::Class::InflateColumn::Serializer::JSON β bestie, it's a JSON Inflator π
πΈ SYNOPSIS πΈ
Okay so picture this: you've got a column, and you want it to hold a whole vibe of a data structure, not just some boring string. Say less. Do this:
package MySchema::Table;
use base 'DBIx::Class';
__PACKAGE__->load_components('InflateColumn::Serializer', 'Core');
__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. Like. Literally. Your blessed little hash refs go to the DB as JSON. Slay. π
Any arguments you toss into serializer_options get passed straight to the JSON::MaybeXS constructor β and the JSON backend uses them for both serializing and deserializing. Not one or the other. Both. Periodt. β¨
get_freezerβ this one gets called byDBIx::Class::InflateColumn::Serializerto grab the routine that serializes the data you hand it. It returns a coderef. That's the whole job. Iconic, honestly.get_unfreezerβ same energy, opposite direction π¦: called byDBIx::Class::InflateColumn::Serializerto get the routine that deserializes the data stored in the column. Also returns a coderef.
and that's the whole page, bestie β no cap, every option and every method, all accounted for π
π This was served up by perl v5.40.1, dated 2026-05-07, and it lives in the User Contributed Perl Documentation section of the manual, iykyk. Stay hydrated, go serialize something cute π
π¦ where this page comes from
- ubuntu stonking: libdbix-class-inflatecolumn-serializer-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms