NAME

Content::JSON - Class to encode and decode JSON data to and from a HASH.

SYNOPSIS

Used in the same way as the placeholder class Content. See Content-class for more information.

DESCRIPTION

Class to encode and decode JSON data to and from a HASH. It uses the JSON::XS module to decode and encode to and from JSON data.

CONSTRUCTOR

same as for the Content placeholder-class. See the Content-class for more information.

METHODS

encode()

Inherited from the Content-class, but in this case encodes a HASH into JSON data and returns the JSON data.

Input is the optional HASH reference to be encoded. If no HASH-reference is given, it will use the one internally to the Content-class and that are set by the set()-method.

It will return the JSON data upon success, undef upon failure. Please check the error()-method for more information.

decode()

Inherited from the Content-class, but in this case decodes JSON data into a Perl HASH. It sets the internal HASH to the decoded result upon success.

Input is a SCALAR with the JSON data. If no input is specified it will default to a blank string.

It returns a blank string upon success, undef upon failure. Check the error()-method for more information on the failure.