Group
Extension

Matches 25

Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_in_json.pm ( view source; MetaCPAN )
package Catmandu::Fix::marc_in_json;

use Catmandu::Sane;
use Catmandu::MARC;
use Moo;
use Catmandu::Fix::Has;

with 'Catmandu::Fix::Inlineable';

our $VERSION = '1.33';

has reverse => (fix_opt => 1)
# Transform a raw MARC array into MARC-in-JSON
# See Ross Singer work at:
#  http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json/
sub fix {
    my ($self, $data) = @_;

 
MARC->instance->marc_json_to_record($data);
    }
    else {
        return Catmandu::MARC->instance->marc_record_to_json($data);
    }
}

=head1 NAME

Catmandu::Fix::marc_in_json - transform a Catman
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Importer/MARC/MiJ.pm ( view source; MetaCPAN )
ckage that imports MARC-in-JSON records

=head1 SYNOPSIS

    # From the command line
    $ catmandu convert MARC --type MiJ --fix "marc_map('245a','title')" < /foo/bar.json

    # From perl
    use C
u;

    # import records from file
    my $importer = Catmandu->importer('MARC',file => '/foo/bar.json', type => 'MiJ');
    my $fixer    = Catmandu->fixer("marc_map('245a','title')");

    $importer-
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_append.pm ( view source; MetaCPAN )
bfield.
This value can be a literal or reference an existing field in the record using the
dollar JSON_PATH syntax.

=head1 INLINE

This Fix can be used inline in a Perl script:

    use Catmandu::Fix
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_set.pm ( view source; MetaCPAN )
 value. This value can be a literal or
reference an existing field in the record using the dollar JSON_PATH syntax.

=head1 INLINE

This Fix can be used inline in a Perl script:

    use Catmandu::Fix
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_copy.pm ( view source; MetaCPAN )
py(650, subjects)

=head1 DESCRIPTION

Copy MARC data referred by MARC_TAG in a structured way to JSON path.

In contrast to L<Catmandu::Fix::marc_map> and L<Catmandu::Fix::marc_spec>
marc_copy will n
a structure.

=head1 METHODS

=head2 marc_copy(MARC_PATH, JSON_PATH, [equals: REGEX])

Copy this MARC fields referred by a MARC_PATH to a JSON_PATH. When an
C<equals> value has been provided, then onl
y the MARC_PATHs with a value
equal to C<equals> will be copied to JSON_PATH. When the MARC_PATH points
to a subfield, then the subfield value need to match C<equals>. When the
MARC_PATH points multip
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_paste.pm ( view source; MetaCPAN )
L<Catmandu::Fix::marc_struc> back at the end of
a MARC record.

=head1 METHODS

=head2 marc_paste(JSON_PATH, [at: MARC_PATH , [equals: REGEX]])

Paste a MARC struct PATH back in the MARC record. By de
.

The C<equals> parameter requires an C<at> parameter. When both are provided, then
the value of JSON_PATH will only be pasted if the string value of the MARC_PATH
in C<at> matches the regular expres
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_cut.pm ( view source; MetaCPAN )
he MARC record

=head1 METHODS

=head2 marc_cut(MARC_PATH, JSON_PATH, [equals: REGEX])

Cut this MARC fields referred by a MARC_PATH to a JSON_PATH. hen an
C<equals> value has been provided, then only
 the MARC_PATHs with a value
equal to C<equals> will be cut to JSON_PATH. When the MARC_PATH points
to a subfield, then the subfield value need to match C<equals>. When the
MARC_PATH points multiple s
all the 300 fields which have subfield c equal to 'ABC'
    marc_cut(300c,tmp,equals:"^ABC")

The JSON_PATH C<tmp> will contain an array with one item per field that was cut.
Each item is a hash conta
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_add.pm ( view source; MetaCPAN )
dded.

By default literal values will be added. To point to an existing value in
a record use the JSON_PATH syntax with a dollar '$.' added in front.

=head1 INLINE

This Fix can be used inline in a P
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/MARC/Tutorial.pod ( view source; MetaCPAN )
characters:

  $ iconv -c -f UTF-8 -t UTF-8 marc21.utf8.raw | catmandu convert MARC --type RAW to JSON

=head2 Convert a decomposed UTF-8 file to a combined UTF-8 file and vice versa

For example, the
t

=head1 READING

=head2 Convert MARC21 records into JSON

The command below converts file data.mrc into JSON:

   $ catmandu convert MARC to JSON < data.mrc

=head2 Convert MARC21 records into MARC-
onvert UNIMARC records into JSON, XML, ...

