Venus::Json

Json Class

Json Class for Perl 5

method: decode method: encode method: new

package main;

use Venus::Json;

my $json = Venus::Json->new(
  value => { name => ['Ready', 'Robot'], version => 0.12, stable => !!1, }
);

# $json->encode;

This package provides methods for reading and writing JSON data. Note: This package requires that a suitable JSON library is installed, currently either JSON::XS 3.0+, JSON::PP 2.27105+, or Cpanel::JSON::XS 4.09+. You can use the VENUS_JSON_PACKAGE environment variable to include or prioritize your preferred JSON library.

Venus::Kind::Utility

Venus::Role::Accessible Venus::Role::Buildable Venus::Role::Explainable Venus::Role::Valuable

decoder: rw, opt, CodeRef encoder: rw, opt, CodeRef

The decode method decodes the JSON string, sets the object value, and returns the decoded value.

decode(string $json) (any)

{ since => '0.01', }

=example-1 decode

# given: synopsis;

my $decode = $json->decode('{"codename":["Ready","Robot"],"stable":true}');

# { codename => ["Ready", "Robot"], stable => 1 }

The encode method encodes the objects value as a JSON string and returns the encoded string.

encode() (string)

{ since => '0.01', }

=example-1 encode

# given: synopsis;

my $encode = $json->encode;

# '{ "name": ["Ready", "Robot"], "stable": true, "version": 0.12 }'

The new method constructs an instance of the package.

new(any @args) (Venus::Json)

{ since => '4.15', }

package main;

use Venus::Json;

local $ENV{VENUS_JSON_PACKAGE} = 'Fake::Json';

my $new = Venus::Json->new;

# Error! (on.config)

t/Venus.t: present: authors t/Venus.t: present: license

23 POD Errors

The following errors were encountered while parsing the POD:

Around line 19:

Unknown directive: =name

Around line 27:

Unknown directive: =tagline

Around line 35:

Unknown directive: =abstract

Around line 43:

Unknown directive: =includes

Around line 53:

Unknown directive: =synopsis

Around line 74:

Unknown directive: =description

Around line 86:

Unknown directive: =inherits

Around line 94:

Unknown directive: =integrates

Around line 105:

Unknown directive: =attributes

Around line 114:

Unknown directive: =method

Around line 119:

Unknown directive: =signature

Around line 123:

Unknown directive: =metadata

Around line 147:

Unknown directive: =method

Around line 152:

Unknown directive: =signature

Around line 156:

Unknown directive: =metadata

Around line 181:

Unknown directive: =method

Around line 185:

Unknown directive: =signature

Around line 189:

Unknown directive: =metadata

Around line 207:

=cut found outside a pod block. Skipping to next block.

Around line 227:

=cut found outside a pod block. Skipping to next block.

Around line 248:

=cut found outside a pod block. Skipping to next block.

Around line 259:

Unknown directive: =raise

Around line 281:

Unknown directive: =partials