GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Venus::Json(3) User Contributed Perl Documentation Venus::Json(3)

Venus::Json - Json Class

Json Class for Perl 5

  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 <https://json.org> 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.

This package has the following attributes:

  decoder(CodeRef)

This attribute is read-write, accepts "(CodeRef)" values, and is optional.

  encoder(CodeRef)

This attribute is read-write, accepts "(CodeRef)" values, and is optional.

This package inherits behaviors from:

Venus::Kind::Utility

This package integrates behaviors from:

Venus::Role::Accessible

Venus::Role::Buildable

Venus::Role::Explainable

Venus::Role::Valuable

This package provides the following methods:

  decode(string $json) (any)

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

Since 0.01

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

  encode() (string)

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

Since 0.01

encode example 1
  # given: synopsis;
  my $encode = $json->encode;
  # '{ "name": ["Ready", "Robot"], "stable": true, "version": 0.12 }'
    

This package may raise the following errors:

This package may raise an error_on_config exception.

example 1

  # given: synopsis;
  my $input = {
    throw => 'error_on_config',
  };
  my $error = $json->catch('error', $input);
  # my $name = $error->name;
  # "on_config"
  # my $message = $error->message;
  # "No suitable JSON package"
    

Awncorp, "awncorp@cpan.org"

Copyright (C) 2022, Awncorp, "awncorp@cpan.org".

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.

2023-11-27 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.