PGObje...::JSON(3pm)

πŸ“¦
version 2.1.1 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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:


πŸŽ€ ACKNOWLEDGEMENTS πŸŽ€

(empty section, but we acknowledge the acknowledgement section itself. respect. πŸ’…)


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