NAME
MARC::File::JSON - Convert between MARC::Record objects and JSON formatted data.
SYNOPSIS
use MARC::File::JSON;
my $record = MARC::Record->new_from_json( $json );
$json = $record->as_json;
DESCRIPTION
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",
...
]
}
INTERFACE
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.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().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.
SEE ALSO
MARC::Record::Generic
Format inspired by http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json
AUTHOR
Clay Fouts <cfouts@khephera.net>
COPYRIGHT & LICENSE
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.