<<

NAME

Koha::Object::JSONFields - Class that adds JSON field manipulation helper methods for Koha::Object-derived classes

SYNOPSIS

    use base qw(Koha::Object Koha::Object::JSONFields);
    my $object = Koha::Object->new({ property1 => $property1, property2 => $property2, etc... } );
    my $field_name_hashref = $object->decode_json_field({ field => 'field_name' });
    $object->encode_json_field({ field => 'field_name', data => $data });

API

Class methods

decode_json_field

    my $hashref = $object->decode_json_field({ field => 'field_name' });

Returns a data structure representing the JSON-decoded value of field field_name.

set_encoded_json_field

    $object->set_encoded_json_field(
        {   data  => $data,
            field => 'field_name',
        }
    );

Sets a JSON string encoded representation of $data into the object's field_name attribute.

Internal methods

_json

    my $JSON_object = $self->_json;

Returns a JSON object with utf8 disabled. Encoding to UTF-8 should be done later.

AUTHOR

Tomas Cohen Arazi, <tomascohen@theke.io>

<<