Venus::Json

Json Class

Json Class for Perl 5

method: decode method: encode

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 }'

This package may raise an error_on_config exception.

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

18 POD Errors

The following errors were encountered while parsing the POD:

Around line 18:

Unknown directive: =name

Around line 26:

Unknown directive: =tagline

Around line 34:

Unknown directive: =abstract

Around line 42:

Unknown directive: =includes

Around line 51:

Unknown directive: =synopsis

Around line 72:

Unknown directive: =description

Around line 84:

Unknown directive: =inherits

Around line 92:

Unknown directive: =integrates

Around line 103:

Unknown directive: =attributes

Around line 112:

Unknown directive: =method

Around line 117:

Unknown directive: =signature

Around line 121:

Unknown directive: =metadata

Around line 145:

Unknown directive: =method

Around line 150:

Unknown directive: =signature

Around line 154:

Unknown directive: =metadata

Around line 179:

Unknown directive: =error

Around line 205:

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

Around line 219:

Unknown directive: =partials