PGObje...::JSON(3pm)
π PGObject::Type::JSON β the manual, but make it cute π
okay bestie, gather round, because this is PGObject::Type::JSON, the module that does JSON wrappers for PGObject. yes that's the whole name, yes it's giving exactly what it says on the tin. β¨
Version: 2.1.1 π
πΈ SYNOPSIS πΈ
PGOBject::Type::JSON->register();
(nope, that capital B in PGOBject is not a typo on my part, that's literally what it says, copy it as-is bestie π«Ά)
Columns of type json will be converted into hashrefs:
my $obj = PGOBject::Type::JSON->new($hashref);
and now $obj will serialize to the database as json. that's it. that's the whole glow-up. π
π¦ DESCRIPTION π¦
So this module lets json types β or literally any other type you specify with a custom register β get converted from JSON into objects, based on their values. it's giving β¨type-awareβ¨ and we love that for it.
β οΈ Real talk, no cap: this module assumes encoding will be UTF8 across the board, and it is NOT safe to use with other database encodings. like, don't. i'm serious. π
π SUBROUTINES/METHODS π
π register(registry => 'default', types => ['json'])
the registration situation. you hand it a registry and the types you want in on the action β defaults being 'default' and ['json'] respectively. π
π new($ref)
Stores this as a reference. Nulls are now scoped references to a lexically scoped variable. (iykyk)
π If values other than scalars, arrayrefs, or hashes are passed in, it throws an error. so don't be chaotic about it.
π§ from_db
serializes from the db. and note this, bestie: database nulls are preserved distinct from json null's. two different nulls, two different vibes, do not conflate them. π
β to_db
returns undef if is_null. Otherwise returns the value encoded as JSON. simple. clean. iconic. β¨
π null
Return a null type for storage in the db.
πΈ TO_JSON
The handler for setting this to the JSON parser.
π reftype
Returns the reftype of the object β i.e. HASH, SCALAR, ARRAY. the receipts of what you actually handed it. π
π¦ is_null
Returns true if it is a database null.
π json_null
Returns a JSON null. (different from the db null, remember? we went over this π«Ά)
π is_json_null
Returns true if the value is a JSON null. Else it returns false. periodt.
π AUTHOR π
Chris Travers, "<chris.travers at gmail.com>" β shoutout to the author, main character energy fr fr β
π BUGS π
Please report any bugs or feature requests to "bug-pgobject-type-json at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Type-JSON>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. so like, you will literally get updates. we stay in the loop here. π₯
π«Ά SUPPORT π«Ά
You can find documentation for this module with the perldoc command:
perldoc PGObject::Type::JSON
You can also look for information at:
- RT: CPAN's request tracker (report bugs here) <http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Type-JSON>
- AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/PGObject-Type-JSON>
- CPAN Ratings <http://cpanratings.perl.org/d/PGObject-Type-JSON>
- Search CPAN <http://search.cpan.org/dist/PGObject-Type-JSON/>
π ACKNOWLEDGEMENTS π
(empty section, but we acknowledge the acknowledgement section itself. respect. π )
πΈ LICENSE AND COPYRIGHT πΈ
Copyright 2013-2023 Chris Travers.
This program is released under the following license: BSD π
and that's the whole page bestie, you ate it up π this was perl v5.36.0, dated 2023-10-27, from PGObject::Type::JSON(3pm) β now go forth and serialize responsibly π§β¨
π¦ where this page comes from
- debian trixie: libpgobject-type-json-perl 2.1.1-1 Β· BSD-2-Clause
- ubuntu noble: libpgobject-type-json-perl 2.1.1-1 Β· BSD-2-Clause
- ubuntu resolute: libpgobject-type-json-perl 2.1.1-1 Β· BSD-2-Clause
- ubuntu stonking: libpgobject-type-json-perl 2.1.1-1 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms