MARC::...rd::MiJ(3pm)
π MARC::Record::MiJ π
okay bestie, so this is the manual page for MARC::Record::MiJ, living in the User Contributed Perl Documentation section, and it's giving "3pm" the whole way through. It's a Perl module for flipping MARC::Record objects back and forth to and from marc-in-json structures. Yes. Both directions. Iconic behaviour honestly.
β¨ NAME β¨
MARC::Record::MiJ β Convert MARC::Record to/from marc-in-json structure π¦
β¨ VERSION β¨
Version 0.04 π
β¨ SYNOPSIS β¨
no thoughts, just code, bestie:
use MARC::Record;
use MARC::Record::MIJ
my $str = get_marc_in_json_from_somewhere;
# The most common use will be to use methods monkeypatched into MARC::Record
my $r = MARC::Record->new_from_mij($str);
my $json = $r->to_mij;
# You can also work with the underlying hash/array structure if you're dealing with
# json serialization/deserialization on your own
my $mij_structure = $r->to_mij_structure;
my $r = MARC::Record->new_from_mij_structure($mij_structure);
# You can also call things on MARC::Record::MiJ
my $r = MARC::Record::MiJ->new($str);
my $json = MARC::Record::MiJ->to_mij($r);
my $mij_structure = MARC::Record::MiJ->to_mij_structure($r);
my $r = MARC::Record::MiJ->new_from_mij_structure($mij_structure);
β¨ DESCRIPTION β¨
So the whole vibe here: this module reads and writes MARC-in-JSON structures and strings, the kind that pymarc / ruby-marc / marc4j support, and it's the flavour described over at http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json/ πΈ
Genuinely do NOT confuse this with another, incompatible JSON encoding that lives in the module MARC::File::JSON β which, as far as the author knows, isn't supported by other readers/writers. Different girl entirely. π
For reading, you probably don't need to touch this directly, fr fr β go peek at MARC::File::MiJ instead, which reads newline-delimited marc-in-json files either all by itself or in cahoots with MARC::Batch π«Ά
And lowkey, the MARC::Record distribution doesn't really do the whole writing out files thing. But you can absolutely do something like this:
# convert file from marc binary to marc-in-json
use MARC::Batch;
use MARC::Record::MiJ;
my $batch = MARC::Batch->new('USMARC', 'file.mrc');
open(my $jsonfile, '>', 'file.ndj' );
while (my $r = $batch->next) {
print $jsonfile MARC::Record::MiJ->to_mij($r), "\n";
}
close $jsonfile;
β¦and boom, you've turned a binary file into newline-delimited marc-in-json. main character energy, truly β¨
β¨ SUBROUTINES/METHODS β¨
json
Get a json object to work with β it's memoized, so it's remembered for you π The whole point of controlling it ourselves is making sure it's not doing anything pretty (like, say, putting newlines in β which would make producing a newline-delimited json file way harder than it needs to be).
new($str)
Take a JSON string and turn it into a MARC::Record object π
to_mij($r)
Take a record; return a JSON string π
MARC::Record::JSON->to_mij_structure($r)
Turn a record into a marc-in-json compatible hash; hand you back the hash pointer π«
controlfield_to_mij_structure($field)
Turn a MARC::Record controlfield into an appropriate hash π¦
valuefield_to_mij_structure($field)
Turn a MARC::Record valuefield into an appropriate hash πΈ
subfield_to_mij_structure($sf)
Turn a MARC::Record subfield pair (that's an arrayref duple of code/value, iykyk) into an appropriate hash β
my $r = MARC::Record::JSON->new_from_mij_structure($mij_structure)
Given a marc-in-json structure, return a MARC::Record object π
new_field_from_mij_structure($f)
Given a field structure, create an appropriate field β control or variable, your choice bestie π
new_datafield_from_mij_structure
Support for new_field_from_mij_structure; this one does the more complex work of actually creating a datafield π
β¨ Monkeypatching MARC::Record β¨
This adds new_from_mij_structure($mij_structure) and to_mij_structure() to MARC::Record πβ¨
my $r = MARC::Record->new_from_mij_structure($mij_structure);
$mij_structure = $r->to_mij_structure;
β¨ AUTHOR β¨
Bill Dueber, "<dueberb at umich.edu>" π
β¨ BUGS β¨
Please report any bugs or feature requests to "bug-MARC-File-MiJ at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MARC-File-MiJ>. The author gets notified, and then you automatically get notified of progress on your bug as changes get made π«Ά no ghosting here.
β¨ SUPPORT β¨
You can find documentation for this module with the perldoc command π
perldoc MARC::Record::MiJ
You can also look for information at:
- RT: CPAN's request tracker (report bugs here)
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MARC-File-MiJ>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/MARC-File-MiJ>
- CPAN Ratings
<http://cpanratings.perl.org/d/MARC-File-MiJ>
- Search CPAN
<http://search.cpan.org/dist/MARC-File-MiJ/>
β¨ ACKNOWLEDGEMENTS β¨
(yeah bestie, this section is literally empty in the original β not me being lazy, I promise π)
β¨ LICENSE AND COPYRIGHT β¨
Copyright 2013 Bill Dueber.
This software is free software and may be distributed under the same terms as Perl itself. π
and that's the whole page, bestie π signed off from perl v5.34.0, dated 2022-06-15, filed under MARC::...rd::MiJ(3pm) in the User Contributed Perl Documentation. go forth and serialize β¨π¦π
π¦ where this page comes from
- debian bookworm: libmarc-file-mij-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmarc-file-mij-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms