MARC::File::JSON - Convert between MARC::Record objects and JSON formatted data.
use MARC::File::JSON; my $record = MARC::Record->new_from_json( $json ); $json = $record->as_json;
This module provides routines for converting between MARC::Record objects and serialized JSON data formatted as:
{ "leader":"01109cam a2200349 a 4500", "fields":[ "001", " 89009461 //r92", "005", "19991006093052.0", "010", { "subfields":[ "a", "89009461 //r92" ], "ind1":" ", "ind2":" " }, "020", ... ] }
MARC::File::JSON injects two subroutines into the MARC::Record namespace. Additionally it inherits from MARC::File and includes encode(), decode, and _next() routines, making it compatible with MARC::Batch.
MARC::Record::new_from_json( $json )
A package method of MARC::Record which applies the values contained in $json to the object which it returns.
$json
MARC::Record::as_json( $args )
An instance method for a MARC::Record object. Returns the objects values as a string of JSON data. $args is an optional hashref to be passed as the second parameter to JSON::to_json().
$args
encode( MARC::Record $record )
Returns a JSON string representation of $record.
decode( $class, $json )
Converts $json into an instance of MARC::Record, applying the transform in MARC::Record::Generic.
MARC::Record::Generic
Format inspired by http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json
Clay Fouts <cfouts@khephera.net>
Copyright (c) 2012 PTFS/LibLime
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MARC::File::JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MARC::File::JSON
CPAN shell
perl -MCPAN -e shell install MARC::File::JSON
For more information on module installation, please visit the detailed CPAN module installation guide.