---
name: "PGObject::Type::JSON"
section: "3pm"
platform: "linux"
package: "libpgobject-type-json-perl"
version: "2.1.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/PGObject::Type::JSON"
---

# PGObject::Type::JSON(3pm)

JSON wrappers for PGObject

## NAME

PGObject::Type::JSON - JSON wrappers for PGObject

## VERSION

Version 2.1.1

## SYNOPSIS

```
   PGOBject::Type::JSON->register();
```

Columns of type json will be converted into hashrefs

```
   my $obj =  PGOBject::Type::JSON->new($hashref);
```

`$obj` will now serialize to the database as json.

## DESCRIPTION

This module allows json types or others (specified by custom register) types to be converted from JSON into objects according to their values.

This module assumes that encoding will be in UTF8 across the board and is not safe to use with other database encodings.

## SUBROUTINES/METHODS

### register(registry =\> 'default', types =\> \['json'\])

### new($ref)

Stores this as a reference. Nulls are now scoped references to a lexically scoped variable.

If values other than scalars, arrayrefs, or hashes are passed in, throws an error.

### from\_db

serializes from the db. Note that database nulls are preserved distinct from json null's.

### to\_db

returns undef if is\_null.  Otherwise returns the value encoded as JSON

### 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)

### is\_null

Returns true if is a database null.

### json\_null

Returns a JSON null

### is\_json\_null

Returns true if the value is a JSON null.  Else it returns false

## AUTHOR

Chris Travers, `"<chris.travers at gmail.com>"`

## 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.

## 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

## LICENSE AND COPYRIGHT

Copyright 2013-2023 Chris Travers.

This program is released under the following license: BSD