To read UNIMARC records use the RAW parser to get the correct character
encoding.

   $ catmandu convert MARC --type RAW to JSON < data.mrc
   $ catmandu co
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Exporter/MARC.pm ( view source; MetaCPAN )
r MARCMaker/MARCBreaker records
  MiJ: L<Catmandu::Exporter::MARC::MiJ> (MARC in JSON) - an export for the MARC-in-JSON format
  XML: L<Catmandu::Exporter::MARC::XML> - an exporter for the MARC XML fo
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_map.pm ( view source; MetaCPAN )
ator-2 is 0
    marc_map('245[1,0]a','title')

=head1 DESCRIPTION

Copy data from a MARC field to JSON path.

This module implements a small subset of the L<MARCspec|http://marcspec.github.io/MARCspec
rc_spec>

=head1 METHODS

=head2 marc_map(MARC_PATH, JSON_PATH, OPT:VAL, OPT2:VAL,...)

Copy the value(s) of the data found at a MARC_PATH to a JSON_PATH.

The MARC_PATH can point to a MARC field. For
p('245ca',title, pluck:1)

=head2 value: Str

Don't write the value of the MARC (sub)field to the JSON_PATH but the specified
string value.

    # has_024_a will contain the value 'Y' if the MARC fiel
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_spec.pm ( view source; MetaCPAN )
b.io/MARCspec/>
for documentation on the path syntax.

=head1 METHODS

=head2 marc_spec(MARCspec, JSON_PATH, OPT:VAL, OPT2:VAL,...)

First parameter must be a string, following the syntax of
L<MARCspe
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/marc_replace_all.pm ( view source; MetaCPAN )
 VALUE. This value can be a literal or
reference an existing field in the record using the dollar JSON_PATH syntax.

=head1 INLINE

This Fix can be used inline in a Perl script:

    use Catmandu::Fix
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Validator/MARC.pm ( view source; MetaCPAN )
or load custom MARC schema
    my $validator = Catmandu::Validator::MARC->new( schema => 'schema.json' );

    my $importer = Catmandu::Importer::MARC->new(
        file => 't/camel.mrc',
       
ma.json')


=head1 DESCRIPTION

This L<Catmandu::Validator> can be used to check MARC records against an MARC21 schema. For more information see L<MARC::Schema> and L<"MARC21 structure in JSON"|h
ttps://pkiraly.github.io/2018/01/28/marc21-in-json/>.

See also L<Catmandu::Fix::validate>, and L<Catmandu::Fix::Condition::valid> for usage of validators in Catmandu Fix language.

=head1 CONFIGU
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/Inline/marc_set.pm ( view source; MetaCPAN )
teral value
 my $data  = marc_set($data,'245[1]a', 'value');

 # Set to a copy of a deeply nested JSON path
 my $data  = marc_set($data,'245[1]a', '$.my.deep.field');

 =head1 DEPRECATED

 This module
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Exporter/MARC/XML.pm ( view source; MetaCPAN )
my $indent = $self->collection ? 1 : 0;

    if ($self->record_format eq 'MARC-in-JSON') {
        $data = $self->_json_to_raw($data);
    }

    if ($self->collection) {
        $self->_line($indent,
 record (default: 'record')

=item record_format

Optionally set to 'MARC-in-JSON' when the input format is in MARC-in-JSON

=item collection

add a marc:collection header when true (default: true)

=
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Fix/Inline/marc_add.pm ( view source; MetaCPAN )
al value
 my $data  = marc_add($data, '245',  a => 'value');

 # Set to a copy of a deeply nested JSON path
 my $data  = marc_add($data, '245',  a => '$.my.deep.field');

=head1 DEPRECATED

This modul
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Exporter/MARC/Base.pm ( view source; MetaCPAN )
nd1, $ind2, @data);
            $marc->append_fields($field);
        }
    }

    $marc;
}

sub _json_to_raw {
    my ($self,$data) = @_;
    my @record = ();

    push (@record , [ 'LDR', ' ', ' ', 
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Exporter/MARC/ALEPHSEQ.pm ( view source; MetaCPAN )
;

sub add {
    my ($self,$data) = @_;

    if ($self->record_format eq 'MARC-in-JSON') {
        $data = $self->_json_to_raw($data);
    }

    my $id_str = $data->{_id};
    $id_str    =~ s{\D}{0}g
Catmandu-MARC ( H/HO/HOCHSTEN/Catmandu-MARC-1.33.tar.gz, HOCHSTEN, 2024; MetaCPAN )
Catmandu-MARC/lib/Catmandu/Exporter/MARC/MARCMaker.pm ( view source; MetaCPAN )
 );

sub add {
	my ($self, $data) = @_;

    if ($self->record_format eq 'MARC-in-JSON') {
        $data = $self->_json_to_raw($data);
    }

    for my $field (@{$data->{record}}) {
        my ($fiel

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.